1
votes

I have the WSDL file of the remote web service I need to call from a proxy service in the WSO2 ESB and would like to know if I need to construct the soap:Body's elements manually through XSLT/Enrich or there is a way to generate the soapenv:Body's contains from the WSDL and maybe replace '?' for the values.

For example, if you've used soapUI before you'll know that when you import a WSDL file in a project a soapenv:Envelope gets generated automatically with all the XML elements and question marks for their values. Same goes for the TryIt tool in the WSO2 ESB.

Here is an example of an auto-generated soapenv:Envelope in soapUI after importing WSDL:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:abc="http://abc.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <abc:RegisterCandidate>
         <abc:NameFirst>?</abc:NameFirst>
         <abc:NameMiddle>?</abc:NameMiddle>
         <abc:NameLast>?</abc:NameLast>
         <abc:PhoneHome>?</abc:PhoneHome>
         <abc:EmailAddress>?</abc:EmailAddress>
         <abc:Address1>?</abc:Address1>
         <abc:Address2>?</abc:Address2>
         <abc:City>?</abc:City>
         <abc:State>?</abc:State>
         <abc:ZipCode>?</abc:ZipCode>
         <abc:Country>?</abc:Country>
      </abc:RegisterCandidate>
   </soapenv:Body>
</soapenv:Envelope>

Is this possible in the Proxy Service through any of the mediators available to read a WSDL and generate soapenv:Body with its XML tags (in the code above it would be abc:RegisterCandidate with its children)? I've done it with the use of the XSL templates, but it's manual and not very elegant.

I've found a few articles/blogs online about writing proxy services in the WSO2 ESB that call remote web services and what the developers were doing in there was to insert the XML elements needed in the soapenv:Body with the use of XSL templates to have the correct/full SOAP message that is then sent (send mediator) to the remote web service server.

Thank you.

1

1 Answers

1
votes

There is no way to generate the soap body from the remote service's wsdl as in your requirement. But there is an easier way than using xslt. That is to use the payload factory mediator. You can define the payload and assign values using xpath as shown in the sample.