If you’ve worked with the Web Service Consumer connector, you’ve probably run into this error message at one point when given a SOAP endpoint.
RPC style WSDLs are not supported by the Web Service Consumer
But don’t worry, there are workarounds to accomplish integrating with these endpoints. In this article, I’ll show you how you can still leverage Anypoint Studio to call this web service; it just requires an additional step. Before diving into this, check out this post. It does a great job covering the different types of WSDLs.
- Anypoint Studio 7.4.2
- Mule EE 4.2.2
- Web Service Consumer 1.5.7
- SOAP UI
Generate SOAP Request
The Web Service Consumer is unable to parse a RPC-style WSDL to extract the operations that are available through the SOAP web service so you need to get or generate the SOAP XML requests outside of Studio. The easiest way to do this is to leverage a tool like SOAP UI. Once you have a copy installed, here is the process to extract the SOAP XML request.
- Open SOAP UI
- Click on New SOAP Project
- Give the project a name (e.g. Weather) and copy and paste the URL for the SOAP WSDL endpoint that you’re trying to call. For this example, I’m going to use the National Weather Service WSDL – https://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php?wsdl
- Click OK
- SOAP UI will extract the operations that are available. Select the one that you plan to call in Anypoint Studio. For this example, I’m using the LatLonListZipCode operation. Copy the request XML and switch over to Anypoint Studio.
Build Flow in Anypoint Studio
- In your project, right click on the src/main/resources folder and click on New > File
- Give the file a name and click on Finish
- Paste the XML request and save the file.
- For this example, I’m going to build a simple flow to pass the SOAP request to an HTTP Request operation. It should look like this.
- Let’s walk through each component. We’ll start with the HTTP Request first.
- In the HTTP Request config, click on the green plus sign.
- Change the protocol to match the SOAP endpoint (e.g. HTTPS). Fill in the Host with the hostname and the Port according to the Protocol. Click on OK.
- In the Request section, change the Method dropdown to POST and fill in the Path field with the remaining path to call the SOAP endpoint
- Click on the Headers tab and add two variables
- Content-Type – “text/xml; charset=utf-8”
- SOAPAction – “https://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl#LatLonListZipCode”
Transform Message (Before HTTP Request)
- In the Transform Message component before the HTTP Request, right click on the Object and click on Set Metadata
- Click on Add
- Enter a name for the Type ID (e.g. rpc) and click on Create type
- Change the Type dropdown to XML, leave XML metadata source as Example and browse and select the XML that we generated in SOAP UI. Once the metadata is generated from the file, click on Select
- Back in the transform message, expand the metadata for the output and double click on zipCodeList. The DataWeave script will be generated with the correct namespaces. Change the null value to a zip code string (e.g. “77401”)
Transform Message (After HTTP Request)
- For the sake of simplicity, I’m just going to output the response from the SOAP endpoint as XML. When you open the Transform Message component, just change the DataWeave script to look like the following.
%dw 2.0 output application/xml --- payload
- Right-click and select Run project <project name>
- Switch to a browser and open the URL that will call the flow. If everything was configured correctly, you’ll see the following response back from the SOAP endpoint.
While the Web Service Consumer doesn’t support RPC style WSDLs, you can still configure a flow to call the endpoint in Mule. There is an extra step of generating the SOAP XML requests using a tool like SOAP UI but you still get the DataSense benefits in DataWeave when you set up the metadata for the output.
For the Transform Message component after the HTTP Request, you can also configure the input metadata if you want to parse and extract data from the response. You’ll just need to grab the expected XML response from SOAP UI.
Hopefully this helps you. If you have any questions, feel free to leave a comment below or email me.