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 Patrick van Kann <pa...@fortune-cookie.com> on 2005/03/29 14:30:14 UTC

Invalid XML returned by Castor Serializer

Has anyone used the Castor serializers for webservice methods that return typed arrays?

I have a method in a wrapped style webservice that returns an array of TestData objects which I based on the classic example available at http://www-106.ibm.com/developerworks/webservices/library/ws-castor/

The method has the following signature
public com.fc.timesheet.data.TestData[] getTestsAsArray()

In my schema, I have defined the response as follows:
<xsd:element name="getTestsAsArrayResponse">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element maxOccurs="unbounded" ref="tns2:testData"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

My generated deploy.wsdd contains after running Java2WSDL:
<operation 
  name="getTestsAsArray" 
  qname="operNS:getTestsAsArray" 
  xmlns:operNS="http://www.fortune-cookie.com/schemas/services/timesheet/wsdl" 
  returnQName="retNS:testData[,unbounded]" 
  xmlns:retNS="http://www.fortune-cookie.com/schemas/services/timesheet/data" 
  returnType="rtns:testData" 
  xmlns:rtns="http://www.fortune-cookie.com/schemas/services/timesheet/data" 
  soapAction="" >
</operation>

and of course typeMappings that I changed to use the Castor serializer/deserializer.

I called the webservice method using the generated SOAPBindingStub via HTTPTrace and received the following response
<?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>
    <getTestsAsArrayResponse 
      xmlns="http://www.fortune-cookie.com/schemas/services/timesheet/wsdl">
      <ns1:testData[,unbounded] 
	    xsi:type="testData" 
	    xmlns:ns1="http://www.fortune-cookie.com/schemas/services/timesheet/data">
	    <name xmlns="">test1</name>
      </ns1:testData[,unbounded]>
    </getTestsAsArrayResponse>
  </soapenv:Body>
</soapenv:Envelope>

However, I get the following exception during de-serialization of this response on the client side
[java] org.xml.sax.SAXParseException: Element type "ns1:testData" must be followed by either attribute specifications, ">" or "/>".

It seems to me that the [,unbounded] part of the ns1:testData element is invalid XML. This seems to be as a result of the returnQName attribute in deploy.wsdd.

Does anyone know what I am doing wrong? Are there any examples of handling typed arrays for document/wrapped webservices using Castor?

Thanks in advance,

Patrick