2014-07-08 306 views
0

我嘗試在WSO2 ESB中使用代理和API來測試類似SOAP Web服務的聚合到一個響應中,但我只是有超時。爲了進行測試,我使用了Weather Web服務(http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl)。我基本上通過使用克隆介質調用GetCityWeatherByZIP兩次相同的操作,爲每個ZIP代碼提供不同的郵政編碼,然後彙總結果。最終目的是調用託管在不同服務器上的Web服務,但目前我正嘗試使用相同的服務。我將不勝感激任何幫助。wso2 ESB:克隆和聚合超時

下面是代理配置:

<?xml version="1.0" encoding="UTF-8"?> 
    <proxy xmlns="http://ws.apache.org/ns/synapse" 
     name="aggre" 
     transports="http" 
     statistics="disable" 
     trace="enable" 
     startOnLoad="true"> 
     <target> 
     <inSequence> 
     <clone> 
      <target> 
       <sequence> 
        <payloadFactory media-type="xml"> 
        <format> 
         <m0:GetCityWeatherByZIP xmlns:m0="http://ws.cdyne.com/WeatherWS/"> 
          <m0:ZIP>11001</m0:ZIP> 
         </m0:GetCityWeatherByZIP> 
        </format> 
        <args/> 
        </payloadFactory> 
        <header name="Action" scope="default" value="urn:GetCityWeatherByZIP "/> 
        <call> 
        <endpoint key="weather"/> 
        </call> 
       </sequence> 
      </target> 
      <target> 
       <sequence> 
        <payloadFactory media-type="xml"> 
        <format> 
         <m0:GetCityWeatherByZIP xmlns:m0="http://ws.cdyne.com/WeatherWS/"> 
          <m0:ZIP>11010</m0:ZIP> 
         </m0:GetCityWeatherByZIP> 
        </format> 
        <args/> 
        </payloadFactory> 
        <header name="Action" scope="default" value="urn:GetCityWeatherByZIP "/> 
        <call> 
        <endpoint key="weather"/> 
        </call> 
       </sequence> 
      </target> 
     </clone> 
     <aggregate> 
      <completeCondition> 
       <messageCount min="-1" max="-1"/> 
      </completeCondition> 
      <onComplete xmlns:m0="http://ws.cdyne.com/WeatherWS" 
         expression="/m0:GetCityWeatherByZIPResponse"> 
       <drop/> 
      </onComplete> 
     </aggregate> 
     </inSequence> 
     <outSequence> 
     <send/> 
     </outSequence> 
     </target> 
     <description/> 
    </proxy> 

下面天氣端點配置:

<endpoint xmlns="http://ws.apache.org/ns/synapse" name="weather"> 
    <address uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx" format="soap11"> 
     <suspendOnFailure> 
     <progressionFactor>1.0</progressionFactor> 
     </suspendOnFailure> 
     <markForSuspension> 
     <retriesBeforeSuspension>0</retriesBeforeSuspension> 
     <retryDelay>0</retryDelay> 
     </markForSuspension> 
    </address> 
</endpoint> 

碳日誌:

