|  | Home | Documentation | SOAP_ENV__Fault Struct Reference updated Mon Apr 22 2024 by Robert van Engelen |

- Main Page
- Modules
- Classes
- Files

- Class List
- Class Members

Public Attributes | List of all members
SOAP_ENV__Fault Struct Reference
Fault structure and functions

SOAP Fault structure. More...

## Public Attributes
_QName | faultcode
| Optional element `faultcode` of XSD type `xsd:QName` More...
char * | faultstring
| Optional element `faultstring` of XSD type `xsd:string` More...
char * | faultactor
| Optional element `faultactor` of XSD type `xsd:string` More...
struct SOAP_ENV__Detail * | detail
| Optional element `detail` of XSD type `SOAP-ENV:Detail` More...
struct SOAP_ENV__Code * | SOAP_ENV__Code
| Optional element `SOAP-ENV:Code` of XSD type `SOAP-ENV:Code` More...
struct SOAP_ENV__Reason * | SOAP_ENV__Reason
| Optional element `SOAP-ENV:Reason` of XSD type `SOAP-ENV:Reason` More...
char * | SOAP_ENV__Node
| Optional element `SOAP-ENV:Node` of XSD type `xsd:string` More...
char * | SOAP_ENV__Role
| Optional element `SOAP-ENV:Role` of XSD type `xsd:string` More...
struct SOAP_ENV__Detail * | SOAP_ENV__Detail
| Optional element `SOAP-ENV:Detail` of XSD type `SOAP-ENV:Detail` More...

## Detailed Description

SOAP Fault structure.

This structure is generated by the wsdl2h tool from a WSDL with SOAP Fault definitions and/or by soapcpp2 to complete the SOAP Fault definitions. The SOAP Fault definitions can also be specified manually in the interface header file for soapcpp2. If no SOAP Fault structure is declared in the interface header file input to soapcpp2 then the soapcpp2 tool will generate an empty structure.

A SOAP Fault contains error information specified by the `SOAP_ENV__Fault::faultstring` (SOAP 1,1) or `SOAP_ENV__Fault::SOAP_ENV__Reason` (SOAP 1.2). The SOAP Fault detail `SOAP_ENV__Fault::SOAP_ENV__Detail` may include specific elements related to the fault.

The `SOAP_ENV__Detail` sub-structure of a SOAP Fault is customizable with members that are part of a SOAP Fault that is specific to a service operation. This structure is generated and populated by wsdl2h with service-specific SOAP Fault details. The `//gsoap <prefix> service method-fault:` directive indicates which member (i.e. XML element) of `SOAP_ENV__Detail` is relevant to the SOAP Faults associated with a service operation.

Because the `SOAP_ENV__Detail` substructure is declared `mutable` (which is a C/C++ extension that only soapcpp2 understands), multiple `struct SOAP_ENV__Detail` structures in the interface header file input are combined into one structure generated by soapcpp2 for C/C++ compilation.

Examples:

#include "soapH.h"
struct soap *soap = soap_new();
... // call a Web service here
if (soap->error)
{
const char *s = soap_fault_string(soap);
const char *d = soap_fault_detail(soap);
printf("Server fault: %s detail: %s\n", s, d ? d : "(none)");
}
#include "soapH.h"
struct soap *soap = soap_new();
... // context initializations
if (soap_call_ns__webmethod(soap, endpoint, NULL, ...))
{
if (soap->fault->detail && soap->fault->detail->__type == SOAP_TYPE_ns__someElement)
{
struct ns__someElement *element = (struct ns__someElement*)soap->fault->detail->fault;
... // inspect the SOAP Fault detail element
}
}
else
{
... // success
}
soap_destroy(soap);
soap_end(soap);
soap_free(soap);
// example .h file for soapcpp2
//gsoap ns service name: example
//gsoap ns service namespace: urn:example
struct ns__someElement {
char *text;
};
struct SOAP_ENV__Detail {
char *__any;
int __type;
void *fault;
struct ns__someElement *ns__someElement; // a service-operation specific fault detail
};
//gsoap ns service method-fault: webmethod ns__someElement
int ns__webmethod(...);
// example service implementation based on the above example .h file for soapcpp2
#include "soapH.h"
int main()
{
struct soap *soap = soap_new();
... // serve requests with soap_bind, soap_accept, soap_ssl_accept, and soap_serve
}
int ns__webmethod(struct soap *soap, ...)
{
int err = soap_sender_fault(soap, "Invalid request", NULL, NULL); // this is a sender fault to return to the client
soap_faultdetail(soap); // allocate SOAP Fault detail
soap->fault->detail->ns__someElement = (struct ns__someElement*)soap_malloc(soap, sizeof(struct ns__someElement));
soap_default_ns__someElement(soap, soap->fault->detail->ns__someElement);
soap->fault->detail->ns__someElement->text = "...";
#if 0
// an alternative way to include the ns__someElement in the SOAP Fault detail can be done as follows:
soap->fault->detail->__type = SOAP_TYPE_ns__someElement;
soap->fault->detail->fault = (void*)soap_malloc(soap, sizeof(struct ns__someElement));
soap_default_ns__someElement(soap, (struct ns__someElement*)soap->fault->detail->fault);
((struct ns__someElement*)soap->fault->detail->fault)->text = "...";
#endif
return err;
}

See also
  `SOAP_CLI_FAULT`, `SOAP_SVR_FAULT`, `soap::fault`, `soap_sender_fault`, `soap_sender_fault_subcode`, `soap_receiver_fault`, `soap_receiver_fault_subcode`, `soap_print_fault`, `soap_stream_fault`, `soap_sprint_fault`, `soap_print_fault_location`, `soap_stream_fault_location`, `soap_fault_string`, `soap_fault_subcode`, `soap_fault_detail`, `soap::lang`.

## Member Data Documentation

struct SOAP_ENV__Detail* SOAP_ENV__Fault::detail

Optional element `detail` of XSD type `SOAP-ENV:Detail`

char* SOAP_ENV__Fault::faultactor

Optional element `faultactor` of XSD type `xsd:string`

_QName SOAP_ENV__Fault::faultcode

Optional element `faultcode` of XSD type `xsd:QName`

char* SOAP_ENV__Fault::faultstring

Optional element `faultstring` of XSD type `xsd:string`

struct SOAP_ENV__Code* SOAP_ENV__Fault::SOAP_ENV__Code

Optional element `SOAP-ENV:Code` of XSD type `SOAP-ENV:Code`

struct SOAP_ENV__Detail* SOAP_ENV__Fault::SOAP_ENV__Detail

Optional element `SOAP-ENV:Detail` of XSD type `SOAP-ENV:Detail`

char* SOAP_ENV__Fault::SOAP_ENV__Node

Optional element `SOAP-ENV:Node` of XSD type `xsd:string`

struct SOAP_ENV__Reason* SOAP_ENV__Fault::SOAP_ENV__Reason

Optional element `SOAP-ENV:Reason` of XSD type `SOAP-ENV:Reason`

char* SOAP_ENV__Fault::SOAP_ENV__Role

Optional element `SOAP-ENV:Role` of XSD type `xsd:string`