Consume a Complex Web Service
Introduction
This how-to explains how to consume a (third-party) web service with which you can integrate your Mendix application and reuse functionality and data from other applications. Web services are the preferred way of integrating a Mendix application with external systems. They can be used to retrieve data, send updates, and perform operations. In Studio Pro, calling a web service is done in a microflow using the call web service action.
This how-to teaches you how to do the following:
- Directly import a web service document into your app
- Configure a web service call
Importing a Web Service
You can import a web service document into your app. For more information, see Consumed Web Services.
To import a web service directly, follow these steps:
-
Right-click a module and select Add Other > Consumed web service.
-
Specify a name for the new consumed web service and click OK.
-
In the Consumed Web Service box, specify the WSDL Source to be use this consumed web service. Click Edit, and in the WSDL Source dialog box, specify a URL or load a File from your computer.
-
Click Import to fetch the services and operations in the WSDL. If prompted, in the WSDL Source dialog box, select the ports you want to use and click OK.
-
In the Consumed web service screen, review the Services and Operations available to the imported web service. If you click on any of the operations, information about the operation will be displayed in the right pane. You can select individual web service operations from the list, otherwise the whole service and operation will be imported:
Configuring the Web Service Call
To configure the web service call, follow these steps:
-
If you did not use the web service wizard or did not use the option in the wizard to automatically create a microflow, create a microflow that will call the imported web service:
Make sure the microflow either creates the variables required as arguments for the web service call or has them passed to it. -
If you are creating your own microflow, add the Call web service activity to the microflow. For details on how to add activities to a microflow, see Activities.
-
Double-click the activity to open the Call Web Service properties editor and in the Operation field, click Select.
-
In the Select Web Service Operation dialog box, you can select the operation for this web service call:
-
In the SOAP Request Body tab of the Call Web Service properties editor, you can configure the SOAP body. This contains the parameters needed to execute the web service request. The Simple, Export Mapping, and Custom options enable you to select the type of SOAP body to use. Click Edit value and use one of the following to change the domain-to-XML mapping or the variables from the microflow used as input arguments:
-
Simple expressions for each request parameter — if the imported web service requires only primitive arguments:
-
Export mappings for each request parameter or Export mapping for the entire request — if the domain model entities need to be mapped to XML elements
-
Custom request template — for the definition of a custom XML body with parameters:
-
-
In the HTTP Headers tab, if the Mendix Runtime should use HTTP authentication before calling the web service, check Use HTTP authentication and enter the User name and Password using the Edit buttons:
-
In the SOAP Response tab, you can configure the handling of the return from the web service call as follows:
-
If the return is a complex XML structure, select Mapping and use an XML-to-domain mapping to map the XML elements to the domain model entities:
-
If the return is a primitive, you can store it in a variable by selecting Store in variable — Yes and provide the Type and Variable:
-
If you want to ignore the return, select Ignore
-
Your imported web service is now ready to be used in your application.
Read More
- Consume a Simple Web Service
- Export XML Documents
- Import Excel Documents
- Expose a Web Service
- Use Selenium Support
- Import XML Documents
- Consume a REST Service
- Expose Data to BI tools Using OData