You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by jaki <ja...@infosys.com> on 2008/08/16 12:04:45 UTC
Returning Map / List from web service
Hi all,
I have an axis WS client calling a remote ejb3 web service as below:
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName(new QName("http://session.um.com/",
"getAuc") );
call.addParameter("arg0",
org.apache.axis.Constants.XSD_INT,
javax.xml.rpc.ParameterMode.IN);
call.setReturnClass(HashMap.class);
HashMap ret = (HashMap) call.invoke( new Object[] {"1"}
Thought it throws no error, the returned Map / List never has any contents
in them. Also, if instead of setReturnClass I try to use
setReturnType(org.apache.axis.Constants.XSD_ANY) it gives me the below
error:
could not find deserializer for type {http://www.w3.org/2001/XMLSchema}any
--
View this message in context: http://www.nabble.com/Returning-Map---List-from-web-service-tp19010233p19010233.html
Sent from the Axis - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Returning Map / List from web service
Posted by sarika pramod <sa...@gmail.com>.
Hi jaki,
List/Map will not work - since those are Java specific types which may not
be representable in all languages -- hence web-services don't support them.
I am also facing the same issues currently.
Regards,
Sarika
On Mon, Aug 18, 2008 at 6:46 PM, jaki <ja...@infosys.com> wrote:
>
> Any help on this? :( I have exposed the ejbs using @Webservice annotations
> and not using the axis wsdd method. Should that be what's causing the
> problem? Please help
>
>
> jaki wrote:
> >
> > Hi all,
> >
> > I have an axis WS client calling a remote ejb3 web service as below:
> >
> > Call call = (Call) service.createCall();
> > call.setTargetEndpointAddress( new
> java.net.URL(endpoint) );
> > call.setOperationName(new QName("http://session.um.com/
> ",
> > "getAuc") );
> >
> >
> > call.addParameter("arg0",
> > org.apache.axis.Constants.XSD_INT,
> > javax.xml.rpc.ParameterMode.IN<http://javax.xml.rpc.parametermode.in/>
> );
> >
> >
> > call.setReturnClass(HashMap.class);
> > HashMap ret = (HashMap) call.invoke( new Object[] {"1"}
> >
> > Thought it throws no error, the returned Map / List never has any
> contents
> > in them. Also, if instead of setReturnClass I try to use
> > setReturnType(org.apache.axis.Constants.XSD_ANY) it gives me the below
> > error:
> >
> > could not find deserializer for type {
> http://www.w3.org/2001/XMLSchema}any<http://www.w3.org/2001/XMLSchema%7Dany>
> >
>
> --
> View this message in context:
> http://www.nabble.com/Returning-Map---List-from-web-service-tp19010233p19031177.html
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
Re: Returning Map / List from web service
Posted by jaki <ja...@infosys.com>.
Any help on this? :( I have exposed the ejbs using @Webservice annotations
and not using the axis wsdd method. Should that be what's causing the
problem? Please help
jaki wrote:
>
> Hi all,
>
> I have an axis WS client calling a remote ejb3 web service as below:
>
> Call call = (Call) service.createCall();
> call.setTargetEndpointAddress( new java.net.URL(endpoint) );
> call.setOperationName(new QName("http://session.um.com/",
> "getAuc") );
>
>
> call.addParameter("arg0",
> org.apache.axis.Constants.XSD_INT,
> javax.xml.rpc.ParameterMode.IN);
>
>
> call.setReturnClass(HashMap.class);
> HashMap ret = (HashMap) call.invoke( new Object[] {"1"}
>
> Thought it throws no error, the returned Map / List never has any contents
> in them. Also, if instead of setReturnClass I try to use
> setReturnType(org.apache.axis.Constants.XSD_ANY) it gives me the below
> error:
>
> could not find deserializer for type {http://www.w3.org/2001/XMLSchema}any
>
--
View this message in context: http://www.nabble.com/Returning-Map---List-from-web-service-tp19010233p19031177.html
Sent from the Axis - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Returning Map / List from web service
Posted by jaki <ja...@infosys.com>.
Changing the binding style to 'DOCUMENT' and parameterstyle to 'BARE' does
away with the above error. But now all the parameters are passed as '<arg0
xsi:type='xsd:string' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>nabble</arg0>'. Any remedy for
this :ninja:
jaki wrote:
>
> Ok I have decided to ditch the hashmap and here's my new wsdl and soap
> response:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <definitions name="AuctionBeanService"
> targetNamespace="http://wrapper.com/" xmlns:tns="http://wrapper.com/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns="http://schemas.xmlsoap.org/wsdl/">
> <types>
> <xs:schema targetNamespace="http://wrapper.com/" version="1.0"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:complexType name="mapBean">
> <xs:sequence>
> <xs:element minOccurs="0" name="key" type="xs:string"/>
> <xs:element minOccurs="0" name="value" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:schema>
> </types>
> <message name="AuctionBean_getMapResponse">
> <part name="return" type="tns:mapBean">
> </part>
> </message>
> <message name="AuctionBean_getMap">
> <part name="arg0" type="xsd:string">
> </part>
> </message>
> <portType name="AuctionBean">
> <operation name="getMap" parameterOrder="arg0">
> <input message="tns:AuctionBean_getMap">
> </input>
> <output message="tns:AuctionBean_getMapResponse">
> </output>
> </operation>
> </portType>
> <binding name="AuctionBeanBinding" type="tns:AuctionBean">
> <soap:binding style="rpc"
> transport="http://schemas.xmlsoap.org/soap/http"/>
> <operation name="getMap">
> <soap:operation soapAction=""/>
> <input>
> <soap:body use="literal" namespace="http://wrapper.com/"/>
> </input>
> <output>
> <soap:body use="literal" namespace="http://wrapper.com/"/>
> </output>
> </operation>
> </binding>
> <service name="AuctionBeanService">
> <port name="AuctionBeanPort" binding="tns:AuctionBeanBinding">
> <soap:address
> location="http://<mcname>:<port>/<jarname>/AuctionBean"/>
> </port>
> </service>
> </definitions>
>
>
>
> Soap response:
>
> <env:Envelope
> xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><ns1:getMapResponse
> xmlns:ns1='http://wrapper.com/'><return><key>randomkey</key><value>randomvalue</value></return></ns1:getMapResponse></env:Body></env:Envelope>
>
> But invoking the service gives me the below error:
>
> Caused by: org.xml.sax.SAXException: SimpleDeserializer encountered a
> child element, which is NOT expected, in something it was trying to
> deserialize.
> at
> org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
> at
> org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
> at
> org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
> at
> org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
> at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
> at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
> at org.apache.axis.client.Call.invoke(Call.java:2448)
> ... 3 more
>
>
>
>
> Lars Ericsson wrote:
>>
>> yes, array list will work i.e
>> ArrayList ret3 = (ArrayList) cu.call.invoke( new Object [] { jobid });
>>
>>
>>
>> ----- Original Message ----
>> From: sarika pramod <sa...@gmail.com>
>> To: axis-user@ws.apache.org
>> Sent: Monday, August 18, 2008 3:31:57 PM
>> Subject: Re: Returning Map / List from web service
>>
>>
>> Hi jaki,
>>
>> List/Map will not work - since those are Java specific types which may
>> not be representable in all languages -- hence web-services don't support
>> them.
>>
>> I am also facing the same issues currently.
>>
>> Regards,
>> Sarika
>>
>>
>> On Mon, Aug 18, 2008 at 6:46 PM, jaki <ja...@infosys.com> wrote:
>>
>>
>> Any help on this? :( I have exposed the ejbs using @Webservice
>> annotations
>> and not using the axis wsdd method. Should that be what's causing the
>> problem? Please help
>>
>>
>>
>> jaki wrote:
>>>
>>> Hi all,
>>>
>>> I have an axis WS client calling a remote ejb3 web service as below:
>>>
>>> Call call = (Call) service.createCall();
>>> call.setTargetEndpointAddress( new
>>> java.net.URL(endpoint) );
>>> call.setOperationName(new
>>> QName("http://session.um.com/",
>>> "getAuc") );
>>>
>>>
>>> call.addParameter("arg0",
>>> org.apache.axis.Constants.XSD_INT,
>>> javax.xml.rpc.ParameterMode.IN);
>>>
>>>
>>> call.setReturnClass(HashMap.class);
>>> HashMap ret = (HashMap) call.invoke( new Object[]
>>> {"1"}
>>>
>>> Thought it throws no error, the returned Map / List never has any
>>> contents
>>> in them. Also, if instead of setReturnClass I try to use
>>> setReturnType(org.apache.axis.Constants.XSD_ANY) it gives me the below
>>> error:
>>>
>>> could not find deserializer for type
>>> {http://www.w3.org/2001/XMLSchema}any
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Returning-Map---List-from-web-service-tp19010233p19031177.html
>>
>> Sent from the Axis - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Returning-Map---List-from-web-service-tp19010233p19048081.html
Sent from the Axis - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Returning Map / List from web service
Posted by jaki <ja...@infosys.com>.
Ok I have decided to ditch the hashmap and here's my new wsdl and soap
response:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="AuctionBeanService" targetNamespace="http://wrapper.com/"
xmlns:tns="http://wrapper.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xs:schema targetNamespace="http://wrapper.com/" version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="mapBean">
<xs:sequence>
<xs:element minOccurs="0" name="key" type="xs:string"/>
<xs:element minOccurs="0" name="value" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</types>
<message name="AuctionBean_getMapResponse">
<part name="return" type="tns:mapBean">
</part>
</message>
<message name="AuctionBean_getMap">
<part name="arg0" type="xsd:string">
</part>
</message>
<portType name="AuctionBean">
<operation name="getMap" parameterOrder="arg0">
<input message="tns:AuctionBean_getMap">
</input>
<output message="tns:AuctionBean_getMapResponse">
</output>
</operation>
</portType>
<binding name="AuctionBeanBinding" type="tns:AuctionBean">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getMap">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://wrapper.um2.com/"/>
</input>
<output>
<soap:body use="literal" namespace="http://wrapper.um2.com/"/>
</output>
</operation>
</binding>
<service name="AuctionBeanService">
<port name="AuctionBeanPort" binding="tns:AuctionBeanBinding">
<soap:address
location="http://<mcname>:<port>/<jarname>/AuctionBean"/>
</port>
</service>
</definitions>
Soap response:
<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><ns1:getMapResponse
xmlns:ns1='http://wrapper.com/'><return><key>randomkey</key><value>randomvalue</value></return></ns1:getMapResponse></env:Body></env:Envelope>
But invoking the service gives me the below error:
Caused by: org.xml.sax.SAXException: SimpleDeserializer encountered a child
element, which is NOT expected, in something it was trying to deserialize.
at
org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
at
org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
at
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at
org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.client.Call.invoke(Call.java:2448)
... 3 more
jaki wrote:
>
> Is your msg incomplete? Cuz it says part of the message was removed to
> comply with nabble security policy.
> If it's not, I tried 'ArrayList ret3 = (ArrayList) cu.call.invoke( new
> Object [] { jobid });' , but it returns back an emtpy list
>
>
>
> Lars Ericsson wrote:
>>
>> yes, array list will work i.e
>> ArrayList ret3 = (ArrayList) cu.call.invoke( new Object [] { jobid });
>>
>>
>>
>> ----- Original Message ----
>> From: sarika pramod <sa...@gmail.com>
>> To: axis-user@ws.apache.org
>> Sent: Monday, August 18, 2008 3:31:57 PM
>> Subject: Re: Returning Map / List from web service
>>
>>
>> Hi jaki,
>>
>> List/Map will not work - since those are Java specific types which may
>> not be representable in all languages -- hence web-services don't support
>> them.
>>
>> I am also facing the same issues currently.
>>
>> Regards,
>> Sarika
>>
>>
>> On Mon, Aug 18, 2008 at 6:46 PM, jaki <ja...@infosys.com> wrote:
>>
>>
>> Any help on this? :( I have exposed the ejbs using @Webservice
>> annotations
>> and not using the axis wsdd method. Should that be what's causing the
>> problem? Please help
>>
>>
>>
>> jaki wrote:
>>>
>>> Hi all,
>>>
>>> I have an axis WS client calling a remote ejb3 web service as below:
>>>
>>> Call call = (Call) service.createCall();
>>> call.setTargetEndpointAddress( new
>>> java.net.URL(endpoint) );
>>> call.setOperationName(new
>>> QName("http://session.um.com/",
>>> "getAuc") );
>>>
>>>
>>> call.addParameter("arg0",
>>> org.apache.axis.Constants.XSD_INT,
>>> javax.xml.rpc.ParameterMode.IN);
>>>
>>>
>>> call.setReturnClass(HashMap.class);
>>> HashMap ret = (HashMap) call.invoke( new Object[]
>>> {"1"}
>>>
>>> Thought it throws no error, the returned Map / List never has any
>>> contents
>>> in them. Also, if instead of setReturnClass I try to use
>>> setReturnType(org.apache.axis.Constants.XSD_ANY) it gives me the below
>>> error:
>>>
>>> could not find deserializer for type
>>> {http://www.w3.org/2001/XMLSchema}any
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Returning-Map---List-from-web-service-tp19010233p19031177.html
>>
>> Sent from the Axis - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Returning-Map---List-from-web-service-tp19010233p19047819.html
Sent from the Axis - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Returning Map / List from web service
Posted by jaki <ja...@infosys.com>.
Is your msg incomplete? Cuz it says part of the message was removed to comply
with nabble security policy.
If it's not, I tried 'ArrayList ret3 = (ArrayList) cu.call.invoke( new
Object [] { jobid });' , but it returns back an emtpy list
Lars Ericsson wrote:
>
> yes, array list will work i.e
> ArrayList ret3 = (ArrayList) cu.call.invoke( new Object [] { jobid });
>
>
>
> ----- Original Message ----
> From: sarika pramod <sa...@gmail.com>
> To: axis-user@ws.apache.org
> Sent: Monday, August 18, 2008 3:31:57 PM
> Subject: Re: Returning Map / List from web service
>
>
> Hi jaki,
>
> List/Map will not work - since those are Java specific types which may not
> be representable in all languages -- hence web-services don't support
> them.
>
> I am also facing the same issues currently.
>
> Regards,
> Sarika
>
>
> On Mon, Aug 18, 2008 at 6:46 PM, jaki <ja...@infosys.com> wrote:
>
>
> Any help on this? :( I have exposed the ejbs using @Webservice annotations
> and not using the axis wsdd method. Should that be what's causing the
> problem? Please help
>
>
>
> jaki wrote:
>>
>> Hi all,
>>
>> I have an axis WS client calling a remote ejb3 web service as below:
>>
>> Call call = (Call) service.createCall();
>> call.setTargetEndpointAddress( new
>> java.net.URL(endpoint) );
>> call.setOperationName(new
>> QName("http://session.um.com/",
>> "getAuc") );
>>
>>
>> call.addParameter("arg0",
>> org.apache.axis.Constants.XSD_INT,
>> javax.xml.rpc.ParameterMode.IN);
>>
>>
>> call.setReturnClass(HashMap.class);
>> HashMap ret = (HashMap) call.invoke( new Object[] {"1"}
>>
>> Thought it throws no error, the returned Map / List never has any
>> contents
>> in them. Also, if instead of setReturnClass I try to use
>> setReturnType(org.apache.axis.Constants.XSD_ANY) it gives me the below
>> error:
>>
>> could not find deserializer for type
>> {http://www.w3.org/2001/XMLSchema}any
>>
>
> --
> View this message in context:
> http://www.nabble.com/Returning-Map---List-from-web-service-tp19010233p19031177.html
>
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>
>
--
View this message in context: http://www.nabble.com/Returning-Map---List-from-web-service-tp19010233p19032202.html
Sent from the Axis - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org