Mule ESB -- Introduce a Middleware to Publish and Consume SOAP - web-services

I just have started using Mule 3.8 CE version. My use case is to like this,
Publish SOAP -- Hit any method from Published SOAP -- Receive data -- Pass this Data to consume SOAP -- Fetch Response -- Process response via Java -- Return this as response from Method of Published SOAP.
In short I want to introduce a middleware (not a proxy) from Mule which will publish endpoint (e1) -- receive data from that endpoint (e1) -- pass this data to another endpoint(e2) -- receive data from this another endpoint.(e2) -- return response to original endpoint (e1).
Currently I am using following Mule configuration to achieve this,
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8085" doc:name="HTTP Listener Configuration"/>
<endpoint exchange-pattern="request-response" address="http://192.168.2.3:9080/crestelBEExport/billexport/CrestelBEExportService/CrestelBEExport" name="Generic" doc:name="Generic"/>
<flow name="webserviceproducerFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/hello" doc:name="HTTP"/>
<cxf:jaxws-service serviceClass="com.poc.example.ws.IHelloWorld" doc:name ="CXF" />
<component class="com.poc.example.ws.HelloWorldWSImpl" doc:name="Java"/>
</flow>
In the 'HellowWorldWSImpl" I have Webmethod. I am consuming SOAP and receive data in this webmethod. I am returning this data consumed from SOAP as response to this Webmethod. Is this right approach or is there any better way to achieve my requirement?

With Mule 3.8 enterprise edition, you have a feature, which will help you to specify WSDL in the beginning
This will create similar structure like a RAMLSample WSDL

You can use WS Consumer for calling the WS. No need in writing java code. This will be more "mule" way.

Related

The soap services is working in SOAPUI but its not working in mule soft web services consumer

I have web service wsdl file and its loaded successfully in SOAPUI. This is an request method.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/" xmlns:asi="http://siebel.com/asi/">
</soapenv:Header>
<soapenv:Body>
<asi:VSPOSCSyncRealTimeQueryById>
<PrimaryRowId>1-test</PrimaryRowId>
</asi:VSPOSCSyncRealTimeQueryById>
</soapenv:Body>
</soapenv:Envelope>
This above method is an working fine in SOAPUI. But when I try
to implement in mulesoft using web service consumer then the method is not populating.
This is an screen shot .
The above picture showing that the mule soft web service consumer is populating the only parameter without operation name but SOAPUI is populating both operation and parameter and its working. so any idea why mule soft web services consumer its not populating method name with parameter.
Thanks
Ishwar
I have created a sample as below and it is wokring as expected. I am not sure if you have selected the Operation in Web Service Component. Refer the following, hope this will work for you -
Webservice Consumer Component Operation
DataMapper
<flow name="muletestFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/test" allowedMethods="GET" doc:name="HTTP"/>
<set-variable variableName="first" value="#[message.inboundProperties.'http.query.params'.first]" doc:name="first"/>
<set-variable variableName="second" value="#[message.inboundProperties.'http.query.params'.second]" doc:name="second"/>
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0%output application/xml%namespace ns0 http://tempuri.org/---
{
ns0#Add: {
ns0#intA: flowVars.first as :number
, ns0#intB: flowVars.second as :number
}
}]]></dw:set-payload>
</dw:transform-message>
<ws:consumer config-ref="Web_Service_Consumer" operation="Add" doc:name="Web Service Consumer"/>
</flow>

Filter payload that passes to the transformer in Webservice Proxy pattern in Mule ESB

When using a web service proxy pattern in Mule, you have the ability to pass the message through 1 or more transformers. Is there anyway to avoid passing ?Wsdl gets or other messages filtered on Content-Type for example? My transformer is manipulating the XML payload prior to passing it off to the web service, but I've found my wsdl calls are also being processed by the transformer and failing.
I've put a check in my transformer code, but this doesn't seem like the right way to go about solving this.
if(message.getOriginalPayload().toString().endsWith("wsdl")||!(xmlString.startsWith("<") && xmlString.endsWith(">"))){return message; }
The Proxy config:
<pattern:web-service-proxy name="SR-Proxy"
doc:name="SR-Proxy"
transformer-refs="enrichPayloadWithSFSession"
wsdlFile="service/SR_Webservice.wsdl">
<http:inbound-endpoint exchange-pattern="request-response" host="${hostname}" port="${http.port}" path="service/SRProxy" doc:name="HTTP" />
<https:outbound-endpoint exchange-pattern="request-response" address="${sfdc.wsUrl}SR_Webservice" />
</pattern:web-service-proxy>
Use the http.query.string inbound message property to detect the ?wsdl request.
See http://www.mulesoft.org/documentation/display/current/HTTP+Transport+Reference#HTTPTransportReference-HTTPProperties for more information about the available inbound properties you can find in inbound HTTP messages.

