Monday, January 12, 2015

Sending attachements with with WSO2 ESB via MTOM

Prerequisites:

WSO2 ESB 4.8.1
WSO2 ESB 4.8.1 service pack1 (This is yet to release)
SoapUI 4.5.1

Environment:
Ubuntu
Java Runtime

Steps:

Enable backend service

1. Apply the sp1 to ESB 4.8.1
2. Go to /samples/axis2Server/src/MTOMSwASampleService and run 'ant'. Once it is build successfully, go to /samples/axis2Server and start the server as follows:
/axis2server.sh

3.Now you will be able to access the wsdl file of MTOMSwASampleService via below url:
http://localhost:9000/services/MTOMSwASampleService?wsdl

Configure ESB

3.1 Save the wsdl file as MTOMSwASampleService.wsdl and copy it to /repository/samples/resources/proxy directory.

4. Start ESB and login via console.
5. Create three dynamic sequences and save them in config regitry as follows:

Go to Manage->Service Bus->Sequences and click on Add Sequence.
  •  InSeq
Sequence Name: InSeq
Click on Add Child->Core->Send and add a Send mediator.
Select Endpoint Type: Define Inline and click on Add button.
Create Address Endpoint.
Address: http://localhost:9000/services/MTOMSwASampleService

Show Advanced Options->Message Content
Optimize: MTOM
Hit 'Save & Close'.
Hit 'Update'.
Hit 'Save in Registry'.
Hit 'Save & Close'.
  • OutSeq
Sequence Name: OutSeq
Click on Add Child->Core->Send and add a Send mediator.
Hit 'Update'.
Hit 'Save in Registry'.
Hit 'Save & Close'.
  • ErrorSeq
Sequence Name:ErrorSeq
Hit 'Save in Registry'.
Hit 'Save & Close'.

6.  Go to Manage->Service Bus->Source View and paste the config
P.S: Ignore the names as they are dump values
Hit Update.

Setup SoapUI

7. Start SoapUI.
Click on 'New SoapUI project' and paste below wsdl url.
http://localhost:8280/services/StockQuoteProxy?wsdl

8. Click on 'uploadFileUsingMTOM' request in soap11 binding.
10. Edit current url as follows:
http://localhost:8280/services/StockQuoteProxy.StockQuoteProxyHttpSoap12Endpoint

9. Attach a image via attachment window. Click yes for  'cache attachment in request'.
10. Modify the request as depicted in the image below and change the value of image name according to your image name:

11. Now you can send the request. You will receive the attachment as the response as follows:

References:
https://axis.apache.org/axis2/java/core/docs/mtom-guide.html
https://docs.wso2.com/pages/viewpage.action?pageId=33136025

No comments: