How Do I Access a Web Service? (Magic xpa 3.x)
Web services are described in a special XML file called a WSDL (Web Service Description Language). The WSDL document describes the service, including the structure of the input and output. In order to access a Web service, you must first find its WSDL entry, which will generally be a URL on the Web. To access a Web service from Magic xpa, you need to define a SOAP entry in the Services section and load the service WSDL. When the WSDL is loaded, a client module (JAR file) is generated and optionally XML schemas are generated as well.
-
Go to Options->Settings->Services.
-
Press F4 (or Edit->Create Line) to open up a line.
-
Give your web service a name. In our example, we used CountryInfo.
-
In the Server column, zoom to select SOAP.
-
Press Alt+Enter to access the Server properties.
-
In the WSDL URL field, enter the URL of the WSDL you are accessing. The Client Module field will fill in automatically.
-
Click the Load button. It will take a few moments for Magic xpa to create the Client Module and XML Schema files.
Also in Service Properties, you can set up attachment encoding type, and the security settings to be used.
Once the Web service is defined, you can access it easily from within Magic xpa.
-
Press F4 (Edit->Create Line) to open up a line.
-
Press I to select the Invoke operation. The cursor will move to the next field.
-
Web service will be selected by default. Tab to the next field.
-
Go to the Properties pane (Alt+Enter).
-
Zoom from the Service field to select the service you want. In our example, that is CountryInfo.
-
Zoom from the Operation field to select which Web Service operation you want to access.
-
Zoom from the Fault field to select a variable (Blob or Alpha) to hold the error code description (if the operation completes successfully the variable will have an empty value).
-
Zoom from the Arguments field to set up the arguments for this Web service. The exact argument list will vary depending on the Web service, but Magic xpa will display a list of what the Web service expects. Often the argument will be a complex type argument represented as XML document, in which case the location of the XML Schema location will be listed.
-
Zoom from the Return value field to specify a variable for the Returned value from the Web service.
That is all there is to it! If the Web service uses complex input or output, you will need to put together the XML Blob for the Arguments and/or Return value.