0

我已经使用 Apache camel 创建了一个代理服务。

这是我的 camel-config.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>

<!-- START SNIPPET: e1 -->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:cxf="http://camel.apache.org/schema/cxf"
       xmlns:cxfcore="http://cxf.apache.org/core"
       xmlns:sec="http://cxf.apache.org/configuration/security"
       xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
       http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
       http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
       http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
       http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
       ">

  <cxfcore:bus/>

  <httpj:engine-factory bus="cxf">
      <httpj:engine port='8243'>
        <httpj:tlsServerParameters>
          <sec:keyManagers keyPassword="skpass">
            <sec:keyStore file="D:/eclipse/tomcat-7.0.29-camel/webapps/Version.Security/WEB-INF/classes/certs/serviceKeystore.jks" password="sspass" type="JKS"/>
          </sec:keyManagers>
          <sec:trustManagers>
            <sec:keyStore file="D:/eclipse/tomcat-7.0.29-camel/webapps/Version.Security/WEB-INF/classes/certs/serviceKeystore.jks" password="sspass" type="JKS"/>
          </sec:trustManagers>
          <sec:cipherSuitesFilter>
            <sec:include>.*_WITH_3DES_.*</sec:include>
            <sec:include>.*_WITH_DES_.*</sec:include>
            <sec:exclude>.*_WITH_NULL_.*</sec:exclude>
            <sec:exclude>.*_DH_anon_.*</sec:exclude>
          </sec:cipherSuitesFilter>
          <sec:clientAuthentication want="true" required="false"/>
        </httpj:tlsServerParameters>
      </httpj:engine>
    </httpj:engine-factory>


  <!-- bean that enriches the SOAP request -->
  <bean id="enrichBean" class="org.apache.camel.example.cxf.proxy.EnrichBean"/>

  <bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
  <bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>

  <bean id="wss4jInConfiguration" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
    <property name="properties">
        <map>
            <entry key="action" value="UsernameToken Timestamp"/>
            <entry key="passwordType" value="PasswordText" />
            <entry>
                <key>
                    <value>passwordCallbackRef</value>
                </key>
              <ref bean="passwordCallback"/>
            </entry>
        </map>
    </property>
    </bean>

    <bean id="passwordCallback" class="org.apache.camel.example.cxf.proxy.UTPasswordCallback"/>

  <!-- this is the CXF web service we use as the front end -->
  **<cxf:cxfEndpoint id="securityService"
                   address="http://localhost:8280/services/Version.Security"
                   endpointName="s:Version.SecurityHttpsSoap11Endpoint"                
                   serviceName="s:Version.Security"
                   wsdlURL="etc/Version.Security.wsdl"
                   xmlns:s="http://axisversion.sample">

    <cxf:properties>
        <entry key="publishedEndpointUrl" value="https://localhost:8243/services/Version.Security.Version.SecurityHttpsSoap11Endpoint" />
   </cxf:properties>**

    <cxf:inInterceptors>
            <ref bean="loggingInInterceptor"/>
            <ref bean="wss4jInConfiguration"/>
    </cxf:inInterceptors>
    <cxf:outInterceptors>
            <ref bean="loggingOutInterceptor"/>
    </cxf:outInterceptors>
  </cxf:cxfEndpoint>

  <!-- this is the Camel route which proxies the real web service and forwards SOAP requests to it -->
  <camelContext xmlns="http://camel.apache.org/schema/spring">

    <!-- property which contains port number -->
    <propertyPlaceholder id="properties" location="classpath:incident.properties,file:target/custom.properties"/>

    <endpoint id="callRealWebService" uri="http://10.115.115.115:8080/axis2/services/Version.Security?throwExceptionOnFailure=false"/>

    <route>
      <!-- CXF consumer using MESSAGE format -->
      <from uri="cxf:bean:securityService?dataFormat=PAYLOAD"/>
      <!-- log input received -->
      <to uri="log:input"/>
      <!-- enrich the input by ensure the incidentId parameter is set -->
      <to uri="bean:enrichBean"/>
      <!-- opp removing headers... testing -->
      <removeHeaders pattern="CamelHttp*" />
      <!-- send proxied request to real web service -->
      <to ref="callRealWebService"/>
      <!-- log answer from real web service -->
      <to uri="log:output"/>
    </route>

  </camelContext>

</beans>
<!-- END SNIPPET: e1 -->

现在我的 wsdl 文件打开了http://localhost:8280/services/Version.Security?wsdl,我的端点 url 是 https://localhost:8243/services/Version.Security.Version.SecurityHttpsSoap11Endpoint

代理的创建没有任何错误,但是当我在soap UI中调用上述服务时,我在SOAP UI中得到一个错误:

Mon Dec 01 12:55:31 IST 2014:ERROR:org.apache.http.conn.HttpHostConnectException: Connection to https://localhost:8243 refused
   org.apache.http.conn.HttpHostConnectException: Connection to https://localhost:8243 refused
    at com.eviware.soapui.impl.wsdl.support.http.SoapUIMultiThreadedHttpConnectionManager$SoapUIClientConnectionOperator.openConnection(SoapUIMultiThreadedHttpConnectionManager.java:321)
    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:561)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
    at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport$Helper.execute(HttpClientSupport.java:246)
    at com.eviware.soapui.impl.wsdl.support.http.HttpClientSupport.execute(HttpClientSupport.java:356)
    at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.submitRequest(HttpClientRequestTransport.java:317)
    at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.sendRequest(HttpClientRequestTransport.java:231)
    at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:123)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
   Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
    at com.eviware.soapui.impl.wsdl.support.http.SoapUISSLSocketFactory.connectSocket(SoapUISSLSocketFactory.java:218)
    at com.eviware.soapui.impl.wsdl.support.http.SoapUIMultiThreadedHttpConnectionManager$SoapUIClientConnectionOperator.openConnection(SoapUIMultiThreadedHttpConnectionManager.java:299)
    ... 17 more

我无法弄清楚是什么问题..

还有一件事,如果我从 camel-config.xml 中删除以下部分

<cxf:properties>
        <entry key="publishedEndpointUrl" value="https://localhost:8243/services/Version.Security.Version.SecurityHttpsSoap11Endpoint" />
   </cxf:properties>

无论 wsdl url 是 http 还是 https,代理服务都能正常工作。

期待您的回答。提前致谢

4

1 回答 1

0

如果您在 cxf 服务之前有负载平衡服务器,则将 publishedEndpointUrl 定义为负载平衡地址是有意义的。

对于您的情况,您似乎希望通过 SOAP UI 访问那里的侦听器上的其他地址。

于 2014-12-02T00:53:40.287 回答