1

I have SEI Class which throws an exception that is declared in WSDL file. During processing when this exception is thrown the SOAP Fault is sent to the client successfully. There is no problem here. However, when we encounter any runtime exceptions in the server during processing we create a custom Fault and Throw the same from the SEI Class. Since this Custom Fault is not declared in the SEI, we have added the Fault Class to extend RuntimeException. However, when this Custom Fault is thrown from the application code, the Websphere application server does not return the SOAP Fault to the Client. Instead it throws an exception and Http error code 500 is sent to the client. Is there a way to send the Custom Fault message to the client without declaring the same in WSDL.

My WebMethod:

public CustomerDetails enquireCustomer(Customer customer)
        throws CustomerFault
{
    try
    {
       // SOME LOGIC HERE
    }
    catch (Exception exception)
    {
        if (exception instanceof CustomerFault)
        throw ((CustomerFault) exception );

        if (localException instanceof CustomerFault)
        {
        FaultDetails faultDetails = new FaultDetails();
        faultDetails.setErrorId(1);
        faultDetails.setErrorDescription(errorDescription);
        throw new CustomerFault("Failed in Processing and other details here... ", faultDetails);
        }
    }
        }

My Fault Class

import javax.xml.ws.WebFault;
@WebFault(name="CustomerFault", targetNamespace="http://www.mycompany.com")
public class CustomerFault extends RuntimeException 
{
    private static final long serialVersionUID = 1L;
    private FaultDetails faultDetails;
    public ServiceExecutionFault(String message, FaultDetails faultDetails) {
        super(message);
        this.faultDetails = faultDetails;
    }

    public ServiceExecutionFault(String message)
    {
    super(message);
    }
    public ServiceExecutionFault(String message, FaultDetails faultDetails, 
           Throwable cause) {
        super(message, cause);
        this.faultDetails = faultDetails;
    }
    public FaultDetails getFaultInfo() {
        return faultDetails;
    }
}

This issue seems to be there in Websphere alone. When tried in weblogic the same works fine without any issue. Is there any standard which I am missing here.

Sandeep Salian
  • 341
  • 2
  • 8

1 Answers1

1

Found the answer here :

JAX-WS server-side SOAPHandler that returns fault gets "Internal Error" on WebSphere v8

By disabling the unified fault handling in websphere this worked fine. Add the following JVM property.

-Dwebservices.unify.faults=false

This can be set from admin console :

Server -> Server Type -> Websphere Application Server -> Process Definition -> Java Virtual Machine -> Custom Properties

Screenshot

Somnath Musib
  • 3,548
  • 3
  • 34
  • 47
Sandeep Salian
  • 341
  • 2
  • 8