[WebService Tutorial] Use services.xml file release WebService - 3

2010-07-04  来源:本站原创  分类:Web  人气:182 

Achieved with Axis2 Web Service, although you can POJO class on axis2 \ WEB-INF \ pojo directory directly released into the Web Service, this does not require any configuration, but these POJO class can not in any package. This seems somewhat inconvenient, this, Axis2 also allows POJO class with a package released into the Web Service.
First realization of a POJO class, the code is as follows:

package service;

public class MyService
{
    public String getGreeting(String name)
    {
        return " Hello   " + name;
    }
    public void update(String data)
    {
        System.out.println("<" + data + "> Has been updated  ");
    }
}

This class has two methods, both methods need to publish as Web Service methods. In this way, and directly on the pojo directory POJO class different. To be released into the class MyService Web Service, require a services.xml file, this file needs to be placed in the META-INF directory, the file 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"
            />
        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
            />
    </messageReceivers>
</service>

One element is used to publish <service> Web Service, a <service> element can only publish a WebService class, name said WebService attribute name, such as the following URL can get the contents of this WebService in WSDL:

http://localhost:8080/axis2/services/myService?wsdl

Property name is the name of which the above URL, "?" And "/" between the parts.

<description> element that the current Web Service description, <parameter> WebService element used to set the parameters, where used to set the WebService corresponding class names. The most notable here is <messageReceivers> element, the element used to set the WebService method of dealing with processors. For example, getGreeting method has a return value, therefore, need to handle input and output of RPCMessageReceiver class, and update method does not return value, therefore, need only deal with input RPCInOnlyMessageReceiver class.

Released this way by using the WebService, to be packaged. Aar file, .. aar file is actually changed the extension. Jar file. Now established two files: MyService.java and services.xml. Will MyService.java compile, generate MyService.class. services.xml and MyService.class location of the file are as follows:

D: \ ws \ service \ MyService.class

D: \ ws \ META-INF \ services.xml

Ws in the windows directory into the console and enter the following command generates. Aar file (in fact,. Jar files can also publish webservice, but the official document axis2 recommended. Aar file release webservice):

jar cvf ws.aar.

Finally, ws.aar files to <Tomcat Installation directory > \ webapps \ axis2 \ WEB-INF \ services directory, start Tomcat, you can call the WebService was. The method of calling and "WebService large auditorium of the Axis2 (1): 0 configured to achieve with POJO WebService" similar to the method of speaking.

Also services.xml file can also specify the WebService class methods, such as code can be configured to publish the following WebService:

<service name="myService">
    <description>
        Web Service Example
    </description>
    <parameter name="ServiceClass">
        service.MyService
    </parameter>
    <operation name="getGreeting">
        <messageReceiver />
    </operation>
    <operation name="update">
        <messageReceiver
            />
    </operation>
</service>

Above the front part of the configuration code and the contents of the previous services.xml file the same, but later used to specify each element <operation> WebService method, and a separate deal with each method specified processor. For the client, calls the two services.xml file using WebService released and I am not much difference, just use the second release WebServices services.xml file after using the wsdl2java command or by using C #, delphi, etc. generate customer when the end of the stub, update methods of String type is encapsulated in the update class, in the update method passing the parameters need to establish update class object instance. The services.xml file using the first release of the WebService directly in the generated stub when the update method for passing parameters of type String. From this we can see that the two methods generated WSDL is quite different. But in fact, if the client program using the first release of the WebService services.xml file generated stub class (then update method parameter is the String), the server has changed to the second services.xml file to publish WebService, At this time the client does not need to regenerate the stub class, which can directly call the update method. That is, what kind of server-side approach using release WebService, and has no effect on the client.

If you want to publish more than WebService, you can use <serviceGroup> elements, such as the re-establishment of a MyService1 class, the code is as follows:

package service
public class MyService1
{
    public String getName()
    {
        return "bill";
    }
}

In the services.xml file, use the following configuration code to configure and MyService1 class MyService:

<serviceGroup>
    <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"
                />
            <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
                />
        </messageReceivers>
    </service>
    <service name="myService1">
        <description>
            Web Service Example
       </description>
        <parameter name="ServiceClass">
            service.MyService1
        </parameter>
         <messageReceivers>
           <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
                />
           <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
                />
        </messageReceivers>
    </service>
