How to Create an MTOM Web Service Component

Previous Next

1.From the menu bar, select Define, RDMI, Web Service Components.
Supply a name for your web service.
2.Create a constructor method with the following Physical Method:

this=new com.usoft.WebServiceClient.WSClient()

this.setEndpointURL((U):0)

this.setInputFolder((U):1)

this.setOutputFolder((U):2)

 

The constructor method must have the same name as the component.
3.Add the following parameters to this method:

Seqno

Name

Mode

DataType

0

url

In

String

1

input_folder

In

String

2

output_folder

In

String

where:

url represents the access point of the web service (SOAP address location in the WSDL file).

input_folder represents the folder where the input files are located.

output_folder represents the path to the location where the binary data received from the web service will be saved as files. The output folder can be omitted if the files are saved in the current directory. To omit the output folder, remove this.setOutputFolder((U):2) from the physical path

this.setEndpointURL((U):0)

this.setInputFolder((U):1)

 

and remove the output_folder input parameter.
4.On the Constructor tab, select the Active checkbox and specify using a select statement in the constructor SQL the values for the constructor parameters. Check the constructor SQL.
Example of constructor SQL:

SELECT 'http://www.test.com/TestingMtom', 'C:/Input/', 'C:/Output'

5.Create another method that will send the MTOM message, with the following physical method:

this.sendSOAPMessage((U) :0, (U) :1, (U) :2)

6.Add the following parameters to this method:

Seqno

Name

Mode

DataType

0

body

In

String

1

header

In

String

2

SoapAction

In

String

3

result

Return

String

where:

body represents the body of your SOAP message. The element that contains binary data must have as a subelement a USoft processing instruction that will specify that that element contains binary data in MTOM format:

<?usoft-mtom path="path to the file that will be sent as binary with the message"?>.

If there is a input_folder specified in constructor than the path can be only the file name, otherwize the path should be the absolute path of the file.

Example:

<MTOMM-essage xmlns="http://www.test.com/TestMtom/v1">

      <request>

       <BinaryData><?usoft-mtom path="TestMTOM.doc"?></BinaryData>

     </request>

 

header represents the header of the soap message

SoapAction represents the SOAPAction HTTP header.

You can now execute a call to this service in your application:

INVOKE <web service component name>.<method name>

WITH

SELECT

'<MTOMMessage xmlns="http://www.test.com/TestMtom/v1">

       <request>

       <BinaryData><?usoft-mtom path="TestMTOM.doc"?></BinaryData>

       </request>

</ MTOMMessage >',

null,

'http://www.test.com/TestMtom/action1'

 

If the response has binary data in MTOM encoding, that data will be saved into files. The files are saved in the location specified by the output folder in the constructor method. The (unique) file names are generated by USoft without extensions and they will be returned in a USoft processing instruction in the element where the binary data should be.

Example of response:

<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >

<soap:Body>

<MTOMResponse xmlns="http://www.test.com/TestMtom/v1">

<result>

<BinaryData>

<?usoft-mtom  path="C:\Output\2d33366539343139613a31313161333034366335373a2d37666666_20070330152414114"?>

</BinaryData>

</result>

</ MTOMResponse>

</soap:Body>

</soap:Envelope>