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 jay dude <ja...@yahoo.com> on 2005/01/05 11:13:36 UTC
typemapping issue, debugged axis code for hours..
Hi,
I've spent ~15 hours trying to solve my problem, so
any help is _greatly_ appreciated!
I'm using Axis 1.2RC2. (a perl server, and axis
client)
I have a WSDL, which I then generate code from using
wsdl2java. The WSDL of interest is listed below:
------------
<types>
<xsd:schema
targetNamespace="ARDOME/SOAP/usermgrapi">
<xsd:complexType name="namelist">
<xsd:sequence>
<xsd:element name="name"
minOccurs="0" maxOccurs="unbounded"
type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
[snip]
<message name="getUserListRequest">
<part name="groupname" type="xsd:string"/>
<part name="refresh" type="xsd:boolean"/>
</message>
<message name="getUserListResponse">
<part name="users" type="typens:namelist"/>
</message>
------------
The code generated looks good, a class Namelist.java
is generated.
To map the response to Namelist, I've added the
following typemapping (in client-config.wsdd):
------------
<?xml version="1.0" encoding="UTF-8"?>
<deployment name="defaultClientConfig"
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/">
<transport name="http"
pivot="java:org.apache.axis.transport.http.HTTPSender"/>
<typeMapping
xmlns:ns="ARDOME/SOAP/usermgrapi"
qname="ns:namelist"
type="java:se.ardendo.ardjavaapi.usermgrapi.Namelist"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
/>
</deployment>
------------
My problem is that I constantly get:
------------
org.xml.sax.SAXException: Bad types (class
[Ljava.lang.Object; -> class
se.ardendo.ardjavaapi.usermgrapi.Namelist)
------------
I've debugged the code, and the code that fails is:
------------
// If we have an xsi:type, make sure
it makes sense
// with the current paramDesc type
Class xsiClass =
context.getTypeMapping().getClassForQName(type);
if (null != xsiClass &&
!JavaUtils.isConvertable(xsiClass, destClass)) {
throw new SAXException("Bad
types (" +
xsiClass
+ " -> " + destClass + ")"); // FIXME!
}
------------
where the variable type is "Array", and destClass is
"se.ardendo.ardjavaapi.usermgrapi.Namelist" (Which is
why it doesn't work..)
The actual request/response is here:
------------
POST /soap/usermgrapi.fcgi HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime,
multipart/related, text/*
User-Agent: Axis/1.1
Host: ardomedev
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "ARDOME/SOAP/usermgrapi/getUserList"
Content-Length: 514
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:getUserList
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="ARDOME/SOAP/usermgrapi">
<groupname xsi:type="xsd:string">admin</groupname>
<refresh xsi:type="xsd:boolean">false</refresh>
</ns1:getUserList>
</soapenv:Body>
</soapenv:Envelope>HTTP/1.1 200 OK
Date: Tue, 04 Jan 2005 09:10:48 GMT
Server: Apache/1.3.27 (Unix) mod_fastcgi/2.4.0
Content-Length: 1231
SOAPServer: SOAP::Lite/Perl/0.55
Connection: close
Content-Type: text/xml; charset=utf-8
response:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:namesp4="ARDOME/SOAP/usermgrapi"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body><
namesp5:getUserListResponse
xmlns:namesp5="ARDOME/SOAP/usermgrapi">
<users SOAP-ENC:arrayType="xsd:string[15]"
xsi:type="namesp4:namelist">
<name xsi:type="xsd:string">admin</name><name
xsi:type="xsd:string">andreas</name><name
xsi:type="xsd:string">ardaafclient</name><name
xsi:type="xsd:string">ardendo</name><name
xsi:type="xsd:string">henrik</name><name
xsi:type="xsd:string">johanna</name><name
xsi:type="xsd:string">jonas</name><name
xsi:type="xsd:string">kan</name><name
xsi:type="xsd:string">markusj</name><name
xsi:type="xsd:string">mortis</name><name
xsi:type="xsd:string">parham</name><name
xsi:type="xsd:string">parham2</name><name
xsi:type="xsd:string">pengpeng</name><name
xsi:type="xsd:string">tobias</name><name
xsi:type="xsd:string">ximena</name>
</users>
</namesp5:getUserListResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
------------
I do not understand why it doesn't take my mapping,
and maps the xml to the Namelist class?
The code that sets the type above to Array is this:
------------
// If there's an arrayType attribute, we
can pretty well guess that we're an Array???
if
(attributes.getValue(Constants.URI_DEFAULT_SOAP_ENC,
Constants.ATTR_ARRAY_TYPE) != null) {
typeQName = Constants.SOAP_ARRAY;
}
------------
The questionmarks in the end doesn't feel very good.
;)
I got it to work, by changing the complex type in the
wsdl to a specific Array (now it maps to a String[]
instead of a Namelist):
------------
<xsd:complexType name="namelist">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<xsd:sequence>
<xsd:element name="name"
minOccurs="0" maxOccurs="unbounded"
type="xsd:string"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
------------
But, when doing that it didn't work from .NET, which
is also a must.
Please email me any comments or questions to
tobias[at]ardendo[dot]se!
Best regards, and with the hope for help,
Tobias Vesterlund.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com