What Happens When You Map WSDL Message Parts

Manipulating XML Data in a BPEL Process 6-41 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-- plnk:partnerLinkType name=Test plnk:role name=TestProvider plnk:portType name=client:Test plnk:role plnk:partnerLinkType wsdl:definitions Example 6–76 shows a .bpel file with toPart elements defined in invoke and reply activities. This maps to the operation defined in the WSDL file shown in Example 6–77 . The copy operation in the invoke activity copies data from the variable indicated in the fromVariable attribute into the part of the anonymous, temporary WSDL variable, request. The copy operation in the reply activity copies data from the variable indicated in the fromVariable attribute into the part of the anonymous, temporary WSDL variable, output. Example 6–76 BPEL File with ToParts Elements sequence -- receive input from requestor -- receive name=receiveInput partnerLink=client portType=tns:Test operation=process variable=input createInstance=yes assign copy frominput.payloadfrom torequestto copy assign invoke name=invokeDummyService partnerLink=DummyService portType=tns:DummyPortType operation=process outputVariable=response toParts toPart part=payload fromVariable=request toParts invoke assign copy fromresponsefrom tooutputto copy assign -- respond output to requestor -- reply name=replyOutput partnerLink=client portType=tns:Test operation=process toParts toPart part=payload fromVariable=output toParts reply sequence Example 6–77 WSDL File that Defines the Operation ?xml version=1.0? definitions name=ch10.3toParts targetNamespace=http:samples.otn.combpel2.0ch10.3 xmlns:tns=http:samples.otn.combpel2.0ch10.3 xmlns:plnk=http:docs.oasis-open.orgwsbpel2.0plnktype xmlns=http:schemas.xmlsoap.orgwsdl 6-42 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite types schema attributeFormDefault=qualified elementFormDefault=qualified targetNamespace=http:samples.otn.combpel2.0ch10.3 xmlns=http:www.w3.org2001XMLSchema element name=input type=string element name=output type=string schema types message name=TestRequestMessage part name=payload element=tns:input message message name=TestResultMessage part name=payload element=tns:output message portType name=Test operation name=process input message=tns:TestRequestMessage output message=tns:TestResultMessage operation portType plnk:partnerLinkType name=Test plnk:role name=TestProvider portType=tns:Test plnk:partnerLinkType definitions Example 6–78 shows a .bpel file with fromParts elements defined in pick and invoke activities. This maps to the operation defined in the WSDL file shown in Example 6–79 . The copy operation in the pick activity retrieves data from the variable indicated in the toVariable attribute into the part of the anonymous, temporary WSDL variable, request. The copy operation in the invoke activities retrieves data from the variable indicated in the toVariable attribute into the part of the anonymous, temporary WSDL variable, response. Example 6–78 BPEL File with FromParts Elements sequence -- receive input from requestor -- pick createInstance=yes onMessage partnerLink=client portType=tns:Test operation=process fromParts fromPart part=payload toVariable=request fromParts empty onMessage pick invoke name=invokeDummyService partnerLink=DummyService portType=tns:DummyPortType operation=process inputVariable=request fromParts fromPart part=payload toVariable=response fromParts invoke assign copy fromconcatresponse, , responsefrom torequestto Manipulating XML Data in a BPEL Process 6-43 copy assign invoke name=invokeDummyService partnerLink=DummyService portType=tns:DummyPortType operation=process2 inputVariable=request fromParts fromPart part=payload toVariable=response fromParts invoke assign copy fromresponsefrom tooutput.payloadto copy assign -- respond output to requestor -- reply name=replyOutput partnerLink=client portType=tns:Test operation=process variable=output sequence Example 6–79 WSDL File that Defines the Operation ?xml version=1.0? definitions name=BPEL20TestCh10.4 targetNamespace=http:samples.otn.combpel2.0ch10.4 xmlns:tns=http:samples.otn.combpel2.0ch10.4 xmlns:plnk=http:docs.oasis-open.orgwsbpel2.0plnktype xmlns=http:schemas.xmlsoap.orgwsdl types schema attributeFormDefault=qualified elementFormDefault=qualified targetNamespace=http:samples.otn.combpel2.0ch10.4 xmlns=http:www.w3.org2001XMLSchema element name=input type=string element name=output type=string schema types message name=TestRequestMessage part name=payload element=tns:input message message name=TestResultMessage part name=payload element=tns:output message portType name=Test operation name=process input message=tns:TestRequestMessage output message=tns:TestResultMessage operation portType plnk:partnerLinkType name=Test plnk:role name=TestProvider portType=tns:Test plnk:partnerLinkType definitions 6-44 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite

6.18 Importing Process Definitions in BPEL 2.0

