1 Reply Latest reply on Oct 7, 2005 5:27 PM by Alejandro Guizar

    Custom fault not recognized at the client side

    Alejandro Guizar Master

      I'm working in replying fault messages to clients of a service published by a jBPM BPEL process. I can't figure out a deserialization problem with a SOAP Fault on the client side. I am using JBoss 4.0.2.

      My service writes fault envelopes like this one:

      <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>
       <soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <faultcode>soapenv:Client</faultcode>
       <faultstring>Business Process Fault</faultstring>
       <detail>
       <types:operationFault xmlns:ns0="urn:samples:atm:types" xmlns:types="urn:samples:atm:types">
       <code>100</code>
       <description>not enough funds</description>
       </types:operationFault>
       </detail>
       </soapenv:Fault>
       </soapenv:Body>
      </soapenv:Envelope>


      The relevant WSDL and XS definitions are:
      <definitions targetNamespace="urn:samples:atm"
       xmlns:tns="urn:samples:atm"
       xmlns:types="urn:samples:atm:types">
      
       <types>
       <schema targetNamespace="urn:samples:atm:types"
       xmlns="http://www.w3.org/2001/XMLSchema">
      
       <element name="operationFault">
       <complexType>
       <sequence>
       <element name="code" type="int"/>
       <element name="description" type="string"/>
       </sequence>
       </complexType>
       </element>
      
       </schema>
       </types>
      
       <message name="operationFault">
       <part name="fault" element="types:operationFault"/>
       </message>
      
       <portType name="atm">
       <operation name="withdraw">
       <input message="tns:operationRequest"/>
       <output message="tns:operationResponse"/>
       <fault name="notEnoughFunds" message="tns:operationFault"/>
       </operation>
       </portType>
      
      </definitions>


      The Java classes and mappings are generated using wscompile.

      package org.jbpm.bpel.tutorial.atm.types;
      
      public class OperationFault extends java.lang.Exception {
       private int code;
       private java.lang.String description;
      
       public OperationFault(int code, java.lang.String description) {
       super(description);
       this.code = code;
       this.description = description;
       }
      
       public int getCode() {
       return code;
       }
      
       public java.lang.String getDescription() {
       return description;
       }
      }
      
      <java-xml-type-mapping>
       <java-type>org.jbpm.bpel.tutorial.atm.types.OperationFault</java-type>
       <root-type-qname xmlns:typeNS="urn:samples:atm:types">typeNS:operationFault</root-type-qname>
       <qname-scope>complexType</qname-scope>
       <variable-mapping>
       <java-variable-name>code</java-variable-name>
       <xml-element-name>code</xml-element-name>
       </variable-mapping>
       <variable-mapping>
       <java-variable-name>description</java-variable-name>
       <xml-element-name>description</xml-element-name>
       </variable-mapping>
      </java-xml-type-mapping>
      
      <exception-mapping>
       <exception-type>org.jbpm.bpel.tutorial.atm.types.OperationFault</exception-type>
       <wsdl-message xmlns:exMsgNS="urn:samples:atm">exMsgNS:operationFault</wsdl-message>
       <constructor-parameter-order>
       <element-name>code</element-name>
       <element-name>description</element-name>
       </constructor-parameter-order>
      </exception-mapping>


      The consumer is a J2EE application client. The problem is that the fault gets mapped and thrown as an AxisFault instead of the custom exception class. Here is the log output at the client side.
      11:31:36,140 DEBUG Call : Mapping Exception to AxisFault
      AxisFault
      faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
      faultSubcode:
      faultString: Business Process Fault
      faultActor:
      faultNode:
      faultDetail:
      {urn:samples:atm:types}operationFault:
      <code>100</code>
      <description>not enough funds</description>
      org.jboss.axis.AxisFault: Business Process Fault
      at org.jboss.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:303)
      at org.jboss.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:142)
      at org.jboss.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1249)
      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(SAXParser.java:375)
      at org.jboss.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:257)
      at org.jboss.axis.MessagePart.getAsSOAPEnvelope(MessagePart.java:684)
      at org.jboss.axis.Message.getSOAPEnvelope(Message.java:428)
      at org.jboss.axis.client.Call.invokeEngine(Call.java:3077)
      at org.jboss.axis.client.Call.invoke(Call.java:3039)
      at org.jboss.axis.client.Call.invoke(Call.java:2629)
      at org.jboss.axis.client.Call.invoke(Call.java:2538)
      at org.jboss.axis.client.Call.invokeInternal(Call.java:1976)
      at org.jboss.axis.client.Call.invoke(Call.java:1914)
      at org.jboss.webservice.client.CallImpl.invoke(CallImpl.java:265)
      at org.jboss.axis.client.AxisClientProxy.invoke(AxisClientProxy.java:381)
      at $Proxy2.withdraw(Unknown Source)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.webservice.client.PortProxy.invoke(PortProxy.java:105)
      at $Proxy3.withdraw(Unknown Source)
      at org.jbpm.bpel.tutorial.atm.AtmTest.testAtmSimpleScenario(AtmTest.java:77)


      Apart from this problem, the endpoint works fine. Any clues on why this fault is not recognized by the client?

      Tnx