web service endpoint using cxf in jboss fuse

I'm using jboss fuse 6.1-final:
here is my simple route:
<route>
<from uri="cxf:bean:synchronousEndpoint"/>
<log message="Service invoked." />
<process ref="simpleProcessor"/>
</route>
and in the simpleProcessor I'm putting correct response(i.e corresponding JAXB object) to the context. But, it responds with fault:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Marshalling Error: java.lang.Object cannot be cast to org.w3c.dom.Element</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
here is stack trace:
Caused by: java.lang.ClassCastException: java.lang.Object cannot be cast to org.w3c.dom.Element
is there any hints or suggestions?
Bit hard to say without seeing some more code from the simpleProcessor. However it seems like you are using the wrong dataFormat parameter.
The cxf component has a dataFormat parameter which can be any of the following:
POJO: POJOs (Plain old Java objects) are the Java parameters to the
method being invoked on the target server. Both Protocol and Logical
JAX-WS handlers are supported.
PAYLOAD: PAYLOAD is the message payload (the contents of the
soap:body) after message configuration in the CXF endpoint is
applied. Only Protocol JAX-WS handler is supported. Logical JAX-WS
handler is not supported.
MESSAGE: MESSAGE is the raw message that is received from the
transport layer. It is not suppose to touch or change Stream, some of
the CXF interceptors will be removed if you are using this kind of
DataFormat so you can't see any soap headers after the camel-cxf
consumer and JAX-WS handler is not supported.
CXF_MESSAGE: New in Camel 2.8.2, CXF_MESSAGE allows for invoking the
full capabilities of CXF interceptors by converting the message from
the transport layer into a raw SOAP message
The default is POJO which means there is no XML being passed as a message Camel is passing objects. I suspect you might be trying to manipulate the response as XML and this is causing problems.
I ran into something similiar to this a while back where I was trying to convert the POJO into XML by trying to do a XPATH query on the XML when I was receiving a POJO.

how can use wire-tape in mule for statstict wsdl?

i define a web-service in mule i want to get statistics user that use from web-service
how can use wire-tape in my project? what is wire-tape? i have not wire- tap in mule pallet
<flow name="service-cxf-wsdlfirstFlow1" doc:name="service-cxf-wsdlfirstFlow1">
<wire-tap>
<vm:outbound-endpoint path="tapped.channel"/>
<wildcard-filter pattern="the quick brown*"/>
</wire-tap>
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:8882/OrderSvcs" doc:name="HTTP"/>
<cxf:proxy-service payload="envelope" doc:name="SOAP" enableMuleSoapHeaders="false" namespace="http://tempuri.org/" service="XXX_News" wsdlLocation="http://www.XXXXXtab.org/XXXX.asmx?WSDL"/>
</flow>
The wire-tap routing message processor seems like a good candidate for what you want to achieve. From its documentation:
The WireTap message processor allows you to route certain messages to
a different message processor as well as to the next one in the chain.

Exposing WebService on Mule

I wanted expose an WebService on mule and its working.
My concern is that am not sure if this is the right approach to follow in exposing a webservice.
As I wanted to be able to view my Mule HTTP Inbound endpoint wsdl i.e
XXX:8084/HelloService?wsdl
, notice the actual service is running on port 8085.
<flow name="WS_In" doc:name="WS_In">
<http:inbound-endpoint address="http://localhost:8084/HelloService" exchange-pattern="request-response" doc:name="HTTP">
<cxf:proxy-service wsdlLocation="http://localhost:8085/HelloService?WSDL" payload="envelope" namespace="http://example.org/HelloService" service="Hello"/>
</http:inbound-endpoint>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8085" doc:name="HTTP" path="test"/>
</flow>
So you're not exposing a service but just proxying it right?
Why not using the ready made pattern for that? See: http://www.mulesoft.org/documentation/display/current/Web+Service+Proxy+Pattern
Proxying web services is a very common practice used for different reasons like security or auditing. This pattern allows a short and easy configuration of such a proxy.
With this you can
Transform the SOAP envelope (body or header) to add or remove specific entries.
Rewrite remote WSDLs so they appear to bind to services inside a corporate firewall.
Mule has already defined these proxy transformers in various ways:
Ref: https://docs.mulesoft.com/mule-user-guide/v/3.7/web-service-proxy-pattern#wsdl-redirection