Mule School: Web Services – part 1

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 [singlepic id=64 w=580 h=355]
  • Enter a project name as below [singlepic id=73 w=580 h=355]
  • Enter the flow name called service-cxf-wsdlfirst [singlepic id=74 w=580 h=355]
  • Then click Finish to complete the project creation.

Import WSDL into the project

  • Select File→ Import
  • Select General → File System [singlepic id=75 w=580 h=355]
  • Select the File and in the “Into Folder” –  “src/main/resources” and click Finish [singlepic id=76 w=580 h=355]

Configure the HTTP inbound endpoint

  • Drag and drop HTTP Inbound EndPoint [singlepic id=77 w=580 h=355]
  • 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.[singlepic id=78 w=580 h=355]

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

Configure the SOAP component

  • Drag and Drop a soap component [singlepic id=79 w=580 h=355]
  • Double click the SOAP component to configure the SOAP end point, and select Operation = JAX-WS Service [singlepic id=80 w=580 h=355]
  • Generate the WSDL to Java Classes
  • Click Import [singlepic id=65 w=580 h=355]
  • Select the WSDL location from current project and package name for all the JAVA classes. [singlepic id=66 w=580 h=355]

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”.

Could not embed GitHub Gist 3022747: Bad credentials. The API can't be accessed using username/password authentication. Please create a personal access token to access this endpoint:

Create the service implementation class

  • Select package the Select → New Class [singlepic id=68 w=580 h=355]
  • Enter the class name & select “Add” to select the Interface Definition [singlepic id=69 w=580 h=355]
  • Define all the business logic in this class.

Final Mule Flow configuration

  • Drag and Drop a Java Component [singlepic id=70 w=580 h=355]
  • Double-Click the Java Component to configure the implementation class that was created in the above “Service Implementation” section. [singlepic id=71 w=580 h=355]
Could not embed GitHub Gist 3022751: Bad credentials. The API can't be accessed using username/password authentication. Please create a personal access token to access this endpoint:

Test Service

  • Run the Service [singlepic id=72 w=580 h=355]
  • Go to webpage and type – . Ensure you can see the complete WSDL including all operations

We'd love to hear your opinion on this post

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

  1. 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.


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


  3. 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

  4. 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

  5. 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

  6. […] 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. […]

  7. Where do I find the wsdl file from the tutorial?


  8. 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

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

  10. 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?

  11. Good tutorial. It’s so useful.

  12. Thanks,
    Very Helpful