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 Jason Thorn <Ja...@scisys.co.uk> on 2007/07/11 13:08:02 UTC

Web Service operation returning String[] causes org.xml.sax.SAXException

Hi,

 

This is my first time developing a Web Service and I have been stuck on
this problem for 3 days now.

 

I have deployed Tomcat 6.0.13 and Axis 1.4 on a Linux platform.

 

I have been given a WSDL file from a Company that will invoke the Web
Service that I am writing.

 

I used WSDL2Java with the -s option (To generate the Server side
service_impl code).

 

I then wrote my Web Service implementation which extended the
service_impl code and deployed this using the WSDD generated by
WSDL2Java.

 

I then wrote a test Java client which I run on Windows. The majority of
the Web service works as expected until I try to invoke an operation
'getItems' that returns a String[], this causes the following exception:

 

org.xml.sax.SAXException: SimpleDeserializer encountered a child
element, which is NOT expected, in something it was trying to
deserialize.

 

Note that I can invoke an operation that returns an array of a custom
object defined in the WSDL, for example CCVersion[].

 

The relevant part of the WSDL is below:

 

<wsdl:types>

      <s:complexType name="ArrayOfString">

        <s:sequence>

          <s:element minOccurs="0" maxOccurs="unbounded" name="string"
nillable="true" type="s:string" />

        </s:sequence>

      </s:complexType>

 

      <s:element name="getItemsResponse">

        <s:complexType>

          <s:sequence>

            <s:element minOccurs="0" maxOccurs="1" name="getItemsResult"
type="tns:ArrayOfString" />

          </s:sequence>

        </s:complexType>

      </s:element>

</wsdl:types>

 

 

WSDL2Java generated the following WSDD (Only relevant section shown):

 

      <operation name="getItems" qname="operNS:getItems"
xmlns:operNS="http://RheaGroup.com/MoisServices/LibCCService"
returnQName="retNS:getItemsResult"
xmlns:retNS="http://RheaGroup.com/MoisServices/LibCCService"
returnType="rtns:ArrayOfString"
xmlns:rtns="http://RheaGroup.com/MoisServices/LibCCService"
returnItemQName="tns:string"
xmlns:tns="http://RheaGroup.com/MoisServices/LibCCService"
soapAction="http://RheaGroup.com/MoisServices/LibCCService/getItems" >

        <parameter qname="pns:id"
xmlns:pns="http://RheaGroup.com/MoisServices/LibCCService"
type="tns:long" xmlns:tns="http://www.w3.org/2001/XMLSchema"/>

        <parameter qname="pns:item"
xmlns:pns="http://RheaGroup.com/MoisServices/LibCCService"
type="tns:CCItem"
xmlns:tns="http://RheaGroup.com/MoisServices/LibCCService"/>

        <parameter qname="pns:includeDeleted"
xmlns:pns="http://RheaGroup.com/MoisServices/LibCCService"
type="tns:boolean" xmlns:tns="http://www.w3.org/2001/XMLSchema"/>

        <parameter qname="pns:attributes"
xmlns:pns="http://RheaGroup.com/MoisServices/LibCCService"
type="tns:ArrayOfCCAttribute"
xmlns:tns="http://RheaGroup.com/MoisServices/LibCCService"
itemQName="itns:CCAttribute"
xmlns:itns="http://RheaGroup.com/MoisServices/LibCCService"/>

      </operation>

 

      <arrayMapping

        xmlns:ns="http://RheaGroup.com/MoisServices/LibCCService"

        qname="ns:ArrayOfString"

        type="java:java.lang.String[]"

        innerType="cmp-ns:string"

        xmlns:cmp-ns="http://www.w3.org/2001/XMLSchema"

        encodingStyle=""

      />

 

 

WSDL2Java generated the following _impl class (Just the getItems method
shown):

 

    public java.lang.String[] getItems(long id,
gal.gcs.opf.osc.cc.moisccif.libccservice.CCItem item, boolean
includeDeleted, gal.gcs.opf.osc.cc.moisccif.libccservice.CCAttribute[]
attributes) throws java.rmi.RemoteException {

        return null;

    }

 

My client code is as follows:

 

      LibCCServiceLocator srvLocator = new LibCCServiceLocator();

      LibCCServiceSoap_PortType service =
srvLocator.getLibCCServiceSoap(

                                                         new
URL(SERVICE_URL) );

 

      String[] items = service.getItems(sId, ccitem, false, NO_ATTRIBS);

 

It is at this point in the client code that I get the following
exception (I'm not 100% whether this is thrown by the client or the
server):

 

rmtRemoteException SimpleDeserializer encountered a child element, which
is NOT expected, in something it was trying to deserialize.

AxisFault

 faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.userException

 faultSubcode: 

 faultString: org.xml.sax.SAXException: SimpleDeserializer encountered a
child element, which is NOT expected, in something it was trying to
deserialize.

 faultActor: 

 faultNode: 

 faultDetail: 

       {http://xml.apache.org/axis/}stackTrace: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.SimpleListDeserializer.onStartChild(SimpleL
istDeserializer.java:112)

       at
org.apache.axis.encoding.DeserializationContext.startElement(Deserializa
tionContext.java:1035)

       at
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:
165)

       at
org.apache.axis.message.MessageElement.publishToHandler(MessageElement.j
ava: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:2467)

       at org.apache.axis.client.Call.invoke(Call.java:2366)

       at org.apache.axis.client.Call.invoke(Call.java:1812)

       at
gal.gcs.opf.osc.cc.moisccif.libccservice.LibCCServiceSoap_BindingStub.ge
tItems(LibCCServiceSoap_BindingStub.java:1576)

       at
gal.gcs.opf.osc.cc.moisccif.MoisCCIFtestWebClient.main(MoisCCIFtestWebCl
ient.java:75)

 

       {http://xml.apache.org/axis/}hostname:dt04879

 

Has anyone any ideas?