I want to add exception handling in Mule ESB using custom-exception-strategy. However, I have multiple service calls in one flow, and I want to handle exceptions from each service call separately.
Is it possible to have multiple custom-exception strategies in a single flow? Right now, I am able to use only one custom-exception-strategy, and only when I place it at the end of the flow, after the last outbound endpoint. This is the expected behavior. All right. But I want to use multiple exception strategies in a flow.
The Mulesoft documentation says we have to use processor chains if we want to use multiple exception strategies. I am not sure how it will translate into the configuration XML. Any guidance?
For this you need place your different service calls in private flows.
Something like:
<flow name="main">
<inbound-endpoint ref="in" />
<flow-ref name="sub1" />
<flow-ref name="sub2" />
</flow>
<flow name="sub1" processingStrategy="synchronous">
<!-- do something -->
<custom-exception-strategy>
<!-- sub1 specific -->
</custom-exception-strategy>
</flow>
<flow name="sub2" processingStrategy="synchronous">
<!-- do something -->
<custom-exception-strategy>
<!-- sub2 specific -->
</custom-exception-strategy>
</flow>
Related
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.
I have a number of web services each returning a list of user ids as follows:
<application name="abc">
<users>
<id>123</id>
<id>456</id>
<id>789</id>
</users>
</application>
I need to be able to
Call a proxy service with a specific id (for example 123);
Call each webservice and search for the ID;
Create a response for each webservice and finally
Aggregate all responses in one message which is sent to the client as follows:
<response>
<id>123</id>
<application name="abc">
found
</application>
<application name="lmn">
not found
</application>
<application name="xyz">
found
</application>
</response>
Its probably a mix of service chaining and aggregate, but I cannot figure out how to do it. I tried cloning a request and using send at the end with a receiving sequence which transforms the body using the payload factory. In the Out sequence I then used aggregate to combine the new messages. However it times out and I don't think it's a matter of timing. My main issue is how to create a new message from each webservice response the aggregate mediator can combine them.
Any help is appreciated.
Thanks
You need to follow this pattern, https://docs.wso2.com/display/IntegrationPatterns/Scatter-Gather and you are almost there. When you define receive sequence the response will be forwareded to that sequence and you wouldn't get the response message in outSequence. Use aggregator mediator inside the outSequence and Combine the responses rather than defining a receive sequence.
Once you aggregate the responses, you can use xslt mediator to transform the message.
I managed to solve my issue by creating a proxy service for each web servive. Each proxy service calls the actual web services and uses a filter in the out sequence to create a response likes this:
<application name="abc">
found
</application>
Then I created a REST API which takes the idno as a URI template. I then prepare a payload with this idno and clone the request to the proxy services I mentioned above. Then I aggregate the responses and add the idno in the payload.
If anybody has any questions let me know.
Hello!
I'm trying to learn some Apache Camel and Apache CXF and of course I've ran into some problems.
What I'm trying to do:
Send timed SOAP messages from ESB to some web service, wait for the reponse from the web service and process it. I'm using Apache ServiceMix!.
What I've done:
Implemented a WSDL file with two operations PingOutput (what I'm sending) and PingInput (what I want to receive from the WS).
Implemented a CXF Endpoint (http://127.0.0.1:8090/ping_ws is a WS mocked with SoapUI):
<cxf:cxfEndpoint address="http://127.0.0.1:8090/ping_ws"
id="Ping_Mocked_WS" wsdlURL="ping.wsdl">
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD" />
</cxf:properties>
</cxf:cxfEndpoint>
Implemented a Camel route:
<camelContext xmlns="http://camel.apache.org/schema/spring" streamCache="true">
<route id="ping-ws">
<from uri="timer://ping_timer?fixedRate=true&period=10000"/>
<bean ref="PingBean" method="createPingRequest" />
<to uri="cxf:bean:Ping_Mocked_WS"/>
<bean ref="PingBean" method="processPingResponse" />
</route>
</camelContext>
What I do not understand:
Why the <bean ref="PingBean" method="processPingResponse" /> gets the correct response from SoapUI (the PingOutput operation defined in WSDL)?
Is this the correct way to achieve my goal? And by this way I mean with one single route?
The codes work correctly, I might have some typos here, please do not mind them.
Thanks!
Ad 1)
Likely because the type defined in the method signature of the processPingResponse method. Camel uses bean parameter binding, and based on the type, it uses its type converter to convert to the given type.
And as the payload is a SOAP response in XML it can use JAXB to convert from XML to the type from the method signature.
To do so it uses camel-jaxb which ServiceMix comes with out of the box.
Ad2)
The route works. What it is you want to do differently?
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.
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