I am new to Axis2 Web services, and I tried to implement Axis2 from some simple tutorials. My code runs well in JavaEE with Tomcat server 7.0+, however I still haven't fully understood how client and server connect together. For that reason, I have a several general questions regarding to Axis2:
What is the functions of the Stub.java file that is automatically generated in client side? I don't know how it functions, but it seems to handle the requests of the client side. Here is the code I need to implement to run from the client side:
public static String getData(int code) throws RemoteException, MylittleShopParserConfigurationExceptionException, MylittleShopIOExceptionException, MylittleShopSAXExceptionException {
//When creating client web service, importing http://localhost:8080/Server/services/MylittleShop?wsdl (this is the xml file for
//describing server-web service, it will tell the client how to compose a web service request and the interface that is
// provided by the server ,all of thing contained in MylittleShopStub class.
MylittleShopStub ser = new MylittleShopStub();
GetData setCode = new GetData();
setCode.setCode(code);
GetData1Response getCode = null;
getCode = ser.getData1(setCode);
return getCode.get_return();
}
My service is simply to send a code (id) to the server to retrieve a dataset from the database.
Thank you in advance!
Using the service is simply a matter of creating and populating the appropriate type of request using the names defined in the WSDL file, and then using the stub to actually send the request to the appropriate method.
A WSDL Service understands and responds to XML documents that are submitted to the server. These XML should follow a specific XSD. At first the client encodes all the parameters in XML,and sends them to the server. Then the server parses the XML, it performs the defined operations and returns an XML to the client. The java client parses the XML and returns the result as a java object.
Client and server can communicate over HTTP and HTTPS. Normally since you follow simple tutorials you use HTTP.
About WSDL services WSDL (Web Services Description Language) is an XML language for describing Web services. So by definition WSDL web services are the web services that are describe and conform to the WSDL standard. A web service is in a sense a remote procedure call. A client program asks a server program to do "something" and (in most cases) return a result. WSDL defines an XML format that is used by client and server to communicate in a neutral, programming language independent, format. So basically the client and server programs send back and forth XML documents that describe the customer request and server response.