TID: [0] [ESB] [2014-07-08 11:10:44,377] INFO {org.apache.axis2.transport.http.HTTPSender} - Unable to sendViaPost to url[http://servername:8281/services/aggre.aggreHttpSoap11Endpoint] {org.apache.axis2.transport.http.HTTPSender} 
java.net.SocketTimeoutException: Read timed out 
    at java.net.SocketInputStream.socketRead0(Native Method) 
    at java.net.SocketInputStream.read(SocketInputStream.java:150) 
    at java.net.SocketInputStream.read(SocketInputStream.java:121) 
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) 
    at java.io.BufferedInputStream.read(BufferedInputStream.java:254) 
    at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78) 
    at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106) 
    at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116) 
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413) 
    at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973) 
    at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735) 
    at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098) 
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) 
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) 
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) 
    at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:622) 
    at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193) 
    at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75) 
    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:451) 
    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:278) 
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442) 
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:430) 
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225) 
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149) 
    at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:554) 
    at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:530) 
    at org.apache.jsp.admin.jsp.WSRequestXSSproxy_005fajaxprocessor_jsp._jspService(org.apache.jsp.admin.jsp.WSRequestXSSproxy_005fajaxprocessor_jsp:276) 
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) 
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403) 
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492) 
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) 
    at org.wso2.carbon.ui.JspServlet.service(JspServlet.java:155) 
    at org.wso2.carbon.ui.TilesJspServlet.service(TilesJspServlet.java:80) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) 
    at org.eclipse.equinox.http.helper.ContextPathServletAdaptor.service(ContextPathServletAdaptor.java:37) 
    at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61) 
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128) 
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:68) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) 
    at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.service(DelegationServlet.java:68) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.wso2.carbon.tomcat.ext.filter.CharacterSetFilter.doFilter(CharacterSetFilter.java:61) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) 
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) 
    at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:178) 
    at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:49) 
    at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:141) 
    at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:156) 
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936) 
    at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:52) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) 
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004) 
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) 
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
    at java.lang.Thread.run(Thread.java:722) 
TID: [0] [ESB] [2014-07-08 11:10:44,420] WARN {org.apache.synapse.transport.passthru.SourceHandler} - Connection time out after request is read: http-incoming-295 {org.apache.synapse.transport.passthru.SourceHandler} 

回答

1

SOAP動作不正確,必須http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP

命名空間聚集的的onComplete XPath表達式是不正確,一個「/」是在最後丟失:http://ws.cdyne.com/WeatherWS/

聚集之後,你就不想放棄的消息,你想送它作爲響應:在「的onComplete」調解

<send/>取代<drop/>的響應將是如OAP消息和SOAP體必須有一個根節點作爲第一個孩子,所以你必須應用改造,爭取爲例:

<payloadFactory media-type="xml"> 
    <format> 
    <response> 
     $1 
    </response> 
    </format> 
    <args> 
    <arg evaluator="xml" xmlns:m0="http://ws.cdyne.com/WeatherWS/" expression="//m0:GetCityWeatherByZIPResponse"/> 
    </args> 
</payloadFactory> 

默認情況下,克隆調解停止父母調解,你需要指定continueParent="true",如果你想聚合要執行

使用呼叫調停,強調工作線程的回報,而不必等待迴應:執行總調解人,測試,如果消息是GetCityWeatherByZIPResponse

完成前:用於執行代理將達到你的總要求代理:

<?xml version="1.0" encoding="UTF-8"?> 
    <proxy xmlns="http://ws.apache.org/ns/synapse" 
     name="TestSOF" 
     transports="http" 
     statistics="disable" 
     trace="enable" 
     startOnLoad="true"> 
     <target> 
     <inSequence> 
     <clone continueParent="true"> 
      <target> 
       <sequence> 
        <payloadFactory media-type="xml"> 
        <format> 
         <m0:GetCityWeatherByZIP xmlns:m0="http://ws.cdyne.com/WeatherWS/"> 
          <m0:ZIP>11001</m0:ZIP> 
         </m0:GetCityWeatherByZIP> 
        </format> 
        <args/> 
        </payloadFactory> 
        <header name="Action" scope="default" value="http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP"/> 
        <call> 
        <endpoint key="weather"/> 
        </call> 
       </sequence> 
      </target> 
      <target> 
       <sequence> 
        <payloadFactory media-type="xml"> 
        <format> 
         <m0:GetCityWeatherByZIP xmlns:m0="http://ws.cdyne.com/WeatherWS/"> 
          <m0:ZIP>11010</m0:ZIP> 
         </m0:GetCityWeatherByZIP> 
        </format> 
        <args/> 
        </payloadFactory> 
        <header name="Action" scope="default" value="http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP"/> 
        <call> 
        <endpoint key="weather"/> 
        </call> 
       </sequence> 
      </target> 
     </clone> 
     <filter source="local-name($body/*[1])" regex="GetCityWeatherByZIPResponse"> 
      <then> 
       <aggregate> 
        <completeCondition> 
         <messageCount min="-1" max="-1"/> 
        </completeCondition> 
        <onComplete xmlns:m0="http://ws.cdyne.com/WeatherWS/" 
           expression="//m0:GetCityWeatherByZIPResponse"> 
         <payloadFactory media-type="xml"> 
          <format> 
           <response> 
           $1 
           </response> 
          </format> 
          <args> 
           <arg evaluator="xml" xmlns:m0="http://ws.cdyne.com/WeatherWS/" expression="//m0:GetCityWeatherByZIPResponse"/> 
          </args> 
         </payloadFactory> 
         <send/> 
        </onComplete> 
       </aggregate> 
      </then> 
     </filter> 
     </inSequence> 
     <outSequence> 
     <send/> 
     </outSequence> 
     </target> 
     <description/> 
    </proxy> 

