我正在尝试使用BPEL进行简单的服务编排:我有一项服务,其中包含允许我上传文件的操作,并且我希望使用允许我上传多个文件的过程来编排它。< / p>
为了达到这个目的,我定义了一个输入变量,它是一个自定义元素数组,每个元素都包含一个字符串(名称)和一个base64Binary(文件内容)。
我要做的是接收这些文件并使用ForEach循环调用上传服务,该循环将迭代直到所有文件都上传完毕。
我已经在Apache ODE中成功部署了我的进程,并且我使用WSDL2Java生成了一个客户端来测试它。 问题是,当我调用服务时,我得到了一个Axis Fault:
Exception in thread "main" org.apache.axis2.AxisFault: axis2ns75:selectionFailure
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at _import.invocation.ws.ImportOrchestrationStub.process(ImportOrchestrationStub.java:182)
at it.italsystem.client.Client.main(Client.java:58)
当我调用存根的进程方法时,会出现异常。
我已经读过,当你尝试使用一些尚未初始化的变量时,通常会出现这种失败,但它们应该是,因为我正在使用BPEL设计器进行Eclipse,当我添加一些assign活动时,它会询问我,如果我想初始化变量。
我希望有人可以给我一些建议,或者告诉我,如果我做的事情很愚蠢,因为我对BPEL很新:)
这是我的流程'代码:
<bpel:process name="ImportOrchestration"
targetNamespace="http://ws.invocation.import"
suppressJoinFailure="yes"
xmlns:tns="http://ws.invocation.import"
xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
xmlns:ns1="http://services.italsystem.it">
<!-- Import the client WSDL -->
<!-- <bpel:import importType="http://schemas.xmlsoap.org/wsdl/"></bpel:import> -->
<bpel:import namespace="http://services.italsystem.it" location="ImportModule.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"></bpel:import>
<bpel:import location="ImportOrchestrationArtifacts.wsdl" namespace="http://ws.invocation.import"
importType="http://schemas.xmlsoap.org/wsdl/" />
<!-- ================================================================= -->
<!-- PARTNERLINKS -->
<!-- List of services participating in this BPEL process -->
<!-- ================================================================= -->
<bpel:partnerLinks>
<!-- The 'client' role represents the requester of this service. -->
<bpel:partnerLink name="client"
partnerLinkType="tns:ImportOrchestration"
myRole="ImportOrchestrationProvider"
/>
<bpel:partnerLink name="ImportPL" partnerLinkType="tns:ImportType" partnerRole="ImportRole"></bpel:partnerLink>
</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="input"
messageType="tns:ImportOrchestrationRequestMessage"/>
<!--
Reference to the message that will be returned to the requester
-->
<bpel:variable name="output"
messageType="tns:ImportOrchestrationResponseMessage"/>
<bpel:variable name="ImportPLRequest" element="ns1:importSingleFile"/>
<bpel:variable name="ImportPLResponse" element="ns1:importFileResponse"/>
</bpel:variables>
<!-- ================================================================= -->
<!-- ORCHESTRATION LOGIC -->
<!-- Set of activities coordinating the flow of messages across the -->
<!-- services integrated within this business process -->
<!-- ================================================================= -->
<bpel:sequence name="main"><!-- Receive input from requester.
Note: This maps to operation defined in ImportOrchestration.wsdl
-->
<bpel:receive name="receiveInput" partnerLink="client" portType="tns:ImportOrchestration" operation="process" variable="input" createInstance="yes" />
<!-- Generate reply to synchronous request -->
<bpel:forEach parallel="no" counterName="Counter" name="ForEach" xmlns:http="urn:http:namesapce">
<bpel:startCounterValue>1</bpel:startCounterValue>
<bpel:finalCounterValue>
<![CDATA[count($input.payload/tns:file/tns:name)]]>
</bpel:finalCounterValue>
<bpel:scope>
<bpel:sequence>
<bpel:assign validate="no" name="Assign">
<bpel:copy>
<bpel:from>
<![CDATA[$input.payload/tns:file/tns:name]]>
</bpel:from>
<bpel:to variable="ImportPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[ns1:name]]></bpel:query>
</bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from>
<![CDATA[$input.payload/tns:file/tns:content]]>
</bpel:from>
<bpel:to variable="ImportPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[ns1:content]]></bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:invoke name="Invoke" partnerLink="ImportPL" operation="importSingleFile" portType="ns1:ImportServicePortType" inputVariable="ImportPLRequest1" outputVariable="ImportPLResponse1"></bpel:invoke>
</bpel:sequence>
<bpel:variables>
<bpel:variable name="ImportPLResponse1" messageType="ns1:importSingleFileResponse"></bpel:variable>
<bpel:variable name="ImportPLRequest1" messageType="ns1:importSingleFileRequest"></bpel:variable>
</bpel:variables>
</bpel:scope>
</bpel:forEach>
<bpel:assign validate="no" name="Assign1">
<bpel:copy>
<bpel:from>
<bpel:literal xml:space="preserve">"Done!"</bpel:literal>
</bpel:from>
<bpel:to part="payload" variable="output">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:result]]></bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:reply name="replyOutput" partnerLink="client" portType="tns:ImportOrchestration" operation="process" variable="output" />
</bpel:sequence>
</bpel:process>
更新:在您的建议之后我做了一些更改,结果如下:
<bpel:process name="ImportOrchestration"
targetNamespace="http://ws.invocation.import"
suppressJoinFailure="yes"
xmlns:tns="http://ws.invocation.import"
xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
xmlns:ns1="http://services.italsystem.it">
<bpel:import namespace="http://services.italsystem.it" location="ImportModule.wsdl" importType="http://schemas.xmlsoap.org/wsdl/"></bpel:import>
<bpel:import location="ImportOrchestrationArtifacts.wsdl" namespace="http://ws.invocation.import"
importType="http://schemas.xmlsoap.org/wsdl/" />
<bpel:partnerLinks>
<bpel:partnerLink name="client"
partnerLinkType="tns:ImportOrchestration"
myRole="ImportOrchestrationProvider"
/>
<bpel:partnerLink name="ImportPL" partnerLinkType="tns:ImportType" partnerRole="ImportRole"></bpel:partnerLink>
</bpel:partnerLinks>
<bpel:variables>
<bpel:variable name="input"
messageType="tns:ImportOrchestrationRequestMessage"/>
<bpel:variable name="output"
messageType="tns:ImportOrchestrationResponseMessage"/>
<bpel:variable name="ImportPLResponse" messageType="ns1:importSingleFileResponse"></bpel:variable>
<bpel:variable name="ImportPLRequest" messageType="ns1:importSingleFileRequest"></bpel:variable>
</bpel:variables>
<bpel:sequence name="main">
<bpel:receive name="receiveInput" partnerLink="client" portType="tns:ImportOrchestration" operation="process" variable="input" createInstance="yes" />
<bpel:forEach parallel="no" counterName="Counter" name="ForEach" xmlns:http="urn:http:namesapce">
<bpel:startCounterValue>1</bpel:startCounterValue>
<bpel:finalCounterValue>
<![CDATA[count($input.payload/tns:file/tns:name)]]>
</bpel:finalCounterValue>
<bpel:scope>
<bpel:sequence>
<bpel:assign validate="no" name="InitializeAssign">
<bpel:copy>
<bpel:from>
<bpel:literal xml:space="preserve">0</bpel:literal>
</bpel:from>
<bpel:to part="parameters" variable="ImportPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[ns1:name]]></bpel:query>
</bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from>
<bpel:literal xml:space="preserve">0</bpel:literal>
</bpel:from>
<bpel:to part="parameters" variable="ImportPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[ns1:content]]></bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:assign validate="no" name="Assign">
<bpel:copy>
<bpel:from>
<![CDATA[$input.payload/tns:file/tns:name]]>
</bpel:from>
<bpel:to variable="ImportPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[ns1:name]]></bpel:query>
</bpel:to>
</bpel:copy>
<bpel:copy>
<bpel:from>
<![CDATA[$input.payload/tns:file/tns:content]]>
</bpel:from>
<bpel:to variable="ImportPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[ns1:content]]></bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:invoke name="Invoke" partnerLink="ImportPL" operation="importSingleFile" portType="ns1:ImportServicePortType" inputVariable="ImportPLRequest" outputVariable="ImportPLResponse"></bpel:invoke>
</bpel:sequence>
</bpel:scope>
</bpel:forEach>
<bpel:assign validate="no" name="Assign1">
<bpel:copy>
<bpel:from>
<bpel:literal xml:space="preserve">DONE</bpel:literal>
</bpel:from>
<bpel:to part="payload" variable="output">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:result]]></bpel:query>
</bpel:to>
</bpel:copy>
</bpel:assign>
<bpel:reply name="replyOutput" partnerLink="client" portType="tns:ImportOrchestration" operation="process" variable="output" />
</bpel:sequence>
</bpel:process>
此处还有Eclipse BPEL Designer生成的WSDL文件:
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.invocation.import" xmlns:vprop="http://docs.oasis-open.org/wsbpel/2.0/varprop" xmlns:wsdl="http://services.italsystem.it" name="ImportOrchestration" targetNamespace="http://ws.invocation.import">
<plnk:partnerLinkType name="ImportType">
<plnk:role name="ImportRole" portType="wsdl:ImportServicePortType"/>
</plnk:partnerLinkType>
<import location="ImportModule.wsdl" namespace="http://services.italsystem.it"/>
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://ws.invocation.import">
<element name="ImportOrchestrationRequest" type="tns:ImportOrchestrationReqType">
</element>
<element name="singleEntry">
<complexType>
<sequence>
<element minOccurs="0" name="name" nillable="true" type="string"/>
<element minOccurs="0" name="content" nillable="true" type="base64Binary"/>
</sequence>
</complexType>
</element>
<element name="ImportOrchestrationResponse">
<complexType>
<sequence>
<element name="result" type="string"/>
</sequence>
</complexType>
</element>
<complexType name="ImportOrchestrationReqType">
<sequence minOccurs="1" maxOccurs="unbounded">
<element name="file" type="tns:SingleFile"></element>
</sequence>
</complexType>
<complexType name="SingleFile">
<sequence>
<element name="name" type="string"></element>
<element name="content" type="base64Binary"></element>
</sequence>
</complexType>
</schema>
</types>
<message name="ImportOrchestrationRequestMessage">
<part name="payload" element="tns:ImportOrchestrationRequest"/>
</message>
<message name="ImportOrchestrationResponseMessage">
<part element="tns:ImportOrchestrationResponse" name="payload"/>
</message>
<portType name="ImportOrchestration">
<operation name="process">
<input message="tns:ImportOrchestrationRequestMessage"/>
<output message="tns:ImportOrchestrationResponseMessage"/>
</operation>
</portType>
<plnk:partnerLinkType name="ImportOrchestration">
<plnk:role name="ImportOrchestrationProvider" portType="tns:ImportOrchestration"/>
</plnk:partnerLinkType>
<binding name="ImportOrchestrationBinding" type="tns:ImportOrchestration">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="process">
<soap:operation soapAction="http://ws.invocation.import/process"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="ImportOrchestration">
<port binding="tns:ImportOrchestrationBinding" name="ImportOrchestrationPort">
<soap:address location="http://localhost:8080/ode/processes/ImportOrchestration"/>
</port>
</service>
</definitions>
最后,该流程使用的服务的WSDL。它有2个操作,但进程使用的唯一一个是“importFile”。
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://services.italsystem.it" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax23="http://exceptions.italsystem.it/xsd" 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/" targetNamespace="http://services.italsystem.it">
<wsdl:documentation>ImportService</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://exceptions.italsystem.it/xsd">
<xs:complexType name="ServiceException">
<xs:complexContent>
<xs:extension base="xs:anyType" />
</xs:complexContent>
</xs:complexType>
</xs:schema>
<xs:schema xmlns:ax24="http://exceptions.italsystem.it/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://services.italsystem.it">
<xs:import namespace="http://exceptions.italsystem.it/xsd"/>
<xs:element name="ImportServiceServiceException">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="ServiceException" nillable="true" type="ax23:ServiceException"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="importFile">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="dh" nillable="true" type="xs:base64Binary"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="importFileResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="importSingleFile">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="content" nillable="true" type="xs:base64Binary"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="importSingleFileResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="importFileRequest">
<wsdl:part name="parameters" element="ns:importFile"/>
</wsdl:message>
<wsdl:message name="importFileResponse">
<wsdl:part name="parameters" element="ns:importFileResponse"/>
</wsdl:message>
<wsdl:message name="ImportServiceServiceException">
<wsdl:part name="parameters" element="ns:ImportServiceServiceException"/>
</wsdl:message>
<wsdl:message name="importSingleFileRequest">
<wsdl:part name="parameters" element="ns:importSingleFile"/>
</wsdl:message>
<wsdl:message name="importSingleFileResponse">
<wsdl:part name="parameters" element="ns:importSingleFileResponse"/>
</wsdl:message>
<wsdl:portType name="ImportServicePortType">
<wsdl:operation name="importFile">
<wsdl:input message="ns:importFileRequest" wsaw:Action="urn:importFile"/>
<wsdl:output message="ns:importFileResponse" wsaw:Action="urn:importFileResponse"/>
<wsdl:fault message="ns:ImportServiceServiceException" name="ImportServiceServiceException" wsaw:Action="urn:importFileImportServiceServiceException"/>
</wsdl:operation>
<wsdl:operation name="importSingleFile">
<wsdl:input message="ns:importSingleFileRequest" wsaw:Action="urn:importSingleFile"/>
<wsdl:output message="ns:importSingleFileResponse" wsaw:Action="urn:importSingleFileResponse"/>
<wsdl:fault message="ns:ImportServiceServiceException" name="ImportServiceServiceException" wsaw:Action="urn:importSingleFileImportServiceServiceException"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ImportServiceSoap11Binding" type="ns:ImportServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="importFile">
<soap:operation soapAction="urn:importFile" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="ImportServiceServiceException">
<soap:fault use="literal" name="ImportServiceServiceException"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="importSingleFile">
<soap:operation soapAction="urn:importSingleFile" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="ImportServiceServiceException">
<soap:fault use="literal" name="ImportServiceServiceException"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="ImportServiceSoap12Binding" type="ns:ImportServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="importFile">
<soap12:operation soapAction="urn:importFile" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="ImportServiceServiceException">
<soap12:fault use="literal" name="ImportServiceServiceException"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="importSingleFile">
<soap12:operation soapAction="urn:importSingleFile" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="ImportServiceServiceException">
<soap12:fault use="literal" name="ImportServiceServiceException"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="ImportServiceHttpBinding" type="ns:ImportServicePortType">
<http:binding verb="POST"/>
<wsdl:operation name="importFile">
<http:operation location="importFile"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="importSingleFile">
<http:operation location="importSingleFile"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ImportService">
<wsdl:port name="ImportServiceHttpSoap11Endpoint" binding="ns:ImportServiceSoap11Binding">
<soap:address location="http://localhost:8080/axis2/services/ImportService.ImportServiceHttpSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="ImportServiceHttpSoap12Endpoint" binding="ns:ImportServiceSoap12Binding">
<soap12:address location="http://localhost:8080/axis2/services/ImportService.ImportServiceHttpSoap12Endpoint/"/>
</wsdl:port>
<wsdl:port name="ImportServiceHttpEndpoint" binding="ns:ImportServiceHttpBinding">
<http:address location="http://localhost:8080/axis2/services/ImportService.ImportServiceHttpEndpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
答案 0 :(得分:1)
查看BPEL文件,我可以看到由于某种原因,你还没有在foreach中初始化“ImportPLRequest”变量。您只需将值复制到变量中,而没有正确的初始化逻辑。
在添加进程WSDL后编辑。
查看更新后的BPEL文件中的第一个复制语句。
在将某些值复制到“ImportPLRequest”变量的“ns1:name”元素之前,应初始化“ImportPLRequest”变量。您仅为BPEL流程提供了WSDL,但此变量是由合作伙伴服务的WSDL中的消息创建的。如果您可以为合作伙伴服务提供WSDL,我们可以帮助初始化块。
您可以将[1]作为变量初始化的参考。请参阅第一份复制声明。
1 - https://svn.wso2.org/repos/wso2/carbon/platform/trunk/products/bps/modules/samples/product/src/main/resources/bpel/2.0/CreditRating/CreditRating.bpel
HTH
答案 1 :(得分:1)
您可以在第一个分配活动中分配在顶级范围内定义的名为ImportPLRequest
的变量。但是,您在调用活动中使用变量ImportPLRequest1
。此变量未初始化,因此是错误。作为旁注:这不应该是您的响应变量的问题。
但是,我想知道你为什么得到selectionFailure
。在这种情况下,我认为uninitializedVariable
错误是正确的。也许,这是ODE中的一个错误。