M-PS Web Services Client 1.0 EN
INTRODUCTION
MAPPING provide its web service with the M-Processing Server tool, in order to access the various methods via some source code.
In this document, you’ll see how to access and manipulate those methods with a web service client. Firstly, some prerequisite have to be done. Then, step by step, we’ll create an example of a web service client in different technology.
WEB SERVICE: WHAT TO DO ?
Access to the web service
To access the web service, go to this link:
http://127.0.0.1:8002/cgi-bin/mapsoapserver.exe?wsdl
It’ll show you the wsdl in XML language (this link will be important later). For more information / readability, just delete the “?wsdl” at this end of the URL. If your server is correctly installed and if already works fine, you’ll see this web page:
Then, for more information about all methods available, go to:
http://127.0.0.1:8002/cgi-bin/mapsoapserver.exe You’ll see:
This page is convenient for knowing about input and output for all methods of this web service. For example, if you click on “Sample GET”, you’ll get an URL. Copy it in your browser and you’ll get the return value of the method chosen, like this: You can test all of methods available like this.
Prerequisite of Eclipse tools
In order to create some examples to call the web service, Eclipse need one tool: axis. You can download axis version 1.4 here: http://www.us.apache.org/dist/axis/axis/java/1.4/ (download “axis-bin-1_4”). After that, unzip it when you want. You’ll need its path for the command who will create all Java class from the WSDL. This command is: java -cp yourPath \axis-1_4\lib\axis.jar; yourPath \axis-1_4\lib\axis-ant.jar; yourPath \axis-1_4\lib\commons-discovery-0.2.jar; yourPath \axis-1_4\lib\commons-logging-1.0.4.jar; yourPath \axis-1_4\lib\jaxrpc.jar; yourPath \axis-1_4\lib\log4j-1.2.8.jar; yourPath \axis-1_4\lib\saaj.jar; yourPath \axis-1_4\lib\wsdl4j-1.5.1.jar org.apache.axis.wsdl.WSDL2Java -U mapadmin -P mapadmin http://127.0.0.1:8002/cgi-bin/mapsoapserver.exe?wsdl The path “yourPath\axis-1_4\” is yours. Change it to get the folder “axis-1_4”. All information are in this command (authentication and URL). We recommend to copy it and paste it in a “.bat” file. Open it in your future Java project folder. When the script will be executed, all Java class will be created in your project. But, some dependencies are requisite to continue.
The project need one last thing to be ready. Go to this link by Apache: https://hc.apache.org/downloads.cgi and download “HttpClient” (choose the binary .zip). Add all .jar file into your project.
Prerequisite of Visual Studio tools
CLIENT IN JAVA
Create a project
All you need is a simple Java project with a Main method.
Access to the web service methods
Among the class of the web service, you can find the class named “MapSoapServerServiceLocator”. It’s the link with the web service. Address information is in here. The class named “MapSoapServerPortBindingStub” is the class who contains all methods implemented. To create an instantiation of MapSoapServerPortBindingStub, we must use an object MapSoapServer, because, the method “getMapSoapServer()” of the class MapSoapServerServiceLocator return this type and we need this method to be connected at the web service. To make it real, a cast of MapSoapServer into MapSoapServerPortBindingStub is mandatory. Then, use the method “setUsername” and “setPassword” of the class MapSoapServerPortBindingStub to authenticate. From now, all methods are available. Go for search some useful methods (the web page with help, see 2.1 Access to the web service, is useful).
Examples
There is one example of type of utility: MapSoapServerServiceLocator serviceLocator = new MapSoapServerServiceLocator(); MapSoapServer locator_temp = serviceLocator.getMapSoapServerPort();
if (locator_temp instanceof MapSoapServerPortBindingStub) {
MapSoapServerPortBindingStub locator = (MapSoapServerPortBindingStub) locator_temp;
locator.setUsername("mapadmin"); locator.setPassword("mapadmin");
Users allUsers = locator.getListUsers(""); for (Usr user : allUsers.getUsrs()) { System.out.println("User name : " + user.getName());} }