Example of using Mule ESB to route web service calls - java

I'm looking for an example of how to set up a very simple Mule configuration to route a SOAP web service call from a client to a service provider. Initially, there will just be one provider, and then I will want to add multiple service providers and a round-robin routing strategy in Mule.
Most of the examples on the Mule site have the service provider running within the Mule container. I want mine to be completely external.

If you don't need to decompose message arguments use HTTP pass-through, which is more light-weight and a lot simpler. For the round-robin implementation you could use a filter router with a groovy-based filter expression.
See here:
Create pass through with Mule ESB 2.2.1
http://www.mulesoft.org/documentation/display/MULE2USER/Outbound+Routers#OutboundRouters-Filters

Related

Invoking a mule non-webservice flow from Activiti

I have a JMS mule flow, which will read messages from a queue and process them. I would like to invoke this flow from a process in Activiti. I am using a remote mule instance. From what I understand, to invoke a mule flow in a remote mule instance, I have to use web service. How can I use web service in this case?
I am using the community edition of mule.
Thanks
Assuming you know the Web Service URL for your remote Mule instance, you would need to do one of two things:
Create a serviceDelegate class that calls the Web Service endpoint and call this from Activiti
Use the Camel module with Activiti to handle the call to Mule
Personally I am a fan of using Camel for this sort of thing since the hard work has already been done for you and it is a relatively simple matter to create a camel route and call it from an Activiti service task (there are even BPMN extension attributes built into the latest versions of Activiti that make this even easier).
Other things to consider.
Is this a fire and forget (i.e. one way) call or are you expecting a response? If you are expecting a response, will it be synchronous or asynchronous? All these factors will impact how you model the BPMN flow to properly integrate the Mule flow.

how to use Servicemix to make SOAP Web Services comunicate

I want to build a system made by several WebServices that exchange SOAP messages through Servicemix. These WSs are not local, but they are remote. So my idea is providing Servicemix as a service itself, and all the others will send message to it. It will be Servicemix to deliver soap messages to the right Service, log and notify the success/fail of the delivery.
Is this doable? Is this a correct use of Servicemix? I can't find a good example or tutorial with this configuration.
I can build WSs easily starting from a wsdl, using the Maven archetype
servicemix-cxf-wsdl-first-osgi-bundle
and they can be deployed on Servicemix... but they will be all local! I want to make remote WSs exchanging messages through a shared bus.
Thank you
Sure, this is essentially the pattern for ServiceMix. Much of what you are looking for in terms of mediation and routing is realized through Apache Camel. You would need to host the remote web services in a separate web container, such as Tomcat or Jetty. Next, you would implement service endpoints as OSGi bundles that are deployed to ServiceMix. These OSGi bundles expose your service interface. When a SOAP request comes in to the OSGi bundle endpoint, you can then use Camel routing rules to route the SOAP message to the appropriate remote web service endpoint.
For some examples of this, I recommend checking out the JBoss Fuse documentation:
http://www.jboss.org/products/fuse/resources/
Fusesource used to be a support organization around ServiceMix; however, they have since been acquired by RedHat. You will find much better documentation and examples over the ServiceMix documentation itself.
Use Apache Camel for the routing, transforming etc.:
Camel is smart routing and mediation engine which implements the Enterprise Integration Patterns and is designed to be used either inside an ESB like ServiceMix, in a Message Broker like ActiveMQ or in a smart endpoint or web services framework like CXF. ServiceMix is an ESB, a JBI container and an integration platform. So they both address different needs though they are both designed to work great together.

camel mediate service via jms and rest

In my company we are starting to use web services. My plan is to provide access to services via 2 protocols, http and jms. Any external access (clients outside company network) to services will be typically via http and json through a restful URL, but internally if the service needs to invoke another service, it will do it via jms, mainly to decouple the service from each other.
My question is following
Can camel provide abstraction so that i can write my service code without http, json and jms dependencies? I would like camel to handle http to java, json to java and jms to java conversion through some mediation and invocation of my service should be simply through a java method with accepts a java object as a request. Keep in mind that although http is synchronous model, jms would have to simulate request-response. If yes, can you please point me towards an example which demonstrates this setting.
Likewisely, i would like camel to convert the response from my service, which would be a java object, into json and return the response back to the client.
Lastly, how can i scale in this model. For JMS, it is easy to startup multiple instances and have them listen to a queue. How can i leverage same instances to loadbalance across http interfaces? I would like services to have location transparency, hence, they should not have to care about invoking "jms" specific cluster vs "http" specific cluster?
I think you can achieve all of this with Camel.
Marshalling between different object representations is handled through data formats. You can call POJOs from within Camel routes that can encapsulate your services.
See data formats.
Camel comes with clustering and load-balancing support. But if you only have HTTP type endpoints to load balance, then my personal opinion is that you should use a more http-centric approach, like using httpd as a reverse proxy/load balancer.

Feedback/Patterns on creating a protocol adaptor

I have a backend system that currently returns a domain object. I want to build a REST & SOAP front end using mule. To create responses that are REST or SOAP based, and ensure that the backend is protocol agnostic, I am thinking about creating two protocol adapters (REST and SOAP). It is unclear to me if it is better to create a mule translator for the service, which understands the protocol and delegates to generate an appropriate response, or just create two class interfaces (using JAX-RS/JAX-WS annotations) to the service.
I'm not finding much literature, best practices, or design patterns on the subject. Can someone point me to some useful material or provide their opinions?
Writing transformers for message formatting would be a waste of time.
You should write service classes with JAX-RS/JAX-WS annotations, transports exist for both.
For a REST service you can use the Jersey transport:
http://www.mulesoft.org/documentation/display/JERSEY/User's+Guide
For SOAP service you can use the CXF transport (also supports JAX-RS):
http://www.mulesoft.org/documentation/display/CXF/Building+a+web+service
Note: You don't need mule for this at all, both Jersey and CXF run in a servlet container like tomcat.

Is there a better way of manipulating SOAP messages than Jaxws SOAP Handler Interceptor before the message gets to the container?

I am currently using the jaxws and apache CXF framework to create webservices using the top down approach.
I am using the SOAP interceptors to add remove SOAP header elements, using SAAJ, before the message gets to the container, and the container maps the SOAP action too the java method. I am doing this to create Security Token Services (STS) to facilitate a lite implementation of the SAML2 Profile - converting authentication details into portable identities (SAML Authentication Assertions).
I cannot help think there must be an easier way to do this. Is there a framework that will allow me to manipulate the message with more ease? and if so a tutorial would help.
Many thanks
To change things in SOAP messages you must use SOAP Handlers.
Maybe easier way to do it is changing the way you are securing your web service, if you use a WS-Security way of doing things, our container will work with it fine, and you don't need the handlers anymore.

Categories

Resources