Tutorials to .com

Tutorials to .com » Jsp » Xml » Axis 1.1 for Java for Web Services Development

Axis 1.1 for Java for Web Services Development

Print View , by: iSee ,Total views: 8 ,Word Count: 1984 ,Date: Mon, 20 Apr 2009 Time: 5:09 AM


Using Axis 1.1 for java for Web Services development almost from all the following documents Axis1.1. But not exclusively from the documents, I do some changes, which the reader entirely from domestic needs.

What is SOAP?

SOAP is an XML-based applications for communications between the encoded data transfer protocol. Initially proposed by Microsoft and Userland Software, with the refined and improved continuously, SOAP soon widely used by industry, the current 1.1 version is fully released. In the course of its development, W3C xml Working Group to actively contribute to the standard SOAP into a true open standards. At the time of writing this document, SOAP1.2 draft has been released, 1.2 pairs of 1.1 part of the relative chaos have made improvements.

SOAP has been widely as a new generation of cross-platform, cross-language distributed computing an important part of Web Services.

Here is too shallow, please refer to finishing my "step-by-step learning SOAP".

What is Axis?

Axis is essentially a SOAP engine, to create server-side, SOAP client and gateway operation of the basic framework. Axis current version of java is prepared for, but for c + + version is under development.

But not entirely Axis is a SOAP engine, it also includes:

SOAP is an independent server.

Is an embedded servlet engine (eg Tomcat) servers.

Support for WSDL.

WSDL provides conversion tools for Java.

Provide examples of procedures.

Providing TCP / IP packet monitor tools.

Axis is the third generation of Apache SOAP, since 2000, SOAP v2 began discussing how the development team to allow Axis more flexible, configurable, and capable of dealing with SOAP and xml from a variety of W3C standards. Through constant discussion and coding, Axis present the results obtained are as follows:

Speed. Axis through SAX event-based processing of xml documents, which in terms of speed and efficiency has increased more than Apache SOAP.

Improve flexibility.

Improve stability.

To provide for the deployment of components.

Transmission to provide a simple abstract framework. The core engine to the transmission totally independent. What kind of agreement so that the transmission based on a more flexible choice.

Support for WSDL. Including everywhere generate WSDL and client, such as agents.

Issue in the current 1.1 version of anything?

SOAP1.1/1.2 engine.

Flexible system configuration and deployment.

Automatic generation of SOAP support in time of service (JWS).

Support all the basic data types, the definition of serial operation since the type of mapping system to provide.

JavaBean automatic serial operation, including the custom attribute type is mapped to the XML attributes and elements.

RPC and SOAP-based information service providers.

Good service from the deployment of automatic generation of WSDL.

WSDL2Java tool description from the WSDL document to produce the client and server side SOAP framework.

The initial expansion to provide a safe, secure integration with Servlet2.2.

Through the HTTP Cookie and has nothing to do with the transmission of the SOAP header information to track the conversation.

Initial support of the SOAP message with attachments.

Provided in the EJB to EJB as a Web service access via.

Servlet based on the HTTP transfer.

JMS-based transport.

Independent of the server (but need HTTP server and Servlet container support).

To provide client, server-side related to the sample application.

Axis of packets needed for the operation of the following components axis.jar

jaxrpc.jar

saaj.jar

commons-logging.jar

commons-discovery.jar

wsdl4j.jar

JAXP-1.1 in line with the XML processor.

The beginning of step-by-step Web Services with Axis for a period of operation is given the following simple method of calling Web Services client-side code (as a result of the original document directly into the way the package is not easy for beginners to understand that type in that package, so I do the following a number of simple changes, I hope to give a clear idea of learners):

public class TestClient (

public static void main (String [] args) (

try (

String endpoint = "http://localhost:8080/axis/SayHello.jws?wsdl"; / / call the web service url address, here is a http request to be a result of wsdl document.

org.apache.axis.client.Service service = new org.apache.axis.client.Service ();// example the establishment of a framework to request services.

/ *

* Org.apache.axis.client.Service achieve the JAX-RPC's javax.xml.rpc.Services interface * generated below the interface to serve as an example * of org.apache.axis.client.Call role.

* /

org.apache.axis.client.Call call = (org.apache.axis.client.Call) service.createCall ();// generated from the framework of an example of a maintenance call.

/ *

* Org.apache.axis.client.Call achieved a JAX-RPC's javax.xml.rpc.Call interface.

* /

call.setTargetEndpointAddress (new java.net.URL (endpoint));

call.setOperationName (new javax.xml.namespace.QName ( "http://www.edu-edu.com.cn/luopc/ws", "echoString "));// settings need to call the name of the function String result = (String) call.invoke (new Object [] ( "hello !"});

System.out.println (result);

) catch (Exception e) (

System.err.println (e.toString ());

)

)

)

The code above may be different from the original document, and in the name space, function will be given a polymorphic confused users. But do not worry, I am in the translation of the manual will also be adding a lot of explanation of the code, if any do not just look for help through e-mail: luopc@edu-edu.com.cn, e-mail me the theme must be the name of the document.

Call through the above code to generate the final SOAP message request to the server package, the contents of specific XML is as follows:

<? xml version = "1.0" encoding = "UTF-8"?> <SOAP-ENV: Envelope xmlns: xsd = "http://www.w3.org/2001/XMLSchema" xmlns: SOAP-ENV = "http : / / schemas.xmlsoap.org / soap / envelope / "xmlns: xsi =" http://www.w3.org/2001/XMLSchema-instance "> <SOAP-ENV:Body> <ns1: echoString xmlns: ns1 = "http://www.edu-edu.com.cn/luopc/ws"> <arg0 xsi:type="xsd:string"> Hello! </ arg0> </ ns1: echoString> </ SOAP-ENV : Body> </ SOAP-ENV: Envelope>

Here I do not how many friends carefully from the corresponding code to find the corresponding information to understand the logic of its own. As for SOAP protocol translation in the future I will be added into the document.

From the above code to call when we entered the parameters of new Object [] ( "hello!"). And then from the generated SOAP request packets can be seen automatically sequence into <arg0 xsi:type="xsd:string"> Hello! </ Arg0>. You can see the name of the parameters arg0, type xsd: string. In fact, in the Axis client that we can directly approach to the adoption of specific settings for each parameter name, type and return value types. The following code:

call.addParameter ( "testParam", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.setReturnType (org.apache.axis.Constants.XSD_STRING);

After adding the above code generates the following SOAP message:

<? xml version = "1.0" encoding = "UTF-8"?> <SOAP-ENV: Envelope xmlns: xsd = "http://www.w3.org/2001/XMLSchema" xmlns: SOAP-ENV = "http : / / schemas.xmlsoap.org / soap / envelope / "xmlns: xsi =" http://www.w3.org/2001/XMLSchema-instance "> <SOAP-ENV:Body> <ns1: echoString xmlns: ns1 = "http://www.edu-edu.com.cn/luopc/ws"> <testParam xsi:type="xsd:string"> Hello! </ testParam> </ ns1: echoString> </ SOAP-ENV : Body> </ SOAP-ENV: Envelope>

Can be used for simple comparison.

Perhaps you will set the parameters of doubt do not set the name and the name of What is the difference between the parameters of the doubt. Make a brief explanation here:

1. Why should call.setReturnType (org.apache.axis.Constants.XSD_STRING)?

Above, you can call or can not call, but return the result data type does not indicate when the Axis do not know how to convert data types. Of course, if the return type and as you well know, the results of the return SOAP response that the corresponding data type you can not carry out the function call above.

2. Why should we set the parameter name and type?

Well, you know in how to call Web Services, and the following to tell you how to write and publish Web Services.

Axis published through Web Services

Here a simple type of writing, and then step by step to publish. Hope that users can learn to sort out some ideas. In my other article on the Web Services will be specific to Web Services General dissemination methods. Although the Web Services involved in a number of complex knowledge, but please do not feel that these simple, maybe you have a lot of questions, does not matter, write down your questions, and constantly test the vote.

public class SayHello (public String echoString (String hello) (return hello;))

Haha, this is not too simple.

Step by step.

Axis provides two types of release will be Java into Web Services means that the immediate release and rapid adoption of automatic configuration file to publish. We first start with the easiest deployment.

Immediate deployment of a simple JWS ---- that is to write their own type of Java source files Copy in accordance with certain rules to a specific directory Axis can be deployed on its own. Concrete steps are as follows:

Will be written above SayHello.java directory copied to the axis.

Changed its name to SayHello.jws.

Note: you can not be written in a specific category of information packet, which is the Axis does not support immediate deployment.

Written to run in front of our client to test results is hello!.


Java and XML Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.