mulesoft consuming soap web service - cxf proxy-client module

14
CONSUMING SOAP WEB SERVICE - MULESOFT CXF PROXY-CLIENT MODULE Vince Jason Soliza

Upload: vince-soliza

Post on 08-Jan-2017

414 views

Category:

Software


1 download

TRANSCRIPT

Page 1: MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

CONSUMING SOAP WEB SERVICE

- MULESOFT CXF PROXY-CLIENT MODULE

Vince Jason Soliza

Page 2: MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

MuleSoft CXF Proxy Client ModuleWhen using CXF inside of Mule, there are several different ways to consume web service.

One is the Proxy Client: Unlike jax-ws-client that oblige to use JAXB-Objects, this one could work directly with XML when consuming web services.

Page 3: MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

Create 2 Flows:Main Flow & CXF Client Flow

Page 4: MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

Main Flow Components• HTTP Listener

– Accepts the request

• Transform Message – Create request for web service consumer the output is XML

• Flow Reference– Reference to the Flow of EchoServiceFlow

• Transform Message– Parse the response of EchoServiceFlow to XML

Page 5: MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

CXF Client Components• CXF

– proxy-client configuration

• HTTP request– http request hold the configuration for the target endpoint

Page 6: MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

Request ConfigurationWe used Transform Message to create a SOAP request, cxf:jax-ws-client requires jaxb-object as the acceptable request so we added xml-to-jaxb-object transformer after it.

Page 7: MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

Request ConfigurationCode Snippet:

<dw:transform-message doc:name="Transform Message"><dw:set-payload><![CDATA[%dw 1.0

%output application/xml%namespace echo http://www.whiteskylabs.com/wsdl/echo/---echo#EchoRequest: {

EchoInfo: {Id: "1345",Name: "Mario Luigi",Description: "Mario Bros",OtherInfo: "Legendary"

}}]]></dw:set-payload></dw:transform-message>

Page 8: MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

cxf:proxy-client ConfigurationCXF proxies support working with the SOAP body or the entire SOAP envelope. By default only the SOAP body is sent as payload, but the payload mode can be set via the "payload" attribute to envelope if needed.

Page 9: MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

Cxf:proxy-client ConfigurationWe put cxf:proxy-client into a new private flow, to wrap it as a SOAP web service consumer.

code snippet:

<flow name="EchoServiceProxyFlow"><cxf:proxy-client

doc:name="CXF"soapVersion="1.2" payload="body" />

<http:request config-ref="HTTP_Request_Configuration"path="/echo-ws/ws/EchoService" method="POST"

doc:name="HTTP" /></flow>

Page 10: MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

Response ConfigurationThe cxf:proxy-client response can be parsed directly with Transform Message.

Page 11: MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

Response Configurationcode snippet:<dw:transform-message doc:name="Transform Message">

<dw:set-payload><![CDATA[%dw 1.0%output application/xml%namespace echo http://www.whiteskylabs.com/wsdl/echo/---{

echo#EchoResponse: {EchoResult: {EchoInfo: {Id: payload.echo#EchoResponse.EchoResult.EchoInfo.Id,Name: payload.echo#EchoResponse.EchoResult.EchoInfo.Name,Description: payload.echo#EchoResponse.EchoResult.EchoInfo.Description,OtherInfo: payload.echo#EchoResponse.EchoResult.EchoInfo.OtherInfo}}}

}]]></dw:set-payload></dw:transform-message>

Page 12: MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

Test the application• Run the application in Anypoint Studio.• Send request through HTTP using Postman, browser or any client you

prefer.• We can see in the screenshot below, the response of the soap web service

we consumed using cxf:proxy-client as web service consumer.

Page 13: MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

SummaryThis slide describes how to consume web services using the CXF proxy-client message processor. While it is recommended to use web service consumer in consuming SOAP web service there are several reasons you may want to use proxy-client, such as:• You don’t want to use the WSDL• You want to work with the SOAP envelope• To take advantage of the CXF web service

standards support to use WS-Security or WS-Addressing

Page 14: MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

QUESTIONS?Please leave a comment