Developing Web Service using AXIS2 's underlying APIs

Source: Internet
Author: User

1. Develop Web service server side using Axis2 's underlying APIs

1.1 Create a WebService (named MyService)

There are two operations in the MyService, as shown below.

public void Ping (omelement element) {}//in-only mode. Just receive the omelement and process it.

Public omelement Echo (omelement element) {}//in_out mode. Receives the Omelemen and returns omelement.

1.2 How to write Web Service

1 Create the class that implements the service.

2 Create Services.xml to parse this web Service.

3 Package it into a *.aar document (Axis Archive).

4 Deploy the Web Service.

1.2.1 Create a class that implements a service

The methods provided in this class must correspond to the operations in the Web Service (declared in Services.xml). Unless you provide data binding, all methods can receive only one parameter, which is of type omelement.

public class MyService{
  public void ping(OMElement element){...}
  public OMElement echo(OMElement element){...}
}

Myservice.java

Package Userguide.example1
Import org.apache.axiom.om.OMElement;
Import Org.apache.axis2.AxisFault;
Import javax.xml.stream.XMLStreamException;
public class MyService {
Public omelement echo (omelement element) throws Xmlstreamexception {
//prapa The ring the omelement so, it can be attached to another OM tree.
//first The omelement should to completely build in case it is not fully built and still
//some of the The XML is in the stream.
Element.build ();
//secondly The omelement should is detached from the ' current ' omtree so ' it can
//be attached some Other OM the 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");
}
}

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.