New Generation Web Service implementation Package--AXIS2 Learning Notes

Source: Internet
Author: User
Tags object model

I'm lazy and don't want to translate all the user guide, just record some points.

Axis2 is a new design, and at the Axis Summit in 2004, we decided to adopt a new architecture to make axis more resilient, more efficient, and more configurable. Some of the feature that AXIS2 now have:
Speed
Low Memory foot Print
AXIOM-
AXis Object Model
Hot Deployment
Asynchronous Web Services
MEP Support-
Message Exchange Patterns
Flexibility
Stability
component-oriented deployment
Transport Framework
WSDL
Support

Some feature now do not understand, or first do a bit, perceptual knowledge of it

First step: Download AXIS2. http://ws.apache.org/axis2/download.cgi. Interestingly, AXIS2 is not visible under the project directory of Apache's Web Service. To the binary version, because there are routines.
Step two: Copy Axis2.war to the $tomcat_home/webapps directory. Tomcat seems to only use JDK1.4, I can not use it in JDK1.5.
The third step: Open Http://localhost:8080/axis2, you can see the Axis2 welcome page. Click Validate and services to see if there are no errors. Without any errors, it means that the deploy was successful. The Adminstration page can be used for remote deploy by uploading files to hot deploy Web service.
Fourth Step: Study the routine. Start with a routine from the ' samples/userguide/src ' directory. It's easy to see how to write a Web service:

Public class MyService {
    public omelement Echo (omelement element) throws Xmlstreamexception { br>       //praparing The omelement so, it can be attached to another OM Tree.
       //first The omelement should be completely build in case it's not fully built And still
       //some of the XML is in the stream.
        Element.build ();
       //secondly The omelement should is detached from the current omtree so that It can be attached
       //some other OM Tree. Once detached the Omtree would remove its connections to this omelement.
        Element.detach ();
        return element;
   }

public void Ping (omelement element) throws Xmlstreamexception {
Do some processing
}
public void Pingf (omelement element) throws axisfault{
throw new Axisfault (' Fault being thrown ');
}
}

It can be seen that the function uniformly uses omelement as a parameter. There is a services.xml file under the Meta-inf directory:
<service name= ' MyService ' >
<description>
This was a sample Web Service with a operations,echo and ping.
</description>
<parameter name= ' ServiceClass ' locked= ' false ' >userguide.example1.MyService</parameter>
<operation name= ' echo ' >
<messagereceiver class= ' Org.apache.axis2.receivers.RawXMLINOutMessageReceiver '/>
</operation>
<operation name= ' ping ' >
<messagereceiver class= ' Org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver '/>
</operation>
</service>
Oh, also very simple. With the return value of the Rawxmlinoutmessagereceiver, no return value is used rawxmlinonlymessagereceiver. Compile them (to write the jar of Axis2 to the Classpath) and press the package to Myservice.aar, the file directory is as follows:
.//meta-inf/services.xml
./userguide/example1/myservice.class
Copy the Myservice.aar to $tomcat_home/webapps/axis2/web-inf/services, then go to the services on the Http://localhost:8080/axis2 page, That is http://localhost:8080/axis2/listServices.jsp, you can see that MyService has been listed.

There's a lot of things to call a Web service, so write it next time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.