Topic
15 replies Latest Post - ‏2010-03-12T14:15:43Z by BhaveshPatel
SystemAdmin
SystemAdmin
659 Posts
ACCEPTED ANSWER

Pinned topic Exception: org.xml.sax.SAXException: SimpleDeserializer encountered a child element

‏2003-03-28T11:56:46Z |
Hello,

I build a web service similar to Sample 4. It is deployed but whenever I try to call it with the modified Invoke file it brings the following error on method
call.invoke(new Object[] {"text"}).
The error message is:
Exception: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.

Does anyone know what is wrong?

Many thanks in advance

Simone
Updated on 2010-03-12T14:15:43Z at 2010-03-12T14:15:43Z by BhaveshPatel
  • SystemAdmin
    SystemAdmin
    659 Posts
    ACCEPTED ANSWER

    Re: Exception: org.xml.sax.SAXException: SimpleDeserializer encountered a child element

    ‏2003-04-02T10:04:29Z  in response to SystemAdmin
    I found my mistake. I used

    wsdlsoap:binding style="document" ...

    instead of

    wsdlsoap:binding style="rpc" ...

    Simone
    • SystemAdmin
      SystemAdmin
      659 Posts
      ACCEPTED ANSWER

      Re: Exception: org.xml.sax.SAXException: SimpleDeserializer encountered a child element

      ‏2005-03-24T14:52:16Z  in response to SystemAdmin
      Thanks for posting reply yourself! it was indeed useful to me!
    • SystemAdmin
      SystemAdmin
      659 Posts
      ACCEPTED ANSWER

      Re: Exception: org.xml.sax.SAXException: SimpleDeserializer encountered a child element

      ‏2006-04-27T16:01:51Z  in response to SystemAdmin
      Hi,

      I came across the same error in my effort to deploy a stateless web service. Let me describe it more precisely:

      I am actually trying to setup a very simple web service that takes a numerical value (float), representing temperature in Celsius and converts it into Farenheit.
      I am using Globus Toolkit 4 for deployment (which actually uses Axis but a version, previous than 2.1 I think). I encountered problems at neither building the globus archive nor at deploying it in the container. But once the service is running the client that I wrote throws the following error, when trying to access it:



      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.SimpleDeserializer.onStartChild(SimpleDeserializer.java:144)
      at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
      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.providers.java.RPCProvider.processMessage(RPCProvider.java:148)
      at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:319)
      at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
      at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
      at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
      at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:450)
      at org.apache.axis.server.AxisServer.invoke(AxisServer.java:285)
      at org.globus.wsrf.container.ServiceThread.doPost(ServiceThread.java:647)
      at org.globus.wsrf.container.ServiceThread.process(ServiceThread.java:378)
      at org.globus.wsrf.container.ServiceThread.run(ServiceThread.java:281)

      {http://xml.apache.org/axis/}hostname:pc-belltree

      org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
      at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:221)
      at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:128)
      at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
      at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
      at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      at javax.xml.parsers.SAXParser.parse(Unknown Source)
      at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
      at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:645)
      at org.apache.axis.Message.getSOAPEnvelope(Message.java:424)
      at org.apache.axis.message.addressing.handler.AddressingHandler.processClientResponse(AddressingHandler.java:305)
      at org.apache.axis.message.addressing.handler.AddressingHandler.invoke(AddressingHandler.java:110)
      at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
      at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
      at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
      at org.apache.axis.client.AxisClient.invoke(AxisClient.java:190)
      at org.apache.axis.client.Call.invokeEngine(Call.java:2726)
      at org.apache.axis.client.Call.invoke(Call.java:2709)
      at org.apache.axis.client.Call.invoke(Call.java:2385)
      at org.apache.axis.client.Call.invoke(Call.java:2308)
      at org.apache.axis.client.Call.invoke(Call.java:1765)
      at org.diligent.converter.services.impl.Converter.bindings.ConverterPortTypeSOAPBindingStub.celsiusToFarenheit(ConverterPortTypeSOAPBindingStub.java:185)
      at org.diligent.converter.clients.Client.main(Client.java:48)

      ---

      Here is the wsdl file:

      <?xml version="1.0" encoding="UTF-8"?>
      <wsdl:definitions targetNamespace="http://www.diligent.org/namespaces/converter/ConverterService_instance"
      xmlns:apachesoap="http://xml.apache.org/xml-soap"
      xmlns:impl="http://www.diligent.org/namespaces/converter/ConverterService_instance" xmlns:intf="http://www.diligent.org/namespaces/converter/ConverterService_instance"
      xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      name="ConverterService"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <!--WSDL created by Apache Axis version: 1.2.1
      Built on Jun 14, 2005 (09:15:57 EDT)-->
      <wsdl:types>
      <xsd:schema
      targetNamespace="http://www.diligent.org/namespaces/converter/ConverterService_instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:element name="celsiusToFarenheit">
      <xsd:complexType>
      <xsd:sequence>
      <xsd:element name="celsius" type="xsd:float" />
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>
      <xsd:element name="celsiusToFarenheitResponse">
      <xsd:complexType>
      <xsd:sequence>
      <xsd:element name="celsiusToFarenheitReturn"
      type="xsd:float" />
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>
      <xsd:element name="farenheitToCelsius">
      <xsd:complexType>
      <xsd:sequence>
      <xsd:element name="farenheit" type="xsd:float" />
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>
      <xsd:element name="farenheitToCelsiusResponse">
      <xsd:complexType>
      <xsd:sequence>
      <xsd:element name="farenheitToCelsiusReturn"
      type="xsd:float" />
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>
      </xsd:schema>
      </wsdl:types>

      <wsdl:message name="farenheitToCelsiusResponse">

      <wsdl:part element="impl:farenheitToCelsiusResponse"
      name="parameters" />

      </wsdl:message>

      <wsdl:message name="celsiusToFarenheitResponse">

      <wsdl:part element="impl:celsiusToFarenheitResponse"
      name="parameters" />

      </wsdl:message>

      <wsdl:message name="farenheitToCelsiusRequest">

      <wsdl:part element="impl:farenheitToCelsius" name="parameters"/>

      </wsdl:message>

      <wsdl:message name="celsiusToFarenheitRequest">

      <wsdl:part element="impl:celsiusToFarenheit" name="parameters"/>

      </wsdl:message>

      <wsdl:portType name="ConverterPortType">

      <wsdl:operation name="celsiusToFarenheit">

      <wsdl:input message="impl:celsiusToFarenheitRequest"
      name="celsiusToFarenheitRequest" />

      <wsdl:output message="impl:celsiusToFarenheitResponse"
      name="celsiusToFarenheitResponse" />

      </wsdl:operation>

      <wsdl:operation name="farenheitToCelsius">

      <wsdl:input message="impl:farenheitToCelsiusRequest"
      name="farenheitToCelsiusRequest" />

      <wsdl:output message="impl:farenheitToCelsiusResponse"
      name="farenheitToCelsiusResponse" />

      </wsdl:operation>

      </wsdl:portType>

      <wsdl:binding name="ConverterSoapBinding" type="impl:ConverterPortType">

      <wsdlsoap:binding style="rpc"
      transport="http://schemas.xmlsoap.org/soap/http" />

      <wsdl:operation name="celsiusToFarenheit">

      <wsdlsoap:operation soapAction="" />

      <wsdl:input name="celsiusToFarenheitRequest">

      <wsdlsoap:body use="literal" />

      </wsdl:input>

      <wsdl:output name="celsiusToFarenheitResponse">

      <wsdlsoap:body use="literal" />

      </wsdl:output>

      </wsdl:operation>

      <wsdl:operation name="farenheitToCelsius">

      <wsdlsoap:operation soapAction="" />

      <wsdl:input name="farenheitToCelsiusRequest">

      <wsdlsoap:body use="literal" />

      </wsdl:input>

      <wsdl:output name="farenheitToCelsiusResponse">

      <wsdlsoap:body use="literal" />

      </wsdl:output>

      </wsdl:operation>

      </wsdl:binding>

      <wsdl:service name="ConverterService">

      <wsdl:port binding="impl:ConverterSoapBinding"
      name="Converter">

      <wsdlsoap:address
      location="http://localhost:8080/wsrf/services/ConverterService" />

      </wsdl:port>

      </wsdl:service>

      </wsdl:definitions>

      ---

      and the wsdd file:

      ---

      <?xml version="1.0" encoding="UTF-8"?>
      <deployment name="defaultServerConfig"
      xmlns="http://xml.apache.org/axis/wsdd/"
      xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema">

      <service name="metadataBroker/core/singleton/BrokerService" provider="Handler" use="literal" style="document">
      <parameter name="className" value="org.diligent.metadataBroker.services.core.singleton.impl.BrokerService"/>
      <wsdlFile>share/schema/metadataBroker/BrokerService_instance/Broker_service.wsdl</wsdlFile>
      <parameter name="allowedMethods" value="*"/>
      <parameter name="handlerClass" value="org.globus.axis.providers.RPCProvider"/>
      <parameter name="scope" value="Application"/>
      </service>

      </deployment>

      ---

      I already tried changing <wsdlsoap:binding style="document"... to rpc but it didn't work. I also tried upgrading the axis.jar with a newer version but the Globus toolkit is not working with another version. :(
      Any help or a hint to where could the error possibly originate will be greatly appreciated! Thank you in advance!

      petko

      • SystemAdmin
        SystemAdmin
        659 Posts
        ACCEPTED ANSWER

        Re: Exception: org.xml.sax.SAXException: SimpleDeserializer encountered a child element

        ‏2006-04-27T16:18:04Z  in response to SystemAdmin

        sorry, the wsdl file didn't show up correctly. :(
        • SystemAdmin
          SystemAdmin
          659 Posts
          ACCEPTED ANSWER

          Re: Exception: org.xml.sax.SAXException: SimpleDeserializer encountered a child element

          ‏2006-05-21T18:27:15Z  in response to SystemAdmin
          When I encountered this error the problem was due to the server side method signature being invalid.

          The schema defined the message input as single parameter, but the server code had method defined with two parameters (which were the two child elements of what was expected!). This error was not detected at container startup.

          One way to avoid this error is to define your server class to "implement" the stubs... this way you are obliged to have the methods defined as per the schemas. This is not always desirable, as you might have imported schemas which would then require you to have methods for lots of items you don't care about (which is what is the case for me) - but does help avoid silly mistakes.

          Hope this helps - as I know I could not find any error examples to help me when I was trying to solve the problem! ;o)
          • SystemAdmin
            SystemAdmin
            659 Posts
            ACCEPTED ANSWER

            Re: Exception: org.xml.sax.SAXException: SimpleDeserializer encountered a child element

            ‏2006-05-21T18:39:42Z  in response to SystemAdmin
            Sorry for earlier posting - wrong message... wrong forum!s
            This is what I meant to write on this forum:

            It would appear that Axis does not always handle abstract types well.
            I observed the same error as you have described, my solution was to edit the generated java class for the abstract type... and remove the word "abstract" from the class definition. This then allowed the Axis server to instantiate the type... and I could get on with my work.

            This is a work-around. My situation was that I had an abstract type "ViewKind", and two classes that extend this: ClientViewKind and ServerViewKind. I could see that my client was sending a ClientViewKind to the service, a network monitor confirmed that this was still the case on the network layer... but once the service received the request the ClientViewKind type attribute had been lost. Therefore the service attempted to instantiate a ViewKind - which it is not allowed to do, as it is abstract class, so the exception message was generated. I therefore had to add a little hack, which was to define a "description" in the schema, which allowed me to over-specify the type. What the client therefore dispatched was something of the format:

            <viewkind xsi:type=ClientViewKind>
            <description>isClient</description>
            </viewkind>

            What I received service-side was:
            <viewkind>
            <description>isClient</description>
            </viewkind>

            This was enough to allow me to get on with the implementation... as I could first try "instanceof" on the element, if this found no match then I checked description... if this still did not find a match then I knew I had a problem.

            Thus if the Axis level is upgraded later the implementation need not change, as the instanceof will match... and the documentation checks will not be run. Given that my project is dependent on Axis from GT4 I doubt any change to Axis level will happen just yet......

            • * *

            It took me a long time to find the cause. To then produce a solution was quick... so I help that this helps guide others on their quests!
  • SystemAdmin
    SystemAdmin
    659 Posts
    ACCEPTED ANSWER

    Re: Other Solution, upgrade to Axis 1.2.1

    ‏2005-06-16T15:12:09Z  in response to SystemAdmin
    Hi,

    I had the same problem, alas when the client de-serialized the data it got from the server (wrapped literal stlye!)
    Seems the culprit is some buggy code in Axis 1.1 that cannot handle unbounded arrays of "things" - in my case Strings.

    Since June 15. 2005 the final release of AXIS 1.2.1 is available.

    I referred to them instead of the original ones found in WSAD/Eclipse, and VOILA - the exception came up never again!

    greetings
    mike (michael.hauser@brz.gv.at)
    • SystemAdmin
      SystemAdmin
      659 Posts
      ACCEPTED ANSWER

      Re: Other Solution, upgrade to Axis 1.2.1

      ‏2005-08-12T04:12:49Z  in response to SystemAdmin
      Hey Mike
      Can you let me know how to refer to the AXIS 1.2.1 libraries from my WSAD 5.1.2.
      TIA
      • SystemAdmin
        SystemAdmin
        659 Posts
        ACCEPTED ANSWER

        How to refer to the Axis 1.2.1 libraries

        ‏2005-08-12T06:33:13Z  in response to SystemAdmin
        Hi TIA,

        sure. Following Steps:
        1) Download the Axis 1.2.1 from Apache Axis including the sources (so you are able to attach the sources to the *.jars later on when debugging)
        2) create a simple Java project, name it AxisClient.
        3) inside make a folder named /lib; into that you copy everything found in the /lib dir from your axis_1_2_1 download.
        4) in the AxisClient Project - properties I add all the *.jars from the /lib as created in step 3)
        5) additional add the junit.jar from <WSAD_Install_Dir>/eclipse/plugins/org.junit_3.1.8
        and let it use the JRE System Library http://WebSphere V5.1 JRE.
        6) Put the *.wsdl (I name it now myservice.wsdl) into AxisClient as well.
        7) You are able to call WSDL2Java directly via Run. Create a Run Configuration for a Java Application and enter following:
        7a)on the main Tab,
        name it:WSDL2Java
        Project:AxisClient
        main class:org.apache.axis.wsdl.WSDL2Java
        check include external jars ...
        7b)on the Arguments Tab
        Program arguments: -v -p com.yourcompany.webservice.gen -H -t -d "Request" file://C:\YourProjectFolder\workspace\AxisClient\myservice.wsdl
        the Axis documentation gives you more insight about the arguments, in short:
        -v = verbose, so it tells you, what it does
        -p = all generated classes will be mapped to a package com.yourcompany.webservice.gen
        -H creates seperate helper classes for metadata
        -t creates a jUnit Test case -> very convenient!
        -d the scope of the Service, "Request" is the most isolated one
        and as last argument an URI to the WSDL, I show you one using the file-Protocol.
        check the use default working directory
        7c)on JRE tab be sure you use the WAS 5.1 JRE
        7d) default classpath, default source lookup . thats it.
        8) now you are able to generate the Axis Client Classes.
        Have Fun.

        BTW - one is able to use a Websphere Standalone Java Client outside the J2EE Container as well, so you are not
        forced to use an Axis Client. A prerequisite is the upgrade of the WebSphere Test Environment from 5.1.0.3 to 5.1.1.5
        (as it fixes some bugs in webservices.jar and other libraries).

        take care
        yours
        mike
        • SystemAdmin
          SystemAdmin
          659 Posts
          ACCEPTED ANSWER

          Re: How to refer to the Axis 1.2.1 libraries

          ‏2005-08-16T11:46:53Z  in response to SystemAdmin
          Hi Michael
          Voila it works perfectly. Thanks so very much. Can we change the runtime configuration of WSAD from Apache Axis 1.0 to 1.2.1. Just curious to know?
          Regards
          DeveloperFromThirdWorld
          • SystemAdmin
            SystemAdmin
            659 Posts
            ACCEPTED ANSWER

            Axis 1.2.1 inside WAS

            ‏2005-08-16T14:39:18Z  in response to SystemAdmin
            Hi Tia,
            as far as I know there is no way to change the WTE inside WSAD so that the runtime uses the new Axis engine automatically.
            IMHO, IBM will force the use of their own WebServices Engine and neither Axis nor the old IBM SOAP Engine.
            BTW, IBMs Web Services are quite mature now, so there should be no need to use Axis on the Server Side.
            ciao
            mike
  • SystemAdmin
    SystemAdmin
    659 Posts
    ACCEPTED ANSWER

    Re: I meet the same matter when invoke the /wsrf/services/DefaultIndexservice, help me!

    ‏2006-08-18T10:00:56Z  in response to SystemAdmin
    I program to query the value of mds4 from /wsrf/services/DefaultIndexservice. It can work well on console but when I debug the code on Eclipse , It will generate the Exception!
    and I use the same JDK, the version is jdk1.4.2. the version of axis if version1.2.1.
    Is anyone here can help me? On edge for your help! Thank you!
    And my email is 2004amin@gmail.com.
    • SystemAdmin
      SystemAdmin
      659 Posts
      ACCEPTED ANSWER

      Re: I meet the same matter when invoke the /wsrf/services/DefaultIndexservice, help me!

      ‏2006-08-18T10:13:25Z  in response to SystemAdmin
      Hi Amin,

      Apache Axis has quite changed from 1.2.1 to the now actual 1.4. Besides the old axis-versions can no longer be found on the web ;-((
      Try it with Axis 1.4 instead.

      In a previous reply I gave the necessary install instructions (August 2005).

      greetings
      mike
  • SystemAdmin
    SystemAdmin
    659 Posts
    ACCEPTED ANSWER

    Re: Exception: org.xml.sax.SAXException: SimpleDeserializer encountered a child element

    ‏2007-08-31T16:54:25Z  in response to SystemAdmin
    > Hello,
    >
    > I build a web service similar to Sample 4. It is
    > deployed but whenever I try to call it with the
    > modified Invoke file it brings the following error on
    > method
    > call.invoke(new Object[] {"text"}).
    > The error message is:
    > Exception: org.xml.sax.SAXException:
    > SimpleDeserializer encountered a child element, which
    > is NOT expected, in something it was trying to
    > deserialize.
    >
    > Does anyone know what is wrong?
    >
    > Many thanks in advance
    >
    > Simone
    Hi,

    I was facing the same error. In my case I was passing XML as a String like( <type>computer</type> )

    I solved this error by passing the xml in below format.
    ampersand(&)lt; type ampersand(&)gt; computer ampersand(&)lt; /type ampersand(&)gt;

    Nisan
    • BhaveshPatel
      BhaveshPatel
      1 Post
      ACCEPTED ANSWER

      Re: Exception: org.xml.sax.SAXException: SimpleDeserializer encountered a child element

      ‏2010-03-12T14:15:43Z  in response to SystemAdmin
      Thank you Nisan I have resolve my issue by helping ur forum