I’m going to provide an overview on how to build a simple contract-first web-service and JAX-WS client that consumes the web-service with Mule Studio.

The sample below is going to build the following:

  • Build SOAP/ HTTP web service using Mule & that is CRUD web service to create, retrieve, update and delete an order and returns the order id. This exercise implements only the create operation for this service.
  • Build the Order Receiver Service
  • Receives the order information from HTTP Inbound Endpoint.
  • Invokes CRUDOrder web service to create the order
  • Returns the order id to Portal

Building the CXF web-service

Following are steps needed to build a CXF based web-service using Mule

  • Create a Mule project
  • Import WSDL into the project
  • Configure the HTTP inbound endpoint
  • Configure the SOAP component.
  • Create the service implementation.
  • Final Service configuration.
  • Test the Service

Create a Mule Project

  • Click File → New → Mule Project cxf1
  • Enter a project name as below cxf2
  • Enter the flow name called service-cxf-wsdlfirst cxf3
  • Then click Finish to complete the project creation.

Import WSDL into the project

  • Select File→ Import
  • Select General → File System cxf4
  • Select the File and in the “Into Folder” -  “src/main/resources” and click Finish cxf5

Configure the HTTP inbound endpoint

  • Drag and drop HTTP Inbound EndPoint cxf6
  • Double-click the HTTP endpoint and configure the HTTP address of the service
  • Click Advanced TAB to configure the address to the required WSDL end point. If the address field is configured then remove the http host, port & application field. cxf7

<http:inbound-endpoint exchange-pattern=”request-response” address=”http://localhost:8882/OrderSvcs” doc:name=”HTTP”/>

Configure the SOAP component

  • Drag and Drop a soap component cxf8
  • Double click the SOAP component to configure the SOAP end point, and select Operation = JAX-WS Service cxf9
  • Generate the WSDL to Java Classes
  • Click Import cxf10
  • Select the WSDL location from current project and package name for all the JAVA classes. cxf11

Tips: Ensure the WSDL name is full path including the WSDL extension

  • Mule Studio automatically generates all the java classes once you import the WSDL.

After the classes are generated, ensure the Service  Class Name field would point to actual Service Interface Definition not the Implementation Class and click “OK”.

Create the service implementation class

  • Select package the Select → New Class cxf13
  • Enter the class name & select “Add” to select the Interface Definition cxf14
  • Define all the business logic in this class.

Final Mule Flow configuration

  • Drag and Drop a Java Component cxf15
  • Double-Click the Java Component to configure the implementation class that was created in the above “Service Implementation” section. cxf16

Test Service

No related posts.


10 Responses to “Mule School: Web Services – part 1”

Way June 17th, 2012, 3:18 am

Nice tutorial, thx!

Do you have any idea when you will have the “ws consumer part” ready?

I’m really looking forward to it, since I’m currently looking for best practices regarding ws and mule.

Cheers

mani June 20th, 2012, 12:46 am

I am new to Mule ESB,Can u plz provide the source code of this sample,that should be approciated.

Thanks
Mani

Themba June 26th, 2012, 2:47 am

This is a useful piece of work, congrats. i cant see operations of my wsdl when testing. what can be the possible mistake i’m making. Thanks in advance

Maria July 11th, 2012, 1:08 am

Hi…..
Thank you for this nice article , I am new in Mule studio and didi it , but i can not see complete WSDL including all operation ? why ? what is problem? and when Part 2 is coming?

Thanks in advance

Mohammed Mustafa August 13th, 2012, 8:03 am

Hi
Thanks for the useful information, I will be great if you can provide the complete source code (.zip) for download.
I want to try this tutorial but I don’t have the WSDL file although I am using Mule3.3

SOA School: Service Orchestration November 19th, 2012, 12:12 am

[...] If you choose Java (the JAX-WS service and client configurations), then you will need JAX-WS annotated classes on your classpath which will represent the service interface, the messages passed to and from each operation and (optionally) a service implementation. This last point is worth noting. You are not obliged to provide a Java implementation if you go down the JAX-WS route. Your flow can just as well act as the implementation of your exposed web-service. All the required Java classes can be generated by Studio by simply importing a WSDL file. [...]

Mike February 13th, 2013, 2:26 am

Where do I find the wsdl file from the tutorial?

//Mike

donghyun.youn@echostar.com September 11th, 2013, 1:33 pm

I can not genereate java classes from WSDl as you did on the tutorial.
so I used wsimport to generate java classes but I only got .classes files.

is it correct? if so how and where should I import them into?

Thank you

Sphe October 17th, 2013, 12:27 pm

where can I find the oderservice.wsdl file used here?

remya October 23rd, 2013, 7:56 am

I tried the steps in this tutorial, when it was time to import the wsdl, i dont see that option at all.

Instead when i double click on the SOAP component, i get the Generate from WSDL button. Any idea?

Leave a Comment