端點:

<?xml version="1.0" encoding="UTF-8"?> 
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="weather"> 
    <wsdl service="Weather" 
     port="WeatherSoap" 
     uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"/> 
</endpoint> 

的響應,我得到:

<response xmlns="http://ws.apache.org/ns/synapse"> 
<GetCityWeatherByZIPResponse xmlns="http://ws.cdyne.com/WeatherWS/"> 
<GetCityWeatherByZIPResult> 
<Success>true</Success> 
<ResponseText>City Found</ResponseText> 
<State>NY</State> 
<City>Franklin Square</City> 
<WeatherStationCity>Farmingdale</WeatherStationCity> 
<WeatherID>14</WeatherID> 
<Description>Cloudy</Description> 
<Temperature>73</Temperature> 
<RelativeHumidity>78</RelativeHumidity> 
<Wind>S6</Wind> 
<Pressure>29.75R</Pressure> 
<Visibility/> 
<WindChill/> 
<Remarks/> 
</GetCityWeatherByZIPResult> 
</GetCityWeatherByZIPResponse> 
<GetCityWeatherByZIPResponse xmlns="http://ws.cdyne.com/WeatherWS/"> 
<GetCityWeatherByZIPResult> 
<Success>true</Success> 
<ResponseText>City Found</ResponseText> 
<State>NY</State> 
<City>Floral Park</City> 
<WeatherStationCity>Farmingdale</WeatherStationCity> 
<WeatherID>14</WeatherID> 
<Description>Cloudy</Description> 
<Temperature>73</Temperature> 
<RelativeHumidity>78</RelativeHumidity> 
<Wind>S6</Wind> 
<Pressure>29.75R</Pressure> 
<Visibility/> 
<WindChill/> 
<Remarks/> 
</GetCityWeatherByZIPResult> 
</GetCityWeatherByZIPResponse> 
</response> 
+0

非常感謝。它的工作原理,你幫我明白我做錯了什麼:) – Noel

+0

我正在研究同樣的事情,但我在克隆中使用了兩個不同的終點。我使用呼叫中介,它甚至沒有進入序列。它正在拋出時間..你能幫助我嗎? –

+0

嘗試使用SoapUI來查看是否得到迴應並測量響應時間 –

0

呼叫中介依靠無阻塞傳輸:編輯repository/conf/nhttp.properties並添加 http.socket.timeout.sender = 60000,如果你同意等待60秒

+0

謝謝,但我做的配置變化,它仍然超時。 Tbh,我不一定需要使用Call調解器。但我嘗試使用克隆與無發送或呼叫;我也嘗試過把總量也放在後面。但無論我做什麼,我都會繼續超時。使用Payload工廠和發送(無需克隆和聚合)調用一次天氣Web服務時,這很奇怪,我在幾秒鐘內得到響應。所以這裏有一些我找不到的地方非常錯誤。我還可以做些什麼? – Noel