This tutorial shows how to create jax-ws webservice in Mule ESB step by step. You need to have some idea on SOAP based webservice otherwise it will be a bit difficult to understand. From jdk 6 onwards we don’t need to put any extra jar for jax-ws based webservices as it comes out of the box. You can also implement jax-ws service using Metro, Axis2, CXF framework and among them Metro implementation has the best support for jax-ws service.

Prerequisites

Mule Studio 3.5.0
Mule 3.4.1
JDK 1.6
Maven 2.x

Step 1. Create Mule Project in Mule Studio from the navigation File -> New -> Mule Project. Make sure that Group Id and Artifact Id are given. Artifact Id is same as Project Name. Click Next.

creating jax-ws webservice in Mule ESB

Step 2. Check “Use default location” or you can change the project location as per your choice. Click Finish.

creating jax-ws webservice in Mule ESB

Step 3. Do right-click on jax-ws-cxf.mflow and rename to jax-ws-publisher.mflow because we are going to create webservice publisher.

creating jax-ws webservice in Mule ESB

Step 4. Do double-click on jax-ws-publisher.mflow and create a flow like below screen-shot
Endpoint: HTTP
Components: SOAP and Java

creating jax-ws webservice in Mule ESB

Step 5. Now click on jax-ws-publisherFlow1 and rename it to jax-ws-publisher. Click Save toolbar.

creating jax-ws webservice in Mule ESB

Step 6. Do double-click on HTTP endpoint and change the below properties
Host: localhost
Port: 8084
Path: jax-ws-publisher

creating jax-ws webservice in Mule ESB

Step 7. Before editing SOAP and Java components create jax-ws service – HelloService.java under src/main/java. This is an Interface java file. Also create an implementation class HelloServiceImpl.java

package in.webtuts.service;

public interface HelloService {
    public String sayHello(String name);
}
package in.webtuts.service;

public class HelloServiceImpl implements HelloService {

    @Override
    public String sayHello(String name) {
        return "Hello " + name;
    }

}

 

Step 8. Do double-click on SOAP component and change the properties

creating jax-ws webservice in Mule ESB

Step 9. Do double-click on the Java component and select the HelloServiceImpl.java for Class Name. Save All.

creating jax-ws webservice in Mule ESB

Step 10. Do right-click on jax-ws-cxf and run as Mule Application

creating jax-ws webservice in Mule ESB

Step 11. You will see the output similar like below at the end if successfully starts up

creating jax-ws webservice in Mule ESB

Step 12. Now hit the URL  http://localhost:8084/jax-ws-publisher?wsdl in the browser. You will see the WSDL output

creating jax-ws webservice in Mule ESB

So we have seen how to create a jax-ws webservice in Mule Project. We will see also consuming jax-ws webservice in Mule Project.

Thanks for your reading. Please do not forget to leave a comment.

Tags:

I am a professional Web developer, Enterprise Application developer, Software Engineer and Blogger. Connect me on Roy Tutorials | TwitterFacebook Google PlusLinkedin | Reddit

Leave a Reply

Your email address will not be published. Required fields are marked *