MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module

VinceSoliza 1,538 views 14 slides Mar 15, 2016
Slide 1
Slide 1 of 14
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14

About This Presentation

MuleSoft Consuming Soap Web Service - CXF Proxy-Client Module


Slide Content

Consuming SOAP Web Service - MuleSoft CXF Proxy- Client Module Vince Jason Soliza

MuleSoft CXF Proxy Client Module When 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.

Create 2 Flows: Main Flow & CXF Client Flow

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

CXF Client Components CXF proxy- client configuration HTTP request http request hold the configuration for the target endpoint

Request Configuration We 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.

Request Configuration Code 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 >

cxf:proxy- client Configuration CXF 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 .

Cxf:proxy- client Configuration We 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>

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

Response Configuration c ode 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 >

Test the application Run the application in A nypoint 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 .

Summary This 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: Y ou 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

Questions? Please leave a comment 