axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aravind Nallan" <aravind.nal...@openwave.com>
Subject RE: returning Map objects from webservices
Date Thu, 27 May 2004 22:48:48 GMT
I think the problem is that WSDL2Java doesnt generate a corresponding Map
object when it sees schema like this in wsdl. It only generates the
MapEntry[] and puts this in the Java code where it should really be Map or
HashMap.

    <schema targetNamespace="http://java.sun.com/jax-rpc-ri/internal"
xmlns:tns=
"http://java.sun.com/jax-rpc-ri/internal"
xmlns:soap11-enc="http://schemas.xmlso
ap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xml
ns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://www.w3.org/2001/XMLSche
ma">
      <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
      <import namespace="urn:opwv"/>
      <complexType name="map">
        <complexContent>
          <restriction base="soap11-enc:Array">
            <attribute ref="soap11-enc:arrayType"
wsdl:arrayType="tns:mapEntry[]
"/></restriction></complexContent></complexType>
      <complexType name="mapEntry">
        <sequence>
          <element name="key" type="anyType"/>
          <element name="value"
type="anyType"/></sequence></complexType></schem
a>

Consequently when i get a response like

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="urn:opwv"
xmlns:ns1="http://java.sun.com/jax-rpc-ri/internal"
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><env:Body><ns0
:getPreferencesResponse><result xsi:type="ns1:hashMap"
enc:arrayType="ns1:mapEntry[20]">.....

it looks at the hashMap and says no serializer found. Becasue it only
generated and registered MapEntry.

Aravind

-----Original Message-----
From: Tom Jordahl [mailto:tomj@macromedia.com]
Sent: Thursday, May 27, 2004 3:17 PM
To: 'axis-dev@ws.apache.org'
Subject: RE: returning Map objects from webservices



The WSDL2Java generated sub code *does* register type mappings for the types
it generates.

Check the generated Stub class for details.

Your patch still may still fix a bug - does the 'all-tests' ant target pass?

--
Tom Jordahl
Macromedia Server Development

-----Original Message-----
From: Aravind Nallan [mailto:aravind.nallan@openwave.com]
Sent: Thursday, May 27, 2004 6:04 PM
To: axis-dev@ws.apache.org
Subject: RE: returning Map objects from webservices

The following diff fixes the problem but i'm not entirely sure this is the
right solution. Can anyone verify?

org/apache/axis/encoding/ser/ArrayDeserializer.java
265c265,266
<         } else {
---
>         }
>         if(arrayClass == null) {

The problem seems to be that the new type generated by WSDL2Java doesnt get
into the DeserializationContext's notion of type mapping. I'm wondering if
there is anything the client needs to do for all these types generated by
WSDL2Java like register them with something?

Aravind


-----Original Message-----
From: Aravind Nallan [mailto:aravind.nallan@openwave.com]
Sent: Thursday, May 27, 2004 12:10 PM
To: axis-dev@ws.apache.org
Subject: RE: returning Map objects from webservices


Got it. Yes the RI maps it to java.util.Map.

Do i have to register this type with axis in my client before i use it? I
get the following exception trying to deserialize a response.

org.xml.sax.SAXException: No deserializer defined for array type
{http://java.sun.com/jax-rpc-ri/internal}mapEntry
        at org.apache.axis.AxisFault.makeFault(AxisFault.java:129)
        at org.apache.axis.client.Call.invoke(Call.java:2275)
        at org.apache.axis.client.Call.invoke(Call.java:2171)
        at org.apache.axis.client.Call.invoke(Call.java:1691)
        at
opwv.UserPreferencesBindingStub.getPreferences(UserPreferencesBindingStub.ja
va:245)
        at GalleryClient.main(GalleryClient.java:46)
Caused by: org.xml.sax.SAXException: No deserializer defined for array type
{http://java.sun.com/jax-rpc-ri/internal}mapEntry
        at
org.apache.axis.encoding.ser.ArrayDeserializer.onStartElement(ArrayDeseriali
zer.java:304)
        at
org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java
:428)
        at
org.apache.axis.encoding.DeserializationContextImpl.startElement(Deserializa
tionContextImpl.java:976)
        at
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:198)
        at
org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:
722)
        at
org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233)
        at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)
        at org.apache.axis.client.Call.invoke(Call.java:2272)

even though the MapEntry class generated by wsdl2java is in classpath and
has getSerializer and getDeserializer methods which return BeanSerializer
objects.

Thanks
Aravind

-----Original Message-----
From: Tom Jordahl [mailto:tomj@macromedia.com]
Sent: Thursday, May 27, 2004 11:43 AM
To: 'axis-dev@ws.apache.org'
Subject: RE: returning Map objects from webservices



Yes, because there is no 'standard' Qualified name for the Java Map type.
So WSDL2Java is just creating a type based on the XML Schema in the WSDL.

Since the namespace is http://java.sun.com/jax-rpc-ri/internal, this gets
turned in to the package name "com.sun.java.jax_rpc_ri.internal".

I'll bet that the RI recognizes this QName and turns it in to a
java.utils.Map type (HashMap?)

I think we do similar things with Map Schema we emit in the axis.apache.org
namespace.....

--
Tom Jordahl
Macromedia Server Development

-----Original Message-----
From: Aravind Nallan [mailto:aravind.nallan@openwave.com]
Sent: Thursday, May 27, 2004 12:26 PM
To: axis-dev@ws.apache.org
Subject: returning Map objects from webservices

I'm trying to generate java code from the attached wsdl. WSDL2Java creates
the following code

package opwv;

public interface UserPreferences extends java.rmi.Remote {
    public com.sun.java.jax_rpc_ri.internal.MapEntry[]
getPreferences(opwv.Crede
ntials credentials_1, java.lang.String string_2, java.lang.String[]
arrayOfStrin
g_3) throws java.rmi.RemoteException, opwv.MMSException,
opwv.InvalidArgumentExc
eption, opwv.InvalidCredentialsException, opwv.UserAccountException;
    public void updatePreferences(opwv.Credentials credentials_1,
java.lang.Stri
ng string_2, com.sun.java.jax_rpc_ri.internal.MapEntry[] map_3) throws
java.rmi.
RemoteException, opwv.MMSException, opwv.InvalidArgumentException,
opwv.InvalidC
redentialsException, opwv.UserAccountException;
}

It creates type com.sun.java.jax_rpc_ri.internal.MapEntry[] for Maps. Is my
implementation supposed to use this internal jaxrpc type instead of regular
java.util.Map?

Thanks
Aravind


Mime
View raw message