Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Exposing Web Service (CXF) With Mule ESB

Exposing Web Service (CXF) With Mule ESB

Exposing Web Service (CXF) With Mule ESB

Jitendra Bafna

May 22, 2017
Tweet

More Decks by Jitendra Bafna

Other Decks in Technology

Transcript

  1. What Is CXF? CXF is a Java web services framework

    used for SOAP (Simple Object Access Protocol) messaging. It handles all serialization and deserialization as well as SOAP envelope and namespace processing. The Mule CXF module provides support for web service integration via Apache CXF. Apache CXF is an open source services framework that helps you build and develop services using front-end programming APIs, like JAX-WS.
  2. Building Web Service 1.) Add new package and name is

    myapp.webservice. 2.) Add Interface and name it IHelloWorldService. 3.) Add Class and name it HelloWorldService. This calls should implement the interface IHelloWorldService. Make sure add all the class and interface under the folder src/main/java. Now start defining the method in interface and implement in class that you need to expose.
  3. Building Web Service IHelloWorldService.java HelloWorldService.java package myapp.webservice; import javax.jws.WebMethod; import

    javax.jws.WebService; @WebService public interface IHelloWorldService { @WebMethod String helloWorldFunc(String name); } package myapp.webservice; import javax.jws.WebService; @WebService public class HelloWorldService implements IHelloWorldService { @Override public String helloWorldFunc(String name) { return "Hello World "+name; } }
  4. Exposing Web Service We will start exposing the web service

    using mule flow. 1.) Place the HTTP listener component in mule flow and configure it.
  5. Exposing Web Service 2.) Place the CXF component in message

    processor and configure it. Select the operation JAX- WS service and add service class (name of your interface (i.e. myapp.webservice.IHelloWorldService).
  6. Exposing Web Service 3.) Place the java component and provide

    the class name (i.e. myapp.webservice.HelloWorldService).
  7. Exposing Web Service <?xml version="1.0" encoding="UTF-8"?> <mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns="http://www.mulesoft.org/schema/mule/core"

    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd"> <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/> <cxf:configuration name="CXF_Configuration" enableMuleSoapHeaders="true" initializeStaticBusInstance="true" doc:name="CXF Configuration"/> <flow name="cxf-webserviceFlow"> <http:listener config-ref="HTTP_Listener_Configuration" path="/web" doc:name="HTTP"/> <cxf:jaxws-service configuration-ref="CXF_Configuration" serviceClass="myapp.webservice.IHelloWorldService" doc:name="CXF"/> <component class="myapp.webservice.HelloWorldService" doc:name="Java"/> </flow> </mule>