Following is an example to call a Web service named CombineWS:
<props id="WSDII_Defaults"> <entry key="wsDefinitionFile" value="e:\\temp\\NewDIIvoker_Webservice_defs_All.xml" /> </props> <WSDII id="combineWS" wsdlURL="http://localhost:9080/BTTSOAModule2Web/wsdl/combineHttpService.wsdl" operation="combine" > <parameters> <wsDIIparameter id=">combine>input1" > </parameters> </WSDII>
WSDII Invoker can have the following properties:
Following are three examples of how to call WSDII invoker:
The WSDL content is as follows:
<wsdl:message name="NewOperationRequest"> <wsdl:part name="NewOperationRequest" type="xsd:string"></wsdl:part> <wsdl:part name="NewOperationRequest1" type="xsd:string"></wsdl:part> <wsdl:part name="NewOperationRequest2" type="xsd:integer"></wsdl:part> </wsdl:message> <wsdl:message name="NewOperationResponse"> <wsdl:part name="NewOperationResponse " type="xsd:integer"></wsdl:part> </wsdl:message> <wsdl:portType name="NewWSDLFile"> <wsdl:operation name="NewOperation"> <wsdl:input message="tns:NewOperationRequest"/> <wsdl:output message="tns:NewOperationResponse"/> </wsdl:operation> </wsdl:portType>
The WSDII invoker definition is as follows:
<WSDII id="newWS" wsdlURL=http://localhost:9080/BTTSOAModule2web/wsdl/NewWSDLFile.wsdl operation="NewOperation" />
Following is the code to call the invoker:
InvokerFactory ivf = new InvokerFactory("jar:///com/ibm/btt/invoker/ut/invoker.xml"); Invoker inv2= ivf.createInvoker("newWS"); Object result = inv2.execute(new Object[]{"hello", "test", "123"}); System.out.println("######## testInvoker2 Execute result= "+result);
This example shows how to use BTT invoker utility API to map the data between BTT Context and Web service complex message. The rule of map is the name matching between the BTT data element and message part of WSDL on same level.
Following is the design view of the complex data: PurchaseOrderType.xsd:
Following is BTT context data definition:
<kColl id="Order_Data"> <field id="orderData" /> <field id="comment" /> <kColl id="shipTo"> <field id="city" /> <field id="zip" /> <field id="street" /> </kColl> <kColl id="billTo"> <field id="city" /> <field id="zip" /> <field id="street" /> </kColl> <kColl id="orderItems" > <iColl id="item" size="2"> <kColl> <field id="productName" /> <field id="quantity" /> <field id="USPrice" /> <field id="shipDate" /> <field id="partNum" /> </kColl> </iColl> </kColl> </kColl> <WSDII id="purshOrderJaxBSampleWS" wsdlURL="http://localhost:9083/WebServiceProviderWeb/wsdl/OrderSOAP.wsdl" operation="NewOperation" > <parameters> <wsDIIparameter id="NewOperationRequest" type="GenericDataObject"> </wsDIIparameter> </parameters> </WSDII>
The following code shows how to call the Web service and how to use WSDynamicInvoker API: convertContexDataToGenericDataObject and convertGenericDataObjectToContext to map the data automatically between BTT context and complex data of Web Service.nult:
Context diiTestCtx , diiTestTempCtx ; // init the diiTestCtx context data for WS request inv3=(WSDynamicInvoker) ivf.createInvoker("purshOrderJaxBSampleWS"); WebServiceInfo wsinfo=((WSDynamicInvoker)inv3).getWsInfo(); UserDefineTypeInfo invoker3UserType = wsinfo.getUserDefineTypeByName("PurchaseOrderType"); invoker3ParameterValue = inv3.convertContexDataToGenericDataObject(inv3.getParameters().get("NewOperationRequest") , invoker3UserType, diiTestCtx); Object result = (WSDynamicInvoker) inv3.execute(new Object[]{ invoker3ParameterValue }); if (result instanceof GenericDataObject) inv3.convertGenericDataObjectToContext(inv3.getParameters().get("NewOperationRequest"), invoker3UserType, (GenericDataObject) result, diiTestTempCtx) ;
Following is an example uses the same Web service and invoker definition as in Example 2. The data is filled by application manually using populateDataObject API.
inv3=(WSDynamicInvoker) ivf.createInvoker("purshOrderWS"); WebServiceInfo wsinfo=((WSDynamicInvoker)inv3).getWsInfo(); UserDefineTypeInfo invoker3UserType = wsinfo.getUserDefineTypeByName("PurchaseOrderType"); UserDefineTypeInfo usaddressType = wsInfo.getUserDefineTypeByName("USAddress"); UserDefineTypeInfo itemType = wsInfo.getUserDefineTypeByName("item"); java.math.BigDecimal dec=new java.math.BigDecimal(100085); GenericDataObject shipTo= usaddressType.populateDataObject(new Object[]{"king","Zhong Guan Chun Street","BJ","BJ",dec}); GenericDataObject shipFrom= usaddressType.populateDataObject(new Object[]{"wei", "hai dian, lai zheng","BJ","BJ",dec}); GenericDataObject item1= itemType.populateDataObject(new Object[]{“cell phone”, 10,399,”2007-10-21” }); GenericDataObject[] items= new GenericDataObject[]{item1}; GenericDataObject paramDO= invoker3UserType.populateDataObject (new Object[]{ shipTo, shipFrom, “cell phone order”, items }); Object result = (WSDynamicInvoker) inv3.execute(new Object[]{ paramDO });