How to use SOAP web service in Mule stream?
I am starting with Mule streams and saw that I saw this page http://www.mulesoft.org/documentation/display/MULE3CONCEPTS/Using+Mule+with+Web+Services and http://www.mulesoft.org/documentation / display / MULEWS / Consuming + SOAP + Web + Services + in + Mule too. They didn't help much. I currently have a simple mule flow like below.
Flow definition
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="CE-3.2.1"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
<flow name="EchoFlow" doc:name="EchoFlow">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8081" path="service/echoflow" doc:name="HTTP" />
<cxf:jaxws-client operation="" serviceClass="com.myapp.demo.ServiceAImplService"
doc:name="SOAP"/>
<outbound-endpoint address="http://localhost:8080/ServiceA/services/" doc:name="Generic"/>
</flow>
</mule>
I am using Mule studio. There is an incoming HTTP point pending a response. I tried to set up a jax-ws client that will call the actual webservice. WSDL for service:
wsdl file
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions name="ServiceAImplService" targetNamespace="http://service.demo.myapp.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.demo.myapp.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.demo.myapp.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<import namespace="http://service.demo.myapp.com/" schemaLocation="http://localhost:8080/ServiceA/services/ServiceAImplPort?xsd=serviceaimpl_schema1.xsd"/>
</schema>
</wsdl:types>
<wsdl:message name="helloResponse">
<wsdl:part element="tns:helloResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="hello">
<wsdl:part element="tns:hello" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="IServiceA">
<wsdl:operation name="hello">
<wsdl:input message="tns:hello" name="hello">
</wsdl:input>
<wsdl:output message="tns:helloResponse" name="helloResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ServiceAImplServiceSoapBinding" type="tns:IServiceA">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="hello">
<soap:operation soapAction="urn:Hello" style="document"/>
<wsdl:input name="hello">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="helloResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ServiceAImplService">
<wsdl:port binding="tns:ServiceAImplServiceSoapBinding" name="ServiceAImplPort">
<soap:address location="http://localhost:8080/ServiceA/services/ServiceAImplPort"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I am not too sure about the jax-ws client setup as you can see. So how exactly am I using the SOAP web service in this thread.
My second question is how to convert the payload to make a call from one web service to another web service (both SOAP). What will the flow be?
Finally, how do I merge the payload? Let's say I have three web services that are called in parallel and their responses are returned together. How can I combine the payload so that I can read it in another service (after combining responses from multiple services being called in parallel)?
What is the equivalent implementation
<pattern:web-service-proxy name="ex-proxy"
inboundAddress="http://localhost:8081/xxx"
outboundAddress="http://xx.xx.com/XXX_WS/xxxWService.asmx" />
using a CXF proxy service / client? Which brings me to another question, when to use a CXF service and when to use a CXF client? And finally, is there any detailed documentation or example / tutorial for Mule Flow Orchestration?
source to share
Try using a CXF proxy (service and client). In this case, you will get the raw XML stream to stream. You can of course deserialize it in java if you need to, for example via an XML-To-Object (XStream) transformer.
http://www.mulesoft.org/documentation/display/MULE3USER/Proxying+Web+Services+with+CXF
From there, there are several ways to do the payload conversion in the middle. Either go through java (as mentioned above) and transform Java level objects or write an XSLT sheet that does the transformation. Convert XML using Java and / or other Mule tools (scripting, xpath, etc.).
You may need to explain the aggregation case in more detail. Do you want to combine responses for future use, or have one web service call -> disconnect -> aggregate -> response?
source to share
If you have access to the web service endpoint interface, you can easily use the web service in a simple Java bean, for example:
public class CityServiceComponent {
public String process(String input) {
// list of cities
StringBuilder output = new StringBuilder();
// create service factory
JaxWsProxyFactoryBean serviceFactory = new JaxWsProxyFactoryBean();
// set service endpoint interface
serviceFactory.setServiceClass(CityService.class);
// set wsdl location
serviceFactory.setAddress("http://localhost:8080/city-service-provider/CityService?wsdl");
// init city service
CityService cityService = (CityService) serviceFactory.create();
// call city service and get all available cities
List<City> cities = cityService.findAll();
// build list of cities
for (City city : cities) {
output.append(city.toString());
output.append("\n");
}
// forward output message
return output.toString();
}
}
Hope it helps ...
source to share