wso2 bps使用ws-addressing进行异步调用

时间:2013-06-11 17:20:06

标签: jax-ws wso2 bpel ws-addressing

我正在尝试用wso2 bps开发一个bpel序列,它调用一个jax-ws web异步Web服务。 wso2似乎从服务接收回调,但它无法将其与原始请求链接,原始请求最终从框架收到错误(超时)响应。 根据我的理解,必须通过ws-addressing标头建立核心化;我找到了一些关于如何使用相关集进行操作的示例,但所有这些示例都将请求中的Id与响应中的另一个相关联,但这不是我的情况,因为我在请求和响应中没有“Id”字段消息。

如果处理此类问题的人可以向我发送一些示例代码

,那将对我有所帮助

使用来自wsdl的wsimport生成jax-ws Web服务,但是从运行时环境查询?wsdl url时获得的wsdl是不同的。 这是用wsimport处理的wsdl:

<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions
     name="processing"
     targetNamespace="http://processing.biosos.eu/"
     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
     xmlns:tns="http://processing.biosos.eu/"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
     xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
     xmlns:wsaw="http://www.w3.org/2006/03/addressing/ws-addr.xsd" 
     xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
    >
     <plnk:partnerLinkType name="ProcessorLinkType">
        <plnk:role name="ProcessingRequestor">
            <plnk:portType name="tns:ProcessorPortType"/>
        </plnk:role>
        <plnk:role name="ProcessingReponse">
            <plnk:portType name="tns:ProcessorResponsePortType"/>
        </plnk:role>
    </plnk:partnerLinkType>
    <wsdl:types>
<!--    <xsd:schema>
            <xsd:import namespace="http://processing.biosos.eu" schemaLocation="processor.xsd"/>
    </xsd:schema> -->
         <xs:schema version="1.0" targetNamespace="http://processing.biosos.eu/" xmlns:tns="http://processing.biosos.eu/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
            <xs:element name="ProcessingException" nillable="true" type="xs:string"/>
            <xs:element name="describeMetaDataIn" nillable="true" type="tns:metaDataSet"/>
            <xs:element name="describeMetaDataOut" nillable="true" type="tns:metaDataSet"/> 
            <xs:element name="executeMetaDataIn" nillable="true" type="tns:metaDataSet"/>
            <xs:element name="executeMetaDataOut" nillable="true" type="tns:metaDataSet"/>
            <xs:element name="executeAsyncMetaDataIn" nillable="true" type="tns:metaDataSet"/>
            <xs:element name="executeAsyncMetaDataInCallback" nillable="true" type="tns:metaDataSet"/>
            <xs:element name="describeasyncMetaDataIn" nillable="true" type="tns:metaDataSet"/> 
            <xs:element name="metaDataSet" type="tns:metaDataSet"/>
            <xs:complexType name="metaDataSet">
                <xs:sequence>
                    <xs:element name="metaData" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
                </xs:sequence>
            </xs:complexType>
        </xs:schema>     
    </wsdl:types>
    <wsdl:message name="WSAReplyToHeader">
        <wsdl:part name="ReplyTo" element="wsaw:ReplyTo"/>
    </wsdl:message>
    <wsdl:message name="WSARelatesToHeader">
        <wsdl:part name="RelatesTo" element="wsaw:RelatesTo"/>
    </wsdl:message>
    <wsdl:message name="executeProcessingAsyncCallbackInput">
        <wsdl:part name="executeAsyncMetaDataInCallback" element="tns:executeMetaDataIn"/>
    </wsdl:message>
    <wsdl:message name="executeProcessingAsyncInput">
        <wsdl:part name="executeAsyncMetaDataIn" element="tns:metaDataSet"/>
    </wsdl:message>
    <wsdl:portType name="executeProcessingRequest">
        <wsdl:operation name="executeProcessingAsync">
            <wsdl:input message="tns:executeProcessingAsyncInput" xmlns:ns1="http://www.w3.org/2006/05/addressing/wsdl"
                 ns1:Action=""/>
        </wsdl:operation>
    </wsdl:portType>
     <wsdl:portType name="executeProcessingResponse">
        <wsdl:operation name="executeProcessingAsyncCallback">
            <wsdl:input message="tns:executeProcessingAsyncCallbackInput" xmlns:ns1="http://www.w3.org/2006/05/addressing/wsdl"
                 ns1:Action=""/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="executeProcessingSoapHttp" type="tns:executeProcessingRequest">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
         <wsdl:operation name="executeProcessingAsync">
            <soap:operation soapAction="http://processing.biosos.eu/executeProcessing/executeProcessingRequest"/>
            <wsdl:input>
                <soap:header message="tns:WSAReplyToHeader"
                part="ReplyTo" use="literal" encodingStyle=""/>
                <soap:body use="literal"/>
            </wsdl:input>
        </wsdl:operation>
    </wsdl:binding>    
    <wsdl:binding name="executeProcessingResponseSoapHttp" type="tns:executeProcessingResponse">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="executeProcessingAsyncCallback">
            <soap:operation soapAction="http://processing.biosos.eu/executeProcessing/executeProcessingResponse"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="executeProcessingAsyncService">
        <wsdl:port name="executeProcessingPort" binding="tns:executeProcessingSoapHttp">
            <soap:address location="http://localhost:8088/processor/processor"/>
        </wsdl:port>
        <wsdl:port name="executeProcessingCallbackPort" binding="tns:executeProcessingResponseSoapHttp">
            <soap:address location="http://localhost:8088/processor/processorcallback"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

特别是它修改了

中的原始xsd
<xs:element name="executeMetaDataIn" nillable="true" type="tns:metaDataSet"/>
    <xs:complexType name="metaDataSet">
        <xs:sequence>
            <xs:element name="metaData" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

为:

<xs:element name="executeProcessingAsync" type="tns:executeProcessingAsync"/>
            <xs:complexType name="executeProcessingAsync">
                <xs:sequence>
                    <xs:element name="arg0" type="tns:metaDataSet" minOccurs="0"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="metaDataSet">
                <xs:sequence>
                    <xs:element name="metaData" type="xs:string" nillable="true" minOccurs="0"
                        maxOccurs="unbounded"/>
                </xs:sequence>
            </xs:complexType>

因此引入了一个显然无用的arg0;我在bpel项目中导入了修改后的xsd模式,否则wso2无法调用该服务。也许这就是问题的根源?

这是我偷窥的网络流量:

从我的浏览器到wso2 bps:

POST http://xxx.xxx.xx.xxx:9763/services/BPS.BPShttpBPSPortBindingEndpoint/ HTTP/1.1
Host: xxx.xxx.xx.xxx:9763
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
SOAPAction: "http://bps.biosos.eu/executeProcessing"
Content-Type: text/xml; charset=UTF-8
Referer: http://xxx.xxx.xx.xxx:9763/services/BPS?tryit
Content-Length: 690
Cookie: menuPanel=visible; menuPanelType=main; JSESSIONID=A1D548B8FE2D9CCA6F773CC48BBBCC4D; Modernizr=; current-breadcrumb=manage_menu%2Cbpel_menu%2Cprocesses_menu%23bpel+package_dashboard.jsp*bpel+process_info.jsp*; MSG13706026625390.7186655491334077=true; requestedURI="../../carbon/tracer/index.jsp?region=region4&item=tracer_menu"; MSG13706055948330.5890288764438495=true; MSG13706058104120.31469188642996127=true
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<s:Header><wsa:To>http://xxx.xxx.xx.xxx:9763/services/BPS.BPShttpBPSPortBindingEndpoint/</wsa:To>
<wsa:ReplyTo><wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address></wsa:ReplyTo>
<wsa:MessageID>http://identifiers.wso2.com/messageid/1370605864890/8335139899</wsa:MessageID>
<wsa:Action>http://bps.biosos.eu/executeProcessing</wsa:Action>
</s:Header>
<s:Body><p:executeMetaDataIn xmlns:p="http://bps.biosos.eu"><!--0 or more occurrences--><metaDataList>fdsdfd</metaDataList></p:executeMetaDataIn></s:Body>
</s:Envelope>

从wso2到外部jax-ws服务

