SophiaFramework UNIVERSE 5.3 |
#include <SFXSOAPParser.hpp>
class SFXSOAPParser : public SFXXMLDOMParser;
SFMTYPEDEFCLASS(SFXSOAPParser)
The SFXSOAPParser parses a SOAP message using the DOM method by inheriting from the SFXXMLDOMParser class.
About Simple Object Access Protocol (SOAP) | |
---|---|
W3C SOAP updated information: Latest SOAP versions (SOAP 1.1 and SOAP 1.2 are supported. However, SOAP Attachment is not implemented and only SOAP Fault of SOAP 1.1 is supported.) |
Example 836. SOAP message to be parsed("soapmessage.xml")
<?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" > <env:Header> <SubscriptionInfo xmlns="http://schemas.xmlsoap.org"> <LicenseStatusCode>0</LicenseStatusCode> <LicenseStatus>Valid license key</LicenseStatus> <LicenseActionCode>0</LicenseActionCode> <LicenseAction>Decremented hit count</LicenseAction> <RemainingHits>18</RemainingHits> <Amount>0</Amount> </SubscriptionInfo> </env:Header> <env:Body> <m:GetLastTradePriceResponse env:encodingStyle="http://www.w3.org/2003/05/soap-envelope" xmlns:m="http://example.org/2001/06/quotes"> <Price>34.5</Price> </m:GetLastTradePriceResponse> <m:GetLastTradePriceResponse env:encodingStyle="http://www.w3.org/2003/05/soap-envelope" xmlns:m="http://example.org/2006/06/quotes"> <Price>56.5</Price> </m:GetLastTradePriceResponse> </env:Body> </env:Envelope>
Example 837. The method to parse the SOAP message using the SFXSOAPParser class
SFXSOAPParser soapparser; // SOAP parser // read and parse the SOAP message from the "soapmessage.xml" file if (soapparser.Parse("soapmessage.xml") != SFERR_NO_ERROR) { // display error value TRACE("error id = 0x%x", soapparser.static_catch()); // display error message TRACE(soapparser.GetErrorInfo()); } else { // processing after parsing the SOAP message // display version of SOAP message TRACE("soap version : %d", soapparser.GetSoapVersion()); // "soap version : 1" will be displayed (because it is SFXSOAPParser::SOAP_VERSION_1_2) // get Envelope element SFXXMLElementPtr envelope = soapparser.GetEnvelope(); // display namespace of Envelope element TRACE("envelope version : %s", envelope->GetNamespaceURI()); // "envelope version: http://www.w3.org/2003/05/soap-envelope" will be displayed // get Header element SFXXMLElementPtr header = soapparser.GetHeader(); // display namespace of Header element TRACE("header version : %s", header->GetNamespaceURI()); // "header version: http://www.w3.org/2003/05/soap-envelope" will be displayed // get all child elements of Header element SFXXMLNode::DOMNodeListPtr list = soapparser.GetHeaderEntries(); // display number of the elements TRACE("entry number : %d", list->GetSize()); // "entry number : 1" will be displayed // get "SubscriptionInfo" element included in Header element SFXXMLElementPtr entry = soapparser.GetHeaderEntry("SubscriptionInfo", "http://schemas.xmlsoap.org"); // get all child element of "SubscriptionInfo" element list = entry->GetChildNodes(); // get enumerator SFXXMLNode::DOMNodeList::Enumerator childEtor = list->GetFirstEnumerator(); while (childEtor.HasNext()) { SFXXMLElementPtr current = static_cast<SFXXMLElementPtr>(childEtor.GetNext()); // display name of each element TRACE("current element name : %s", current->GetName()); // e.g. "current element name : LicenseStatusCode" will be displayed // display text of each element TRACE("current element content : %s", current->GetText().GetCString()); // e.g. "current element content : 0" will be displayed } // get Body element SFXXMLElementPtr body = soapparser.GetBody(); // display namespace of Body element TRACE("body version : %s", body->GetNamespaceURI()); // "body version : http://www.w3.org/2003/05/soap-envelope" will be displayed // get all child element of Body element list = soapparser.GetBodyEntries(); // display number of the elements TRACE("entry number: %d", list->GetSize()); // "2" will be displayed // get enumerator childEtor = list->GetFirstEnumerator(); while (childEtor.HasNext()) { SFXXMLElementPtr current = static_cast<SFXXMLElementPtr>(childEtor.GetNext()); // display content of each element TRACE("current element name : %s", current->GetLocalName()); // e.g. "current element name : GetLastTradePriceResponse" will be displayed // display namespace of each element TRACE("current element namespace : %s", current->GetNamespaceURI()); // e.g. "current element namespace : http://example.org/2001/06/quotes" will be displayed // display text(price) of each element TRACE("price : %s", current->GetText().GetCString()); // e.g. "price : 34.5" will be displayed } }
Constructor/Destructor |
---|
SFXSOAPParser( Void ) Constructor of the SFXSOAPParser class.
|
~SFXSOAPParser( Void ) Destructor of the SFXSOAPParser class.
|
Public Functions | |
---|---|
SFXXMLElementPtr |
GetBody( Void ) Get the Body element of the SOAP document.
|
SFXXMLNode::DOMNodeListPtr |
GetBodyEntries( Void ) Get all child elements of the Body element of the SOAP message.
|
SFXXMLElementPtr |
GetBodyEntry(
SFXAnsiStringConstRef local
, SFXAnsiStringConstRef uri = SFXAnsiString::EmptyInstance()
) Get the specified element in the Body element of the SOAP message.
|
SFXXMLElementPtr |
GetEnvelope( Void ) Get the Envelope element of the SOAP message.
|
SFXXMLElementPtr |
GetFault( Void ) Get the SOAP Fault element.
|
SFXXMLElementPtr |
GetFaultActor( Void ) Get the faultactor element of the SOAP Fault element.
|
SFXXMLElementPtr |
GetFaultCode( Void ) Get the faultcode element of the SOAP Fault element.
|
SFXXMLElementPtr |
GetFaultDetail( Void ) Get the detail element of the SOAP Fault element.
|
SFXXMLElementPtr |
GetFaultString( Void ) Get the faultstring element of the SOAP fault element.
|
SFXXMLElementPtr |
GetHeader( Void ) Get the Header element of the SOAP message.
|
SFXXMLNode::DOMNodeListPtr |
GetHeaderEntries( Void ) Get all the child elements of the Header element of the SOAP message.
|
SFXXMLElementPtr |
GetHeaderEntry(
SFXAnsiStringConstRef local
, SFXAnsiStringConstRef uri = SFXAnsiString::EmptyInstance()
) Get the specified element among the Header elements of the SOAP message.
|
SFXXMLElementPtr |
GetRPCParameter(
SFXAnsiStringConstRef local
, SFXAnsiStringConstRef uri = SFXAnsiString::EmptyInstance()
) Get the element among the Body elements of the SOAP message that matches the specified parameter.
|
SFXXMLElementPtr |
GetRPCResult( Void ) Get the first child of the first child of the Body element of the SOAP message.
|
SFXXMLElementPtr |
GetRPCStruct( Void ) Get the first child element of the Body element of the SOAP message.
|
SOAP_VERSION |
GetSoapVersion( Void ) Get the version of the SOAP message.
|
SFCError |
Parse(
SFBFileSmpConstRef source
) Parse the SOAP message using the DOM parser.
|
SFCError |
Parse(
SFXAnsiStringConstRef source
) Parse the SOAP message using the DOM parser.
|
SFCError |
Parse(
SFXPathConstRef source
) Parse the SOAP message using the DOM parser.
|
SFCError |
Parse(
SFXStreamReaderConstRef source
) Parse the SOAP message using the DOM parser.
|
Void |
Reset( Void ) Reset all the internal variables
|
Bool |
GetCreateCommentNodes( Void )
(inherits from SFXXMLDOMParser)
Check whether or not to create Comment nodes.
|
Bool |
GetDoIndent( Void )
(inherits from SFXXMLDOMParser)
Check whether or not to indent.
|
Bool |
GetDoNamespaces( Void )
(inherits from SFXXMLDOMParser)
Check whether or not to process namespace.
|
Bool |
GetDoSchema( Void )
(inherits from SFXXMLDOMParser)
Check whether or not to process the XML Schema.
|
SFXXMLDocumentPtr |
GetDocument( Void )
(inherits from SFXXMLDOMParser)
Get the Document node.
|
ACharConstPtr |
GetErrorInfo( Void )
(inherits from SFXXMLDOMParser)
Get the internal error message.
|
static SFXXMLElementPtr |
GetFirstChildElement(
SFXXMLNodeConstPtr parent
)
(inherits from SFXXMLDOMParser)
Get the first child Element node of the specified node.
|
static SFXXMLElementPtr |
GetFirstChildElementNS(
SFXXMLNodeConstPtr parent
, SFXAnsiStringHandleConst elemNames
, SFXAnsiStringConstRef uri
, SInt32 length
)
(inherits from SFXXMLDOMParser)
Get the first child Element node of the specified node, which matches the namespace URI and one of the local names specified.
|
Bool |
GetIgnoreAnnotations( Void )
(inherits from SFXXMLDOMParser)
Check whether or not to ignore annotations.
|
Bool |
GetLoadExternalDTD( Void )
(inherits from SFXXMLDOMParser)
Check whether or not to load the external DTD.
|
static SFXXMLElementPtr |
GetNextSiblingElement(
SFXXMLNodeConstPtr node
)
(inherits from SFXXMLDOMParser)
Get the next sibling Element node of the specified node.
|
static SFXXMLElementPtr |
GetNextSiblingElementNS(
SFXXMLNodeConstPtr node
, SFXAnsiStringHandleConst elemNames
, SFXAnsiStringConstRef uri
, SInt32 length
)
(inherits from SFXXMLDOMParser)
Get the next sibling Element node of the specified node, which matches the namespace URI and one of the local names specified.
|
Bool |
GetStandalone( Void )
(inherits from SFXXMLDOMParser)
Get the Standalone declaration of the XML document.
|
Bool |
GetValidationDTD( Void )
(inherits from SFXXMLDOMParser)
Check whether or not to validate the XML document with DTD.
|
Bool |
GetValidationSchema( Void )
(inherits from SFXXMLDOMParser)
Check whether or not to validate the XML document with XML Schema.
|
Void |
SetCreateCommentNodes(
BoolConst create
)
(inherits from SFXXMLDOMParser)
Set whether or not to create comment nodes.
|
Void |
SetDoIndent(
BoolConst state
)
(inherits from SFXXMLDOMParser)
Set whether or not to indent.
|
Void |
SetDoNamespaces(
BoolConst state
)
(inherits from SFXXMLDOMParser)
Set whether or not to process namespaces.
|
Void |
SetDoSchema(
BoolConst state
)
(inherits from SFXXMLDOMParser)
Set whether or not to process the XML Schema.
|
Void |
SetGrammar(
SFXXMLGrammar::GrammarType grammar
)
(inherits from SFXXMLDOMParser)
Set the grammar used by this parser.
|
Void |
SetGrammar(
SFXXMLGrammar::GrammarType grammar
)
(inherits from SFXXMLDOMParser)
Set the grammar used by this parser.
|
Void |
SetIgnoreAnnotations(
BoolConst state
)
(inherits from SFXXMLDOMParser)
Set whether or not to ignore annotations.
|
Void |
SetIgnoreAnnotations(
BoolConst state
)
(inherits from SFXXMLDOMParser)
Set whether or not to ignore annotations.
|
Void |
SetLoadExternalDTD(
BoolConst state
)
(inherits from SFXXMLDOMParser)
Set whether or not to load the external DTD.
|
Void |
SetSchemaLocation(
SFXAnsiStringConstRef name
)
(inherits from SFXXMLDOMParser)
Set the XSD file of the XML document with XML Schema.
|
Void |
SetValidationDTD(
BoolConst state
)
(inherits from SFXXMLDOMParser)
Set whether or not to validate the XML document with DTD.
|
Void |
SetValidationSchema(
BoolConst state
)
(inherits from SFXXMLDOMParser)
Set whether or not to validate the XML document with XML Schema.
|
Protected Functions | |
---|---|
Void |
SetGrammar(
SFXXMLGrammar::GrammarType grammar
)
(inherits from SFXXMLDOMParser)
Set the grammar used by this parser.
|
Void |
SetGrammar(
SFXXMLGrammar::GrammarType grammar
)
(inherits from SFXXMLDOMParser)
Set the grammar used by this parser.
|
Void |
SetIgnoreAnnotations(
BoolConst state
)
(inherits from SFXXMLDOMParser)
Set whether or not to ignore annotations.
|
Void |
SetIgnoreAnnotations(
BoolConst state
)
(inherits from SFXXMLDOMParser)
Set whether or not to ignore annotations.
|
Types |
---|
SOAP_VERSION Version of the SOAP Protocol.
|
[ public, explicit ] SFXSOAPParser(Void);
[ public ] ~SFXSOAPParser(Void);
[ public, const ] SFXXMLElementPtr GetBody(Void);
[ public, const ] SFXXMLNode::DOMNodeListPtr GetBodyEntries(Void);
[ public, const ] SFXXMLElementPtr GetBodyEntry( SFXAnsiStringConstRef local // name of elemen SFXAnsiStringConstRef uri = SFXAnsiString::EmptyInstance() // namespace URI of the element );
[ public, const ] SFXXMLElementPtr GetEnvelope(Void);
[ public, const ] SFXXMLElementPtr GetFault(Void);
About SOAP Fault | |
---|---|
Simple Object Access Protocol (SOAP) 1.1 ( W3C ) : SOAP Fault SOAP Tutorial : SOAP Fault Element |
* Only SOAP Fault of SOAP 1.1 is supported.
SFXSOAPRPC::FAULT | SFXSOAPParser::GetFaultActor | SFXSOAPParser::GetFaultCode | SFXSOAPParser::GetFaultDetail | SFXSOAPParser::GetFaultString
[ public, const ] SFXXMLElementPtr GetFaultActor(Void);
About SOAP Fault | |
---|---|
Simple Object Access Protocol (SOAP) 1.1 ( W3C ) : SOAP Fault SOAP Tutorial : SOAP Fault Element |
* Only SOAP Fault of SOAP 1.1 is supported.
SFXSOAPRPC::FAULT | SFXSOAPParser::GetFault | SFXSOAPParser::GetFaultCode | SFXSOAPParser::GetFaultDetail | SFXSOAPParser::GetFaultString
[ public, const ] SFXXMLElementPtr GetFaultCode(Void);
About SOAP Fault | |
---|---|
Simple Object Access Protocol (SOAP) 1.1 ( W3C ) : SOAP Fault SOAP Tutorial : SOAP Fault Element |
* Only SOAP Fault of SOAP 1.1 is supported.
SFXSOAPRPC::FAULT | SFXSOAPParser::GetFault | SFXSOAPParser::GetFaultActor | SFXSOAPParser::GetFaultDetail | SFXSOAPParser::GetFaultString
[ public, const ] SFXXMLElementPtr GetFaultDetail(Void);
About SOAP Fault | |
---|---|
Simple Object Access Protocol (SOAP) 1.1 ( W3C ) : SOAP Fault SOAP Tutorial : SOAP Fault Element |
* Only SOAP Fault of SOAP 1.1 is supported.
SFXSOAPRPC::FAULT | SFXSOAPParser::GetFault | SFXSOAPParser::GetFaultActor | SFXSOAPParser::GetFaultCode | SFXSOAPParser::GetFaultString
[ public, const ] SFXXMLElementPtr GetFaultString(Void);
About SOAP Fault | |
---|---|
Simple Object Access Protocol (SOAP) 1.1 ( W3C ) : SOAP Fault SOAP Tutorial : SOAP Fault Element |
* Only SOAP Fault of SOAP 1.1 is supported.
SFXSOAPRPC::FAULT | SFXSOAPParser::GetFault | SFXSOAPParser::GetFaultActor | SFXSOAPParser::GetFaultCode | SFXSOAPParser::GetFaultDetail
[ public, const ] SFXXMLElementPtr GetHeader(Void);
[ public, const ] SFXXMLNode::DOMNodeListPtr GetHeaderEntries(Void);
[ public, const ] SFXXMLElementPtr GetHeaderEntry( SFXAnsiStringConstRef local // name of the element SFXAnsiStringConstRef uri = SFXAnsiString::EmptyInstance() // namespace URI of the element );
[ public, const ] SFXXMLElementPtr GetRPCParameter( SFXAnsiStringConstRef local // name of the element SFXAnsiStringConstRef uri = SFXAnsiString::EmptyInstance() // namespace URI of the element );
[ public, const ] SFXXMLElementPtr GetRPCResult(Void);
[ public, const ] SFXXMLElementPtr GetRPCStruct(Void);
[ public, const ] SOAP_VERSION GetSoapVersion(Void);
Return the version of a SOAP document.
Integer value | A defined constant |
---|---|
0 | SOAP_VERSION_1_1 |
1 | SOAP_VERSION_1_2 |
-1 | SOAP_VERSION_UNKNOWN |
[ public ] SFCError Parse( SFBFileSmpConstRef source // file for the SOAP message );
[ public ] SFCError Parse( SFXAnsiStringConstRef source // SOAP message );
[ public ] SFCError Parse( SFXPathConstRef source // name of file for the SOAP message );
[ public ] SFCError Parse( SFXStreamReaderConstRef source // input stream for the SOAP message );
The error codes that may occur when parsing the SOAP document are as follows:
The error codes that may occur when parsing the SOAP document with DTD are as follows:
The error codes that may occur when parsing the SOAP document with Schema are as follows:
Reference: SFCErrorEnum
The SFXXMLSOAPParser::Parse function is to read and parse the specified SOAP document using the DOM parser. The argument can be an input stream, file name (of file path type), or string. The default directory of the file path is the home directory of application.
[ public ] Void Reset(Void);
SOAP_VERSION_1_1 // version 1.1 SOAP_VERSION_1_2 // version 1.2
Version of the SOAP Protocol. SFXSOAP class supports version 1.1 and 1.2. However, SOAP Attachment is not implemented.
Constant | Namespace |
---|---|
SOAP_VERSION_1_1 | "http://schemas.xmlsoap.org/soap/envelope/" |
SOAP_VERSION_1_2 | "http://www.w3.org/2003/05/soap-envelope" |
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |