调用骆驼代理 Web 服务时出错



我使用Apache骆驼创建了一个代理服务。

这是我的骆驼配置.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

代理的创建没有任何错误,但是当我在肥皂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

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

还有一件事,如果我从骆驼配置中删除以下部分.xml

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

无论 wsdl url 是 http 还是 https,代理服务都能完美运行。

期待您的回答。提前致谢

如果在 cxf 服务之前有负载平衡服务器,则定义负载平衡地址的已发布终结点 URL 是有意义的。

对于您的情况,看起来您希望 SOAP UI 访问侦听器上的其他地址。

最新更新