</serviceGroup>
相关文章
  • [WebService Tutorial] Use services.xml file release WebService - 3 2010-07-04

    Achieved with Axis2 Web Service, although you can POJO class on axis2 \ WEB-INF \ pojo directory directly released into the Web Service, this does not require any configuration, but these POJO class can not in any package. This seems somewhat inconve

  • [WebService Tutorial] Binary file transfer - 4 2010-07-04

    In the "WebService large auditorium of the Axis2 (2): complex types of data transfer," have said that, if you want to transfer binary files (such as images, audio files, etc.), you can use the byte [] as the data types are passed, then the clien

  • Spring integration with the Xfire release WebService 2010-06-08

    Web service publisher must first provide a WSDL document, Web Services Description Language (Web Services Description Language), XML file that defines the Web service call to all of the information, including all of the method name, parameter types,

  • [WebService Tutorial] will be released Spring assembly JavaBean into WebService - 7 2010-07-04

    In today's Web applications frequently use the Spring framework to load the JavaBean. If it is to be certain in the Spring in the assembly of the JavaBean released into WebService, using Axis2's Spring perception function is very easy to do. In this

  • [WebService Tutorial] prepared Axis2 module (Module) - 9 2010-07-04

    Axis2 by module (Module) be extended. Axis2 module requires at least two classes, two classes were realized Module and Handler interfaces. Development and use of an Axis2 module, follow these steps: 1. Preparation of achieving Module interface. Axis2

  • [WebService Tutorial] Session (Session) Management - 5 2010-07-04

    WebService people feel is the most intuitive way from a one component, and the client through the SOAP protocol call these methods. These methods may have return values, may not return values. Although some tools that can be done, but the method is c

  • [WebService Tutorial] Cross-Service Session (Session) Management - 6 2010-07-04

    In the "WebService large auditorium of the Axis2 (5): Session (Session) Management" article describes how to use Axis2 to manage the session with a service, but a complex system, not only a WebService service, for example, at least there will be

  • [WebService Tutorial] Use soapmonitor module to monitor soap request and response messages - 10 2010-07-04

    In Axis2 Axis2 module provides a (soapmonitor), the module with "WebService large auditorium of the Axis2 (9): preparation of Axis2 module (Module)" in the logging module to achieve the same function, the difference is, logging module directly t

  • (Original) java xml data access WebService returns an instance of students into the local file 2010-06-17

    Reprinted please indicate the source: http://eric-619.javaeye.com/blog/692838 import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.io.FileNotFou

  • BPEL integration services, a complete case WEBService 2009-08-24

    Much nonsense that lets you understand more specific examples of BPEL and WebService technology. Example Objective: Using BPEL calls through the CXF project was announced the addition of a service and subtraction services, to form a new service -----

  • [WebService Tutorial] to achieve 0 configuration with POJO WebService - 1 2010-07-04

    Axis2 WebService is a brand new engine, this version is Axis1.x redesigned product. Axis2 not only supports SOAP1.1 and SOAP1.2, also integrates a very popular REST WebService, and also supports Spring, JSON technologies. All will be explained later

  • [WebService Tutorial] complex types of data transfer - 2 2010-07-04

    In practical applications, not only need to use the WebService to pass a simple type of data, sometimes need to pass more complex data that can be called complex types of data. Array with the class (interface) is a compound commonly used type. Axis2

  • Xfire Spring Hibernate release WebService 2010-04-01

    Xfire Spring Hibernate release WebService Xfire Spring 1.2 Hibernate 3 release WebService First, preparatory work 1, download and install Eclipse Version: 3.3.1.1 and MyEclipse6.0.1 2, download and install MySQL Server 5.1 3, download MySQL driver my

  • xfire webservice tutorial 2010-09-03

    Study: ThirdteenDevil 13 demon qq: 181907667 Note: This example can be solved webservice passing custom objects Server files and settings The servlet in the web.xml configuration xfire <servlet> <servlet-name>XFireServlet</servlet-name>

  • [WebService Tutorial] asynchronous call WebService - 8 2010-07-04

    In the previous articles are used in synchronous mode to call WebService. That is, if the WebService method is called a long time does not return, the client will remain blocked until the method returns so far. Use the synchronous method to call WebS

  • php的webservice的wsdl的XML无法显示问题的解决方法 2014-04-12

    本篇文章是对php的webservice的wsdl的XML无法显示问题的解决方法进行了介绍,需要的朋友可以过来参考下,希望对大家有所帮助 php的webservice的因为wsdl有中文所以xml无法显示 可以用Nopepad++ 转码即可 以UTF-8无BOM编码

  • easy to read tutorial flash xml file (change) 2010-04-14

    First, the establishment of XML objects: var myXML = new XML (); Second, the reference XML file: myXML.load ("data.xml"); Third, ignore the spaces: myXML.ignoreWhite = true; / / default is false 4, dealing with XML objects function: myXML.onLoad

  • java parse xml file in four ways (change) 2009-09-26

    Keywords: java 1. Introduction 1) DOM (JAXP Crimson parser) DOM is platform-and language-independent manner in the official W3C standard XML documents. DOM is a hierarchical organization of nodes or a collection of pieces of information. This hierarc

  • XML file parsing - libxml library functions explained 2010-04-12

    http://zacaosansan.spaces.live.com/Blog/cns!20F577789A0BB695!206.entry Parsing xml document parsing an xml document, from out the desired information, such as node contains text, or an attribute node, the process is as follows: XmlReadFile function w

  • Comprehensive Xiangjie AndroidManifest.xml file 2010-08-18

    First, the importance of AndroidManifest.xml Android application is the most important documents. It is the global configuration file Android program, is required for each program file android. It is located in the applications we develop the root di