There are two problems with this fault message:
1- The <SOAP-ENV:Fault> element must be the first and only child element in
the <SOAP-ENV:Body> element. It cannot be a child of the <ns1:SomeFunction>
element. If you want to return the <ns1:SomeFunction> information in the
fault, it must be encoded within the <detail> element.
2- Content in the <detail> message must be namespace qualified. 

-Anne

-----Original Message-----
From: Trevor Porter [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 14, 2004 5:07 PM
To: [EMAIL PROTECTED]
Subject: SAXException trying to deserialize this fault

I'm trying to figure out why Axis throws a SAXException trying to 
deserialize the following SOAP message containing a fault:

<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; 
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/1999/XMLSchema";>
  <SOAP-ENV:Body>
  <ns1:SomeFunction xmlns:ns1="urn:foo">
  <Param1 xsi:type="xsd:string">some value</Param1>
  <Param2 xsi:type="xsd:string">some value</Param2>
    <SOAP-ENV:Fault>
    <faultcode xsi:type="xsd:string">Client</faultcode>
    <faultstring xsi:type="xsd:string">Client request/data 
invalid</faultstring>
      <detail>
      <message xsi:type="xsd:string">some message</message>
      <errorcode xsi:type="xsd:string">-5</errorcode>
      </detail>
    </SOAP-ENV:Fault>
  </ns1:SomeFunction>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The code I'm using:

Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(endpoint);
call.setSOAPActionURI("SomeAction"); 
call.setOperationName(new QName("urn:foo", "SomeFunction"));
call.addParameter("Param1", org.apache.axis.Constants.XSD_STRING, 
javax.xml.rpc.ParameterMode.IN);
call.addParameter("Param2", org.apache.axis.Constants.XSD_STRING, 
javax.xml.rpc.ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING);
String result = (String)call.invoke( new Object[] { "value1", "value2" } );

The exception stack trace that results:

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(SimpleDeseriali
zer.java:149)
        at 
org.apache.axis.encoding.DeserializationContext.startElement(Deserialization
Context.java:1025)
        at 
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:159)
        at 
org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:
1138)
        at 
org.apache.axis.message.RPCElement.deserialize(RPCElement.java:308)
        at org.apache.axis.message.RPCElement.getParams(RPCElement.java:342)
        at org.apache.axis.client.Call.invoke(Call.java:2420)
        at org.apache.axis.client.Call.invoke(Call.java:2319)
        at org.apache.axis.client.Call.invoke(Call.java:1776)
remote exception=org.xml.sax.SAXException: SimpleDeserializer 
encountered a child element, which is NOT expected, in something it was 
trying to deserialize.


Reply via email to