WebService Axis2 (3): Publishing with Services.xml file WebService

Source: Internet
Author: User
Tags wsdl

Web service is implemented with AXIS2, although it is possible to publish Pojo classes directly into a Web service in the Axis2\web-inf\pojo directory, which does not require any configuration, but these Pojo classes cannot be in any package. This may seem inconvenient, and Axis2 also allows the Pojo class with packages to be published as a Web Service.

First implement a Pojo class, the code is as follows:

Package service;
public class MyService
{public
    string getgreeting (string name)
    {
        "hello" + name;
    }
    public void Update (String data)
    {
        System.out.println ("<" + Data + "> has been updated");
    }

This class has two methods, both of which need to be published as Web service methods. This approach differs from the Pojo class that is placed directly in the Pojo directory. To publish a MyService class as a Web Service, you need a services.xml file that needs to be placed in the Meta-inf directory, which reads as follows:

<service name= "MyService" >
    <description>
        Web Service Example
    </description>
    < Parameter name= "ServiceClass" >
        service. MyService  
    </parameter>
    <messageReceivers>
        <messagereceiver mep= "http://www.w3.org/ 2004/08/wsdl/in-out "
            class=" Org.apache.axis2.rpc.receivers.RPCMessageReceiver "/>
        < Messagereceiver mep= "http://www.w3.org/2004/08/wsdl/in-only"
            class= " Org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver "/>
    </messageReceivers>
</service >

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.