1

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

如果处理此类问题的人可以向我发送一些示例代码,这对我会有帮助

jax-ws Web 服务是使用 wsimport 从 wsdl 生成的,但是从运行时环境中查询 ?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>

元数据输出.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>
4

0 回答 0