My classes
public class MyService {
public MyDescriptor[] getDescriptors() {
...
}
}
public class MyDescriptor {
private String _field1;
private String _field2;
...
public String getField1() {
return _field1;
}
...
}
From my deploy.wsdd:
<service name="MyService" provider="java:RPC"
style="wrapped" use="literal">
<parameter name="wsdlTargetNamespace"
value="http://www.schuerig.de/verzeichnisservice"/>
<parameter name="wsdlServiceElement" value="VerzeichnisService"/>
<parameter name="wsdlServicePort" value="VerzeichnisPort"/>
<parameter name="className"
value="de.schuerig.verzeichnisservice.ws.JaxRpcVerzeichnisService"/>
<parameter name="wsdlPortType" value="VerzeichnisPortType"/>
<operation name="getDescriptors"
xmlns:operNS="http://www.schuerig.de/myservice"
qname="operNS:getDescriptors"
returnQName="descriptors"
soapAction="getDescriptors">
</operation>
<beanMapping
xmlns:ns="http://www.schuerig.de/myservice"
qname="ns:descriptor"
languageSpecificType="java:de.schuerig.myservice.MyDescriptor"/>
...
The relevant portion of the generated WSDL looks like this
<element name="getDescriptorsResponse">
<complexType>
<sequence>
<element maxOccurs="unbounded" name="descriptors"
type="impl:myDescriptor"/>
</sequence>
</complexType>
</element>
<complexType name="myDescriptor">
<sequence>
<element name="field1" nillable="true" type="xsd:string"/>
<element name="field2" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
This already looks fishy. The "descriptors" name doesn't really apply to
the single items in the sequence, but only to the enclosing complexType
as a whole.
Now, when I call the service, in the SOAP body I get this
<soapenv:Body>
<getDescriptorsResponse xmlns="">
<descriptors>
<item>
<field1>...</field1>
<field2>...</field2>
</item>
<item>
...
</item>
...
</descriptors>
</getDescriptorsResponse>
</soapenv:Body>
which is pretty much what I want, despite my misgivings about the WSDL.
What I really don't want, though, is the exception I get when I run the
generated TestCase
org.xml.sax.SAXException: Invalid element in
de.schuerig.www.verzeichnisservice.VerzeichnisDeskriptor - item
at
org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:223)
at
org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1031)
at
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at
org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1140)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:238)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:386)
at org.apache.axis.client.Call.invoke(Call.java:2402)
at org.apache.axis.client.Call.invoke(Call.java:2301)
at org.apache.axis.client.Call.invoke(Call.java:1758)
As far as I understand it, the cause of the problem is how arrays are
handled here. Axis tries to deserialize the entire return value with a
BeanSerializer, which can't work. The BeanSerializer applies only to
single item-elements whereas the enclosing return ought to be handled
by an ArrayDeserializer.
To me it appears as if Axis is mixing up the types of arrays and their
elements. Preferably, I hope to be told that the error is on my part
and that I only need to specify slightly differently what I want in
order to get it.
Michael
--
Michael Schuerig Nothing is as brilliantly adaptive
mailto:[EMAIL PROTECTED] as selective stupidity.
http://www.schuerig.de/michael/ --A.O. Rorty, The Deceptive Self