Web Service Executor Sample
This sample explains how the Web Service Executor can be used in lifecycle configurations to invoke a Web Service in a synchronous manner.
Prerequisites
Download Apache Axis2 and SoapUI.
Steps To Get This Sample To Work
Start the Apache Axis2 server and add the AdderService.aar file which can be downloaded here, into
AXIS2_HOME/repository/services.Go to http://localhost:8080/axis2/services/ and get AdderService from this. You can copy the WSDL location which should look like the following: http://localhost:8080/axis2/services/AdderService?wsdl
.Start SoapUI and create a new project and give the WSDL path that was obtained in step 2.
Send an request to the Web Service using the SoapUI. Add some random values to args0 and args1.
The response can be seen through SoapUI after successful service invocation.Start WSO2 Governance Registry and go to Extensions > Configure > Lifecycles and click on Add New Lifecycle.
Add the following segment under the datamodel tag in Development state and save the Lifecycle.
<data name="transitionExecution"> <execution forEvent="Promote" class="org.wso2.carbon.governance.registry.extensions.executors.WSExecutor"> <parameter name="async" value="false"/> <parameter name="save.type" value="property"/> <parameter name="save.name" value="response"/> <parameter name="response.xpath" value="//ns:return"/> <parameter name="response.namespace" value="http://ws.apache.org/axis2"/> <parameter name="response.namespace.prefix" value="ns"/> <parameter name="epr" value="http://localhost:8080/axis2/services/AdderService.AdderServiceHttpSoap11Endpoint/"/> <parameter name="payload"> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:axis="http://ws.apache.org/axis2"> <soapenv:Header/> <soapenv:Body> <axis:add> <axis:args0>5</axis:args0> <axis:args1>6</axis:args1> </axis:add> </soapenv:Body> </soapenv:Envelope> </parameter> </execution> </data><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:axis="http://ws.apache.org/axis2"> <soapenv:Header/> <soapenv:Body> <axis:add> <axis:args0>5</axis:args0> <axis:args1>6</axis:args1> </axis:add> </soapenv:Body> </soapenv:Envelope>Create a new API and add the “SampleLifeCycle” as the lifecycle.
Do an Promote operation. The response value is saved in the property when the promote operation is successful.