POST /processor/processor?wsdl HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: "http://processing.biosos.eu/executeProcessing/executeProcessingRequest"
User-Agent: WSO2 Business Process Server-3.0.0
Host: xxx.xxx.xx.yyy:8080
Transfer-Encoding: chunked

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:ReplyTo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Address>http://xxx.xxx.xx.xxx:9763/services/processorcallback</Address>
</wsa:ReplyTo><wsa:To>http://toyota.planetek.it:8080/processor/processor?wsdl</wsa:To><wsa:MessageID>urn:uuid:c3942e49-004a-4cd7-86fb-866742c2c4b1</wsa:MessageID><wsa:Action>http://processing.biosos.eu/executeProcessing/executeProcessingRequest</wsa:Action></soapenv:Header><soapenv:Body><executeProcessingAsync xmlns="http://processing.biosos.eu/">
                        <arg0 xmlns="">
                         <metaData>lhhlh</metaData>
                         </arg0>
                        </executeProcessingAsync></soapenv:Body></soapenv:Envelope>

有回应 HTTP / 1.1 202接受

从jax-ws服务回调到wso2服务器:

POST /services/processorcallback HTTP/1.1
Accept: text/xml, multipart/related
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://processing.biosos.eu/executeProcessing/executeProcessingRequest"
User-Agent: JAX-WS RI 2.2.5-b01
Cache-Control: no-cache
Pragma: no-cache
Host: xxx.xxx.xx.yyy:9763
Connection: keep-alive
Content-Length: 257

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Header>
  <RelatesTo xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:c3942e49-004a-4cd7-86fb-866742c2c4b1</RelatesTo>
  <To xmlns="http://www.w3.org/2005/08/addressing">http://xxx.xxx.xx.yyy:9763/services/processorcallback</To>
  <Action xmlns="http://www.w3.org/2005/08/addressing">http://processing.biosos.eu/executeProcessing/executeProcessingResponse</Action>

metadata_out.xml

有回应 HTTP / 1.1 202接受

这是bpel文件:

<bpel:process name="BiososProcessing"
         targetNamespace="http://pk/bps/processing"
         suppressJoinFailure="yes"
         xmlns:tns="http://pk/bps/processing"
         xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
    <!-- Import the client WSDL -->
     <bpel:import namespace="http://enterprise.netbeans.org/bpel/BPSWrapper" location="BPSWrapper.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <bpel:import namespace="http://bps.biosos.eu" location="BPS.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <bpel:import namespace="http://enterprise.netbeans.org/bpel/Asyn_ProcessorWrapper" location="Asyn_ProcessorWrapper.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <bpel:import namespace="http://processing.biosos.eu/" location="Asyn_Processor.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"/>
    <!-- ================================================================= -->         
    <!-- PARTNERLINKS                                                      -->
    <!-- List of services participating in this BPEL process               -->
    <!-- ================================================================= -->         
    <bpel:partnerLinks>
         <bpel:partnerLink name="ProcPartnerLink" xmlns:tns="http://enterprise.netbeans.org/bpel/Asyn_ProcessorWrapper" partnerLinkType="tns:ExecuteProcessingLinkType" myRole="ExecuteProcessingReplyRole" partnerRole="ExecuteProcessingReceiverRole"/>
        <bpel:partnerLink name="BPSPartnerLink" xmlns:tns="http://enterprise.netbeans.org/bpel/BPSWrapper" partnerLinkType="tns:IBPSServiceLinkType" myRole="IBPSServiceRole"/>   
    </bpel:partnerLinks>  
    <!-- ================================================================= -->         
    <!-- VARIABLES                                                         -->
    <!-- List of messages and XML documents used within this BPEL process  -->
    <!-- ================================================================= -->         
    <bpel:variables>
        <!-- Reference to the message passed as input during initiation -->
         <bpel:variable name="BPSExecuteProcessingOut" xmlns:bps="http://bps.biosos.eu" messageType="bps:executeProcessingResponse"/>
         <bpel:variable name="ProcExecuteProcessingAsyncCallbackIn" xmlns:tns="http://processing.biosos.eu/" messageType="tns:executeProcessingAsyncCallback"/>
         <bpel:variable name="ProcExecuteProcessingAsyncIn" xmlns:tns="http://processing.biosos.eu/" messageType="tns:executeProcessingAsync"/>
         <bpel:variable name="ServiceInvokerIARequest" xmlns:tns="http://processing.biosos.eu/" messageType="tns:executeProcessingAsync"/>
         <bpel:variable name="BPSExecuteProcessingIn" xmlns:bps="http://bps.biosos.eu" messageType="bps:executeProcessing"/>   
    </bpel:variables>


    <!-- ================================================================= -->         
    <!-- ORCHESTRATION LOGIC                                               -->
    <!-- Set of activities coordinating the flow of messages across the    -->
    <!-- services integrated within this business process                  -->
    <!-- ================================================================= -->         

    <bpel:sequence name="main">
            <bpel:receive name="BPSReceive_executeProcessing" createInstance="yes" partnerLink="BPSPartnerLink" operation="executeProcessing" xmlns:bps="http://bps.biosos.eu" portType="bps:IBPSService" variable="BPSExecuteProcessingIn">
                <correlations>
                    <correlation set="correlator" initiate="yes"></correlation>
                </correlations>
            </bpel:receive>
        <bpel:assign name="Assign1">
            <bpel:copy>
                <bpel:from>
                    <bpel:literal>
                        <tns:executeProcessingAsync xmlns:tns="http://processing.biosos.eu/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><arg0>
    <metaData>metaData</metaData>
  </arg0>

                        </tns:executeProcessingAsync>
                    </bpel:literal>
                </bpel:from>
                <bpel:to variable="ProcExecuteProcessingAsyncIn" part="parameters"></bpel:to>
            </bpel:copy>
            <bpel:copy>
              <bpel:from>
               <bpel:literal xml:space="preserve"><wsa:ReplyTo xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                   <Address>http://avatar.planetek.it:9763/services/processorcallback</Address>

                 </wsa:ReplyTo></bpel:literal>
             </bpel:from>
             <bpel:to header="ReplyTo" variable="ProcExecuteProcessingAsyncIn">
             </bpel:to>
            </bpel:copy>
            <bpel:copy>
                <bpel:from part="executeMetaDataIn" variable="BPSExecuteProcessingIn">
                    <bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">
                        <![CDATA[metaDataList[1]]]>
                    </bpel:query>
                </bpel:from>
                <bpel:to part="parameters" variable="ProcExecuteProcessingAsyncIn">
                    <bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">
                        <![CDATA[arg0/metaData[1]]]>
                    </bpel:query>
                </bpel:to>
            </bpel:copy>
        </bpel:assign> 
                <bpel:invoke name="InvokeProcessor_executeProcessing" 
                partnerLink="ProcPartnerLink" 
                operation="executeProcessingAsync" 
                xmlns:tns="http://processing.biosos.eu/" 
                portType="tns:ExecuteProcessing" 
                inputVariable="ProcExecuteProcessingAsyncIn">       
                </bpel:invoke>
                <bpel:receive name="ProcReceive_executeprocessing" 
                  createInstance="no" 
                  partnerLink="ProcPartnerLink"
                  operation="executeProcessingAsyncCallback" 
                  xmlns:tns="http://processing.biosos.eu/"
                  portType="tns:ExecuteProcessingCallback" 
                  variable="ProcExecuteProcessingAsyncCallbackIn">
                  <correlations>
                    <correlation set="correlator" initiate="no"></correlation>
                  </correlations>           
                </bpel:receive>
        <bpel:assign name="Assign2">
            <bpel:copy>
                <bpel:from>
                    <bpel:literal>
                        <bps:executeMetaDataOut xmlns:bps="http://bps.biosos.eu" 
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                        <metaDataList>metaDataList</metaDataList>
                        </bps:executeMetaDataOut>
                    </bpel:literal>
                </bpel:from>
                <bpel:to variable="BPSExecuteProcessingOut" part="executeMetaDataOut"></bpel:to>
            </bpel:copy>
             <bpel:copy>
                <bpel:from part="parameters" variable="ProcExecuteProcessingAsyncCallbackIn">
                    <bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[arg0/metaData[1]]]></bpel:query>
                </bpel:from>
                <bpel:to part="executeMetaDataOut" variable="BPSExecuteProcessingOut">
                    <bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[metaDataList[1]]]></bpel:query>
                </bpel:to>
            </bpel:copy>       
        </bpel:assign>
        <bpel:reply name="BPSReply_executeProcessing" partnerLink="BPSPartnerLink" operation="executeProcessing" xmlns:bps="http://bps.biosos.eu" portType="bps:IBPSService" variable="BPSExecuteProcessingOut"/>
    </bpel:sequence>
</bpel:process>

0 个答案:

没有答案