Axis2service Client Access Universal Class collection list custom type

Source: Internet
Author: User

AXIS2 services four kinds of client invocation methods:

1.AXIOMClient

2.generating a client using ADB

3.generating a client using XMLBeans

4.generating a client using JiBX

Http://axis.apache.org/axis2/java/core/official

Search a lot of information, did not find the right. Whether it's plug-in generation or axiomclient is cumbersome to use.

Service

Public interface Testservice {public list<person> findAll ();p ublic person Getwhere (list<person> persons); /3. Passing in the collection, returning the object public list<person> getwheres (list<person> persons);//4. Incoming collection, returns the collection public person Getchild ( Person P); 1. Incoming object, return object public list<person> GetChildren (person p);//2. Incoming object, return collection}

To achieve the above goal should be able to meet the majority of the use of the scene. Then we'll do it in the next.

Client

1. Passing in objects, returning objects

private static  void Test01parameterisobjectreturnobject ()    {
Client calls are simple. You can call the service method by passing in the following value
        Service address, namespace, method name, parameter
SYSTEM.OUT.PRINTLN ("=====================test01[the parameter is a object and return a object] begin:");        Axis2context.setfunctionname ("Getchild");        map<string,object> map = new hashmap<string,object> ();        Map.put ("P", Createperson ());        Axis2context.setfunctionprameters (map);        Person person = Axis2help.invoke (Axis2context, person.class);        SYSTEM.OUT.PRINTLN ("The result:" + person.getname ());        System.out.println ("=============================================================================end");    }

return Result:

==========================================test01[the parameter is a object and return a object] begin:
The result: Zhang San return value
=============================================================================end

2. Passing in the object, returning the collection

private static  void Test02parameterisobjectreturnlist ()    {        System.out.println ("===================== Test02[the parameter is a object and return list] begin: ");        Axis2context.setfunctionname ("GetChildren");        map<string,object> map = new hashmap<string,object> ();        Map.put ("P", Createperson ());        Axis2context.setfunctionprameters (map);        list<person> persons = Axis2help.invokeforlist (Axis2context, person.class);        SYSTEM.OUT.PRINTLN ("The result Persons.size ():" + persons.size ());        System.out.println ("=============================================================================end");    }

return Result:

==========================================test02[the parameter is a object and return list] begin:
The result Persons.size (): 2
=============================================================================end

3. Incoming collection return object

SYSTEM.OUT.PRINTLN ("=====================test03[the parameter is list and return a object] begin:");        Axis2context.setfunctionname ("Getwhere");        map<string,object> map = new hashmap<string,object> ();        Map.put ("Persons", Createpersonlist ());        Axis2context.setfunctionprameters (map);        Person person = Axis2help.invoke (Axis2context, person.class);        SYSTEM.OUT.PRINTLN ("The result:" + person.getname ());        System.out.println ("=============================================================================end");

return Result:

=====================test03[the parameter is list and return a object] begin:
The result: Zhang San: return value
=============================================================================end

4. Incoming collection Returns a collection

private static  void Test04parameterislistreturnlist ()    {        System.out.println ("===================== Test04[the parameter is list and return a list] begin: ");        Axis2context.setfunctionname ("Getwheres");        map<string,object> map = new hashmap<string,object> ();        Map.put ("Persons", Createpersonlist ());        Axis2context.setfunctionprameters (map);        list<person> persons = Axis2help.invokeforlist (Axis2context, person.class);        SYSTEM.OUT.PRINTLN ("The result:" + persons.size ());        System.out.println ("=============================================================================end");    }

return Result:

==========================================test04[the parameter is list and return a list] begin:
The Result:2
=============================================================================end

Parameter type: Person is a complex custom type.

End

Axis2service Client Access Universal Class collection list custom type

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.