<wsdlsoap:address location="http://localhost:9081/SampleWeb/services/TestInt"/>
<wsdlsoap:address location="http://localhost:9081/SampleWeb/services/TestInt"/>
<wsdlsoap:address location="http://localhost:7800/SampleWeb/services/TestInt"/>
After deploying Web Service successfully, follow these steps to dynamically invoke Web Service with BTT WSDII Invoker:
<kColl id="invoker"> <kColl id="classTable"> <field id="WSDII" value="com.ibm.btt.invoker.ws.dynamic.WSDynamicInvoker" /> </kColl> <field id="initializer" value="com.ibm.btt.invoker.InvokerInitializer"/> <field id="extFile" value="invoker.xml"/> </kColl>
<WSDII id="newWS" wsdlURL="http://localhost:9080/BTTSOAModule2Web/wsdl/NewWSDLFileExport1_NewWSDLFileHttp_Service.wsdl" operation="NewOperation" > <parameters> <wsDIIparameter id="input1" /> <wsDIIparameter id="input2" type="String" /> </parameters> </WSDII>
The following table describes the parameters specified for WSDII Invoker:
Parameter | Description |
---|---|
id | The wsdl definition name, mandatory |
wsdlURL | The wsdl url address, mandatory |
operation | The operation which will be called in WSDL, mandatory |
wsDefinitionFile | wsDefinitionFile can be defined in global default, or in specific invoker. If it is not defined in both locations, the Web service information is extracted dynamically at the first invocation. Optional. |
parameters | wsDIIparameter, The parameter is only useful when mapping BTT Context to/from WSDL messages. The id must match with the operation paramName in wsDefinitionFile. Optional. |
id | The parameter id, mandatory |
type | The id data type, optional |
<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>
<WSDII id="newWS" wsdlURL=http://localhost:9080/BTTSOAModule2web/wsdl/NewWSDLFile.wsdl operation="NewOperation" />
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 the same level.
Following is the design view of the complex data: PurchaseOrderType.xsd:
<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"/> </parameters> </WSDII>
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) ;
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 });