Best practices for interoperability between axis and DOTNET in Web Service: Passing java. util. Map Objects to C)

Source: Internet
Author: User

Since axis supports automatic serialization and deserialization of JavaBean, Java object and xml soap message ing are realized, so the map object of Java is passed. net is the simplest way to implement a JavaBean array object:

File 1:

Public class mapentryvo {
Private object key;
Private object value;

Public mapentryvo (){
}

Public mapentryvo (Object key, object Value ){
This. Key = key;
This. value = value;
}

Public object getkey (){
Return key;
}
Public void setkey (object Value ){
Key = value;
}

Public object getvalue (){
Return value;
}
Public void setvalue (object Value ){
This. value = value;
}
}
File 2:

Import java. util .*;

Public class webservicesutils {
Public static mapentryvo [] convertmaptomapentryvo (MAP Conv ){
Mapentryvo [] result = new mapentryvo [Conv. Size ()];
Int I = 0;
Iterator iter = Conv. entryset (). iterator ();

While (ITER. hasnext ()){
Map. Entry item = (Map. Entry) ITER. Next ();
Result [I ++] = new mapentryvo (item. getkey (), item. getvalue ());
}

Return result;
}
}
File 3:

// Example WebService
Public class testservice {
Public mapentryvo [] testmethod (){
Java. util. MAP value = new java. util. hashmap ();

Value. Put ("Key 1", "value 1 ");
Value. Put ("Key 2", "value 2 ");

Return webservicesutils. convertmaptomapentryvo (value );
}
}

CodeAfter that, remember to configure the serialization of the JavaBean in the server-config.wsdd (or deployment file deploy. WSDD) to inform axis of the object you need to serialize automatically:

<Typemapping QNAME = "Java: mapentryvolist"
Type = "Java: mapentryvo []"
Serializer = "org. Apache. axis. encoding. Ser. arrayserializerfactory"
Deserializer = "org. Apache. axis. encoding. Ser. arraydeserializerfactory"
Encodingstyle = "http://schemas.xmlsoap.org/soap/encoding/"/>

<Typemapping QNAME = "Java: mapentryvo"
Type = "Java: mapentryvo"
Serializer = "org. Apache. axis. encoding. Ser. beanserializerfactory"
Deserializer = "org. Apache. axis. encoding. Ser. beandeserializerfactory"
Encodingstyle = "http://schemas.xmlsoap.org/soap/encoding/"/>

Refer:

Http://wiki.apache.org/ws/FrontPage/Axis/DotNetInteropMapInfo

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.