[
https://issues.apache.org/jira/browse/AXIS2-5064?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13070368#comment-13070368
]
Paul Nibin K J commented on AXIS2-5064:
---------------------------------------
Hi,
I tried to create a service that receives and returns a Map.
The Service class is:
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
public class MapTest
{
public Map < String, Object > echoMap( Map < String, Object > testMap )
{
Set < Entry < String, Object >> entrySet = testMap.entrySet();
for ( Entry < String, Object > entry : entrySet )
{
System.out.println( entry.getKey() + " : " + entry.getValue() + " :
" + entry.getValue().getClass() );
}
return testMap;
}
}
I deployed this service as a POJO. And I generated client stub using the
following code.
WSDL2Java.main( new String []
{ "-o", ".", "-uw", "-u", "-uri",
"http://localhost:8080/axis2/services/MapTest?wsdl" } );
My Client test code is:
import org.apache.ws.namespaces.axis2.map.Entry1;
import org.apache.ws.namespaces.axis2.map.Entry2;
import org.apache.ws.namespaces.axis2.map.Map1;
import org.apache.ws.namespaces.axis2.map.Map2;
public class Axis2MapTest
{
public static void main( String [] args ) throws Throwable
{
MapTestStub stub = new MapTestStub();
Map1 testMap5 = new Map1();
Entry1 entry1 = new Entry1();
entry1.setKey( "key1" );
entry1.setValue( "Value1" );
testMap5.addEntry( entry1 );
entry1 = new Entry1();
entry1.setKey( "key2" );
entry1.setValue( 5 );
testMap5.addEntry( entry1 );
entry1 = new Entry1();
entry1.setKey( "key1" );
entry1.setValue( 47.2233 );
testMap5.addEntry( entry1 );
Map2 echoMap = stub.echoMap( testMap5 );
Entry2 [] entry = echoMap.getEntry();
for ( Entry2 entry2 : entry )
{
System.out.println( entry2.getKey() + " : " + entry2.getValue() + "
: " + entry2.getValue().getClass() );
}
}
}
When I try to invoke the service using the client, I am getting the following
error from the client.
Exception in thread "main" org.apache.axis2.AxisFault:
org.apache.axis2.databinding.ADBException: Unexpected subelement
{http://ws.apache.org/namespaces/axis2/map}entry
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.ws.axis2.MapTestStub.fromOM(MapTestStub.java:529)
at org.apache.ws.axis2.MapTestStub.echoMap(MapTestStub.java:192)
at org.apache.ws.axis2.Axis2MapTest.main(Axis2MapTest.java:28)
Caused by: java.lang.Exception: org.apache.axis2.databinding.ADBException:
Unexpected subelement {http://ws.apache.org/namespaces/axis2/map}entry
at org.apache.ws.namespaces.axis2.map.Map2$Factory.parse(Map2.java:538)
at
org.apache.ws.axis2.EchoMapResponse$Factory.parse(EchoMapResponse.java:397)
at org.apache.ws.axis2.MapTestStub.fromOM(MapTestStub.java:523)
... 2 more
Caused by: org.apache.axis2.databinding.ADBException: Unexpected subelement
{http://ws.apache.org/namespaces/axis2/map}entry
at org.apache.ws.namespaces.axis2.map.Map2$Factory.parse(Map2.java:524)
... 4 more
There is no error at the server side. The exception occurs while parsing the
response in the client side.
The response sent to the client from server is:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns:echoMapResponse xmlns:ns="http://ws.apache.org/axis2">
<return>
<map:entry
xmlns:map="http://ws.apache.org/namespaces/axis2/map">
<map:key>key2</map:key>
<map:value xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="xs:int">5</map:value>
</map:entry>
<map:entry
xmlns:map="http://ws.apache.org/namespaces/axis2/map">
<map:key>key1</map:key>
<map:value xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="xs:double">47.2233</map:value>
</map:entry>
</return>
</ns:echoMapResponse>
</soapenv:Body>
</soapenv:Envelope>
Please check whether this is supported yet.
Thanks,
Paul
> Support HashMap type in the web service.
> ----------------------------------------
>
> Key: AXIS2-5064
> URL: https://issues.apache.org/jira/browse/AXIS2-5064
> Project: Axis2
> Issue Type: Improvement
> Components: adb
> Affects Versions: 1.5.4, 1.6.0
> Reporter: Muhammed Shariq
> Assignee: Sagara Gunathunga
> Fix For: 1.7.0
>
>
> Support HashMap type in the web service.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]