You can use the import element to specify the definitions on which your BPEL process is dependent. When you create a version 2.0 BPEL process, an import element is added to the .bpel file, as shown in Example 6–80 . Example 6–80 Import Element process name=Loan Flow . . . . . . import namespace=http:xmlns.oracle.comSOAApplicationSOAProjectLoanFlow location=LoanFlow.wsdl importType=http:schemas.xmlsoap.orgwsdl You can also use the import element to import a schema without a namespace, as shown in Example 6–81 . Example 6–81 Schema Import Without Namespace process name=Loan Flow . . . . . . import location=xsdNoNamespaceSchema.xsd importType=http:www.w3.org2001XMLSchema You can also use the import element to import a schema with a namespace, as shown in Example 6–82 . Example 6–82 Schema Import With Namespace process name=Loan Flow . . . . . . import namespace=http:www.example.org location=xsdTestSchema.xsd importType=http:www.w3.org2001XMLSchema The import element is provided to declare a dependency on external XML schema or WSDL definitions. Any number of import elements can appear as children of the process element. Each import element can contain the following attributes. ■ namespace: Identifies an absolute URI that specifies the imported definitions. This is an optional attribute. If a namespace is specified, then the imported definitions must be in that namespace. If a namespace is not specified, this indicates that external definitions are in use that are not namespace-qualified. The imported definitions must not contain a targetNamespace specification. ■ location: Identifies a URI that specifies the location of a document containing important definitions. This is an optional attribute. This can be a relative URI. If no location attribute is specified, the process uses external definitions. However, there is no statement provided indicating where to locate these definitions. ■ importType: Identifies the document type to import. This must be an absolute URI that specifies the encoding language used in the document. This is a required attribute. – If importing XML schema 1.0 documents, this attribute’s value must be set to http:www.w3.org2001XMLSchema. – If importing WSDL 1.1 documents, the value must be set to http:schemas.xmlsoap.orgwsdl. You can also specify other values for this attribute. Manipulating XML Data in a BPEL Process 6-45 For more information, see section 5.4 of the Web Services Business Process Execution Language Specification Version 2.0.

6.19 Manipulating XML Data Sequences That Resemble Arrays

Data sequences are one of the most basic data models used in XML. However, manipulating them can be nontrivial. One of the most common data sequence patterns used in BPEL process service components are arrays. Based on the XML schema, the way you can identify a data sequence definition is by its attribute maxOccurs being set to a value greater than one or marked as unbounded. See the XML Schema Specification at http:www.w3.orgTR for more information. The examples in this section illustrate several basic ways of manipulating data sequences in BPEL. However, there are other associated requirements, such as performing looping or dynamic referencing of endpoints. The following sections describe a particular requirement for data sequence manipulation.

6.19.1 How to Statically Index into an XML Data Sequence That Uses Arrays

The following two examples illustrate how to use XPath functionality to select a data sequence element when the index of the element you want is known at design time. In these cases, it is the first element. In Example 6–83 , addresses[1] selects the first element of the addresses data sequence: Example 6–83 Data Sequence Element Selection assign -- get the first address and assign to variable address -- copy from variable=input part=payload query=tns:invalidLoanApplicationautoloan:application autoloan:customerautoloan:addresses[1] to variable=address copy assign In this query, addresses[1] is equivalent to addresses[position=1], where position is one of the core XPath functions see sections 2.4 and 4.1 of the XML Path Language XPath Specification. The query in Example 6–84 calls the position function explicitly to select the first element of the addresses data sequence. It then selects that address’s street element which the activity assigns to the variable street1. Example 6–84 position Function Use assign -- get the first addresss street and assign to street1 -- copy from variable=input part=payload query=tns:invalidLoanApplicationautoloan:application autoloan:customerautoloan:addresses[position=1] autoloan:street to variable=street1 copy assign 6-46 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite If you review the definition of the input variable and its payload part in the WSDL file, you go several levels down before coming to the definition of the addresses field. There you see the maxOccurs=unbounded attribute. The two XPath indexing methods are functionally identical; you can use whichever method you prefer.

6.19.2 How to Use SOAP-Encoded Arrays

Oracle SOA Suite provides support for SOAP RPC-encoded arrays. This support enables Oracle BPEL Process Manager to operate as a client calling a SOAP web service RPC-encoded that uses a SOAP 1.1 array. Example 6–85 provides an example of a SOAP array payload named myFavoriteNumbers. Example 6–85 SOAP Array Payload myFavoriteNumbers SOAP-ENC:arrayType=xsd:int2 number3number number4number myFavoriteNumbers In addition, ensure that the schema element attributes attributeFormDefault and elementFormDefault are set to unqualified in your schema. Example 6–86 provides details: Example 6–86 Schema Element Attributes attributeFormDefault=unqualified elementFormDefault=unqualified targetNamespace=java:services xmlns:s0=http:schemas.xmlsoap.orgwsdl xmlns:xs=http:www.w3.org2001XMLSchema The following features are not supported: ■ A service published by BPEL that uses a SOAP array ■ Partially-transmitted arrays ■ Sparse arrays ■ Multidimensional arrays To use a SOAP-encoded array: Example 6–87 shows how to prepare SOAP arrays with the bpelx:append tag in a BPEL project. 1. Create a BPEL process in Oracle JDeveloper. 2. Prepare the payload for the invocation. Note that bpelx:append in Example 6–87 is used to add items into the SOAP array. Example 6–87 SOAP Array bpws:assign bpws:copy bpws:from variable=input part=payload query=tns:value bpws:to variable=request part=strArray query=strArrayJavaLangstring bpws:copy bpws:assign bpws:assign bpelx:append