Genivia Home Documentation
SOAP_ENV__Fault Struct Reference

updated Mon Jan 22 2024 by Robert van Engelen
 
SOAP_ENV__Fault Struct Reference

SOAP Fault structure. More...

#include <stdsoap2.h>

Public Attributes

_QName faultcode
 Optional element faultcode of XSD type xsd:QName
 
char * faultstring
 Optional element faultstring of XSD type xsd:string
 
char * faultactor
 Optional element faultactor of XSD type xsd:string
 
struct SOAP_ENV__Detaildetail
 Optional element detail of XSD type SOAP-ENV:Detail
 
struct SOAP_ENV__CodeSOAP_ENV__Code
 Optional element SOAP-ENV:Code of XSD type SOAP-ENV:Code
 
struct SOAP_ENV__ReasonSOAP_ENV__Reason
 Optional element SOAP-ENV:Reason of XSD type SOAP-ENV:Reason
 
char * SOAP_ENV__Node
 Optional element SOAP-ENV:Node of XSD type xsd:string
 
char * SOAP_ENV__Role
 Optional element SOAP-ENV:Role of XSD type xsd:string
 
struct SOAP_ENV__DetailSOAP_ENV__Detail
 Optional element SOAP-ENV:Detail of XSD type SOAP-ENV:Detail
 

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)");
}
struct soap * soap_new()
Allocate and initialize a new soap context.
const char * soap_fault_string(struct soap *soap)
Returns the SOAP Fault string/reason or NULL when absent.
const char * soap_fault_detail(struct soap *soap)
Returns the SOAP Fault detail XML string or NULL when absent.
Context with the engine state.
Definition stdsoap2.h:2883
int error
The soap context soap_status (int) error code of the last operation or #SOAP_OK (zero)
Definition stdsoap2.h:2999
#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
}
void soap_free(struct soap *soap)
Finalize and free the given soap context from unmanaged heap memory.
void soap_end(struct soap *soap)
Delete all data from heap memory managed by the specified soap context and release the freed memory b...
void soap_destroy(struct soap *soap)
Delete all dynamically-allocated C++ objects managed by the specified soap context.
void * fault
Any data of some type T serialized as fault element when its SOAP_TYPE_T is assigned to __type
Definition stdsoap2.h:9638
int __type
Any data of some type T serialized as fault element when its SOAP_TYPE_T is assigned to __type
Definition stdsoap2.h:9636
struct SOAP_ENV__Detail * detail
Optional element detail of XSD type SOAP-ENV:Detail
Definition stdsoap2.h:9606
struct SOAP_ENV__Fault * fault
The soap::fault points to a SOAP_ENV__Fault structure with the SOAP Fault that was received or that c...
Definition stdsoap2.h:3036
// example .h file for soapcpp2
//gsoap ns service name: example
//gsoap ns service namespace: urn:example
struct ns__someElement {
char *text;
};
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(...);
SOAP Fault Detail structure.
Definition stdsoap2.h:9634
// 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;
}
void * soap_malloc(struct soap *soap, size_t len)
Allocate a block of heap memory managed by the specified soap context.
int soap_sender_fault(struct soap *soap, const char *faultstring, const char *faultdetail)
Set SOAP 1.1 client fault / SOAP 1.2 sender fault string and detail.
const char ** soap_faultdetail(struct soap *soap)
Allocates and returns a pointer to the SOAP Fault detail XML string to set this string or NULL when n...
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

◆ detail

struct SOAP_ENV__Detail* SOAP_ENV__Fault::detail

Optional element detail of XSD type SOAP-ENV:Detail

◆ faultactor

char* SOAP_ENV__Fault::faultactor

Optional element faultactor of XSD type xsd:string

◆ faultcode

_QName SOAP_ENV__Fault::faultcode

Optional element faultcode of XSD type xsd:QName

◆ faultstring

char* SOAP_ENV__Fault::faultstring

Optional element faultstring of XSD type xsd:string

◆ SOAP_ENV__Code

struct SOAP_ENV__Code* SOAP_ENV__Fault::SOAP_ENV__Code

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

◆ SOAP_ENV__Detail

struct SOAP_ENV__Detail* SOAP_ENV__Fault::SOAP_ENV__Detail

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

◆ SOAP_ENV__Node

char* SOAP_ENV__Fault::SOAP_ENV__Node

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

◆ SOAP_ENV__Reason

struct SOAP_ENV__Reason* SOAP_ENV__Fault::SOAP_ENV__Reason

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

◆ SOAP_ENV__Role

char* SOAP_ENV__Fault::SOAP_ENV__Role

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