Generating SOAP Faults from a Web Service

For web services that use SOAP as their message format, the proper way to inform a client about errors encountered while processing an invocation message is to return a SOAP fault. A SOAP fault element may contain one or more detail objects describing the problem encountered.

In a WebLogic Workshop web service, there are three ways for you to create a SOAP fault and return it to the client:

SOAP Faults, Details and XMLBeans

The WSDL file for a web service specifies the types of SOAP faults that may be returned by the web service, including the particular object types that may be included in the SOAP fault detail. WSDL files you receive from external sources and implement as WebLogic Workshop web services may include SOAP fault definitions.

The easiest way to handle SOAP fault detail types is with XMLBeans. If you add a WSDL file to the Schemas project of your application, all of the types defined in the WSDL's schema, including any SOAP fault detail types, will be compiled into XMLBeans. You can use the generated XMLBeans types to create SOAP fault detail objects and use the com.bea.jws.SOAPFaultException API to include the detail objects in SOAP faults you throw.

Related Topics

How Do I: Handle Errors In a Web Service?

JwsContext Interface

com.bea.jws.SoapFaultException