SophiaFramework UNIVERSE 5.3 |
SFXSOAPRPC is the class that supports the SOAP-RPC protocol.
About Simple Object Access Protocol ( SOAP ) | |
---|---|
W3C SOAP latest information: Simple Object Access Protocol (SOAP) 1.1 (However, SOAP Attachment has not been implemented.) |
Example 838. The method to call the web service using the SOAP-RPC Protocol
#define AMAZON_ID " // Amazon ID must be set SFMTYPEDEFCLASS(SOAPTest) class SOAPTest : public SFCApplication { SFMSEALCOPY(SOAPTest) private: SFXSOAPRPC _rpc; // variable for processing the SOAP-RPC protocol Void OnSOAP(Void); static Void OnResultSHP_SOAP(SFCError error, const SFXSOAPRPC::Params& result, const SFXSOAPRPC::FAULT& fault, SFXSOAPParserConstRef soap, VoidPtr reference); Void OnResult_SOAP(SFCError error, const SFXSOAPRPC::Params& result, const SFXSOAPRPC::FAULT& fault, SFXSOAPParserConstRef soap); }; Void SOAPTest::OnSOAP() { // set method name _rpc.SetMethodName("ItemSearch"); // set SOAP encoding _rpc.SetEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/"); // the following code is the same as the above // _rpc.SetEncodingStyle("STANDARD"); // set target URI _rpc.SetTargetObjectURI("https://webservices.amazon.com/"); // set parameters of web service _rpc.AddParameter("AWSAccessKeyId", SFXBuffer(SFXAnsiString(AMAZON_ID))); _rpc.AddParameter("Keywords", SFXBuffer(SFXAnsiString("caviar"))); _rpc.AddParameter("MerchantId", SFXBuffer(SFXAnsiString("Amazon"))); _rpc.AddParameter("SearchIndex", SFXBuffer(SFXAnsiString("GourmetFood"))); // call web service _rpc.Invoke("http://soap.amazon.co.jp/onca/soap?Service=AWSECommerceService", "http://soap.amazon.com", OnResultSHP_SOAP, this); } // callback function to be notified of the result of the web service // error: error value, result: return value of web service, fault: SOAP Fault element, soap : SOAP message, reference: data passed to callback function Void SOAPTest::OnResultSHP_SOAP(SFCError error, const SFXSOAPRPC::Params& result, const SFXSOAPRPC::FAULT& fault, SFXSOAPParserConstRef soap, VoidPtr reference) { static_cast<SOAPTestPtr>(reference)->OnResult_SOAP(error, result, fault, soap); } // Function to process the SOAP message received from web server Void SOAPTest::OnResult_SOAP(SFCError error, const SFXSOAPRPC::Params& result, const SFXSOAPRPC::FAULT& fault, SFXSOAPParserConstRef soap) { if (error == SFERR_NO_ERROR) { // get result of SOAP message(SFXSOAPRPC::Params array) for each parameter // get enumerator SFXSOAPRPC::Params::Enumerator paramEtor = result.GetFirstEnumerator(); while (paramEtor.HasNext()) { // get each parameter SFXSOAPRPC::LPPARAMETER temp = paramEtor.GetNext(); // display name of parameter TRACE("parameter-name: %s", temp->_name.GetCString()); // display type of parameter TRACE("parameter-type: %d", temp->_type); if (!temp->_value.IsEmpty()) { // display value of parameter TRACE("parameter-value: %s", ACharConstPtr(temp->_value.GetBuffer())); } } } // display error message(SOAP Fault) else if (error == SFERR_SOAP_FAULT_MESSAGE) { if(!fault._faultactor.IsEmpty()) { // if faultactor element is not empty, display its content TRACE("faultactor: %s", fault._faultactor.GetCString()); } if(!fault._faultcode.IsEmpty()) { // if faultcode element is not empty, display its content TRACE("faultcode: %s", fault._faultcode.GetCString()); } if(!fault._faultstring.IsEmpty()) { // if faultstring element is not empty, display its content TRACE("faultstring: %s", fault._faultstring.GetCString()); } if (!fault._faultdetail) { // if detail element is not "null", display its content TRACE("faultstring: %s", fault._faultdetail->GetText().GetCString()); } } return; }
Constructor/Destructor |
---|
SFXSOAPRPC( Void ) Constructor of the SFXSOAPRPC class.
|
SFXSOAPRPC(
SFXAnsiStringConstRef targeturi
, SFXAnsiStringConstRef prefix
, SFXAnsiStringConstRef method
, ParamsConstRef params
, SFXAnsiStringConstRef encodingstyle = "NONE"
, SFXAnsiStringConstRef port = SFXAnsiString::EmptyInstance()
) Constructor of the SFXSOAPRPC class.
|
~SFXSOAPRPC( Void ) Destructor of the SFXSOAPRPC class.
|
Public Functions | |
---|---|
SFCError |
AddAttribute(
SFXAnsiStringConstRef param
, SFXAnsiStringConstRef name
, SFXAnsiStringConstRef value
, PARAMETER::Mode mode = PARAMETER::IN
) Add an attribute to the parameter.
|
SFCError |
AddMethodAttribute(
SFXAnsiStringConstRef name
, SFXAnsiStringConstRef value
) Add a method attribute.
|
SFCError |
AddParameter(
SFXAnsiStringConstRef name
, SFXBufferConstRef value
, PARAMETER::Types type = PARAMETER::XSD_STRING
, PARAMETER::Mode mode = PARAMETER::IN
) Add a parameter.
|
Void |
Cancel( Void ) Cancel the SOAP-RPC communication.
|
ACharConstPtr |
GetEncodingStyle( Void ) Get the SOAP encoding.
|
ACharConstPtr |
GetMethodName( Void ) Get the method name of Web Service.
|
ParamsConstPtr |
GetParams( Void ) Get the array of the input parameters.
|
const LPPARAMETER |
GetResultValueByName(
SFXAnsiStringConstRef name
) Get the return value of the specified parameter.
|
ParamsConstPtr |
GetResultValues( Void ) Get the array of the output parameters.
|
ACharConstPtr |
GetTargetObjectURI( Void ) Get target URI.
|
UInt32 |
GetTrustMode( Void ) Get the SSL trust mode.
|
SFCError |
Invoke(
SFXAnsiStringConstRef url
, SFXAnsiStringConstRef SOAPActionURI
, NotifySPP spp = null
, VoidPtr reference = null
) Call the Web Service method.
|
SFCError |
Invoke(
SFXAnsiStringConstRef url
, SFXAnsiStringConstRef SOAPActionURI
, SFXAnsiStringConstRef input
, NotifySPP spp = null
, VoidPtr reference = null
) Call the Web Service method.
|
Bool |
IsConnecting( Void ) Check whether or not to be connected to the server.
|
Void |
RemoveAllParams( Void ) Remove all the parameters of the web service.
|
Void |
Reset( Void ) Reset all the internal variables.
|
Void |
SetEncodingStyle(
SFXAnsiStringConstRef encodingstyle
) Set the SOAP encoding.
|
SFXXMLElementPtr |
SetHeader(
SFXAnsiStringConstRef encodingstyle = "NONE"
) Set the Header element of the SOAP-RPC message.
|
Void |
SetMethodName(
SFXAnsiStringConstRef method
) Set the method name of the web service.
|
Void |
SetNotifyHandler(
NotifySPP spp
, VoidPtr reference
) Set the callback function to get the return value.
|
SFCError |
SetParams(
ParamsConstRef params
) Set the parameters.
|
Void |
SetTargetObjectURI(
SFXAnsiStringConstRef targeturi
, SFXAnsiStringConstRef prefix = SFXAnsiString::EmptyInstance()
) Set the target URI.
|
Void |
SetTrustMode(
UInt32 param
) Set the SSL trust mode.
|
Types |
---|
FAULT Data structure for the SOAP Fault.
|
LPFAULT Pointer type of SFXSOAPRPC::FAULT.
|
LPPARAMETER Pointer type of SFXSOAPRPC::PARAMETER.
|
NotifySPP Type that represents the callback function.
|
PARAMETER Data structure for the parameter.
|
Params Array of pointer to PARAMETER structures.
|
[ public, explicit ] SFXSOAPRPC(Void);
[ public, explicit ] SFXSOAPRPC( SFXAnsiStringConstRef targeturi // target URI SFXAnsiStringConstRef prefix // namespace prefix of target URI SFXAnsiStringConstRef method // target method ParamsConstRef params // parameters SFXAnsiStringConstRef encodingstyle = "NONE" // SOAP encoding SFXAnsiStringConstRef port = SFXAnsiString::EmptyInstance() // port of web service );
The following variables are defined in the params argument.
Variable | Description |
---|---|
_type | type of parameter |
_mode | I/O mode of parameter |
_name | name of parameter |
_value | value of parameter |
_attrlist | attribute information of parameter |
[ public ] ~SFXSOAPRPC(Void);
[ public ] SFCError AddAttibute( SFXAnsiStringConstRef param // name of parameter SFXAnsiStringConstRef name // name of attribute SFXAnsiStringConstRef value // value of attribute PARAMETER::Mode mode = PARAMETER::IN // mode of attribute (default: input mode) );
[ public ] SFCError AddMethodAttribute( SFXAnsiStringConstRef name // name of attribute SFXAnsiStringConstRef value // value of attribute );
[ public ] SFCError AddParameter( SFXAnsiStringConstRef name // name of parameter SFXBufferConstRef value // value of parameter PARAMETER::Types type = PARAMETER::XSD_STRING // type of parameter(default: string) PARAMETER::Mode mode = PARAMETER::IN // mode of parameter(default: input mode) );
SFXSOAPRPC rpc; rpc.AddParameter("Index", SFXBuffer(SFXAnsiString("1")), SFXSOAPRPC::PARAMETER::SOAP_INT, SFXSOAPRPC::PARAMETER::IN );
[ public ] Void Cancel(Void);
[ public, const ] ACharConstPtr GetEncodingStyle(Void);
SOAP encoding is not for encoding the characters but for representing the data types of SOAP document as XML format.
Usually, the encoding style defined at the " http://schemas.xmlsoap.org/soap/envelope/ " URI is used as SOAP Encoding.
About SOAP Encoding | |
---|---|
W3C Simple Object Access Protocol (SOAP) 1.1 : SOAP Encoding |
[ public, const ] ACharConstPtr GetMethodName(Void);
[ public, const ] ParamsConstPtr GetParams(Void);
Array of the input parameters of the SFXSOAPRPC::LPPARAMETER type(SFXSOAPRPC::Params).
This function gets the array of the input parameters of the SFXSOAPRPC::LPPARAMETER type(SFXSOAPRPC::Params).
Note | |
---|---|
SFXSOAPRPC::LPPARAMETER is the type of pointer to the SFXSOAPRPC::PARAMETER structure. |
SFXSOAPRPC _rpc; // SFXSOAPRPC object SFXSOAPRPC::ParamsConstPtr lp; lp = _rpc.GetParams(); // get list of input parameters SFXSOAPRPC::LPPARAMETER item; item = lp->Get(0); // get first element TRACE("%s",item->_name.GetCString()); // display type of parameter TRACE("%s",item->_value.GetBuffer()); // display value of parameter
SFXSOAPRPC::SetParams | SFXSOAPRPC::Params | SFXSOAPRPC::LPPARAMETER | SFXSOAPRPC::PARAMETER
[ public, const ] const LPPARAMETER GetResultValueByName( SFXAnsiStringConstRef name );
[ public, const ] ParamsConstPtr GetResultValues(Void);
Array of the output parameters of the SFXSOAPRPC::LPPARAMETER type(SFXSOAPRPC::Params).
This function gets the array of the output parameters of the SFXSOAPRPC::LPPARAMETER type(SFXSOAPRPC::Params).
Note | |
---|---|
SFXSOAPRPC::LPPARAMETER is the type of pointer to the SFXSOAPRPC::PARAMETER structure. |
SFXSOAPRPC _rpc; // SFXSOAPRPC object SFXSOAPRPC::ParamsConstPtr lp; lp = _rpc.GetResultValues(); // get list of output parameters SFXSOAPRPC::LPPARAMETER item; item = lp->Get(0); // get first element TRACE("%s",item->_name.GetCString()); // display type of parameter TRACE("%s",item->_value.GetBuffer()); // display value of parameter
SFXSOAPRPC::SetNotifyHandler | SFXSOAPRPC::Invoke | SFXSOAPRPC::Params | SFXSOAPRPC::LPPARAMETER | SFXSOAPRPC::PARAMETER | SFXSOAPRPC::NotifySPP
[ public, const ] ACharConstPtr GetTargetObjectURI(Void);
[ public, const ] UInt32 GetTrustMode(Void);
The SSL trust mode can be one of the following values.
Note | |
---|---|
Reference: ISSL_NegotiateV in the BREW API Reference |
[ public ] SFCError Invoke( SFXAnsiStringConstRef url // Web Service IP address SFXAnsiStringConstRef SOAPActionURI // SoapAction attribute value NotifySPP spp = null // callback function VoidPtr reference = null // data passed to the callback function );
[ public ] SFCError Invoke( SFXAnsiStringConstRef url // Web Service IP address SFXAnsiStringConstRef SOAPActionURI // SoapAction attribute value SFXAnsiStringConstRef input // SOAP message NotifySPP spp = null // callback function(Default: null) VoidPtr reference = null // data passed to the callback function(Default: null) );
SFXSOAPRPC::SetNotifyHandler | SFXSOAPRPC::SetTrustMode | SFXSOAPRPC::SetEncodingStyle | SFXSOAPRPC::SetHeader | SFXSOAPRPC::SetMethodName | SFXSOAPRPC::AddMethodAttribute | SFXSOAPRPC::SetParams | SFXSOAPRPC::AddParameter | SFXSOAPRPC::AddAttribute | SFXSOAPRPC::SetTargetObjectURI | SFXSOAPRPC::IsConnecting | SFXHTTPConnection::Open | SFXHTTPConnection::Connect | SFXHTTPConnection::SetTrustMode
[ public, const ] Bool IsConnecting(Void);
[ public ] Void RemoveAllParams(Void);
[ public ] Void Reset(Void);
[ public ] Void SetEncodingStyle( SFXAnsiStringConstRef encodingstyle // SOAP encoding );
The values for the SOAP encoding are defined as follows:
Value | Description |
---|---|
"NONE" | SOAP encoding is not specified |
"STANDARD" | "http://schemas.xmlsoap.org/soap/encoding/" is specified. |
SOAP encoding is not for encoding the characters but for representing the data types of SOAP document as XML format.
Usually, the encoding style defined at the " http://schemas.xmlsoap.org/soap/envelope/ " URI is used as SOAP Encoding.
About SOAP Encording | |
---|---|
W3C Simple Object Access Protocol (SOAP) 1.1 : SOAP Encoding |
[ public ] SFXXMLElementPtr SetHeader( SFXAnsiStringConstRef encodingstyle = "NONE" // SOAP encoding );
The values for the SOAP encoding are defined as follows:
Value | Description |
---|---|
"NONE" | SOAP encoding is not specified |
"STANDARD" | "http://schemas.xmlsoap.org/soap/encoding/" is specified. |
Set the Header element of the SOAP-RPC document. If the Header element has already existed, this setting is not performed.
SOAP encoding is not for encoding the characters but for representing the data types of SOAP document as XML format.
Usually, the encoding style defined at the " http://schemas.xmlsoap.org/soap/envelope/ " URI is used as SOAP Encoding.
About SOAP Encording | |
---|---|
W3C Simple Object Access Protocol (SOAP) 1.1 : SOAP Encoding |
[ public ] Void SetMethodName( SFXAnsiStringConstRef method // method name of the web service );
[ public ] Void SetNotifyHandler( NotifySPP spp // callback function VoidPtr reference // data passed to the callback function );
[ public ] SFCError SetParams( ParamsConstRef params // parameters );
[ public ] Void SetTargetObjectURI( SFXAnsiStringConstRef targeturi // target URI SFXAnsiStringConstRef prefix = SFXAnsiString::EmptyInstance() // namespace prefix of target URI );
One of the following values are available for the SSL trust mode:
Note | |
---|---|
Reference: ISSL_NegotiateV in the BREW API Reference |
typedef struct SFXSOAPRPC::_Fault SFXSOAPRPC::FAULT typedef struct SFXSOAPRPC::_Fault SFXSOAPRPC::FAULT typedef struct _Fault { SFXAnsiString _faultactor; // faultactor element SFXAnsiString _faultcode; // faultcode element SFXAnsiString _faultstring; // faultstring element SFXXMLElementPtr _faultdetail; // faultdetail element } FAULT;
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::LPFAULT | SFXSOAPParser::GetFault | SFXSOAPParser::GetFaultActor | SFXSOAPParser::GetFaultCode | SFXSOAPParser::GetFaultDetail | SFXSOAPParser::GetFaultString
typedef struct SFXSOAPRPC::_Fault * SFXSOAPRPC::LPFAULT typedef struct _Fault { SFXAnsiString _faultactor; // faultactor element SFXAnsiString _faultcode; // faultcode element SFXAnsiString _faultstring; // faultstring element SFXXMLElementPtr _faultdetail; // faultdetail element } *LPFAULT;
typedef struct SFXSOAPRPC::_Parameter * SFXSOAPRPC::LPPARAMETER typedef struct _Parameter { enum Types { XSD_STRING, XSD_FLOAT, XSD_BOOLEAN, XSD_DOUBLE, XSD_INTEGER, XSD_INT, XSD_LONG, XSD_SHORT, XSD_DECIMAL, XSD_BASE64, XSD_HEXBINARY, XSD_BYTE, XSD_DATETIME, XSD_QNAME, SOAP_STRING, SOAP_BOOLEAN, SOAP_DOUBLE, SOAP_BASE64, SOAP_FLOAT, SOAP_INT, SOAP_LONG, SOAP_SHORT, SOAP_BYTE, SOAP_ARRAY, UNKNOWN }; enum Mode { IN, INOUT, OUT }; Types _type; // type Mode _mode; // input/output mode SFXAnsiString _name; // name SFXBuffer _value; // value SFXProperty _attrlist; // attribute information } *LPPARAMETER;
typedef Void(* SFXSOAPRPC::NotifySPP)(SFCError error, const Params &result, const FAULT &fault, SFXSOAPParserConstRef soap, VoidPtr reference)
error value
return value
Fault element of the SOAP message
reference to the SOAP message
data passed to the callback function
typedef struct SFXSOAPRPC::_Parameter SFXSOAPRPC::PARAMETER typedef struct _Parameter { enum Types { XSD_STRING, XSD_FLOAT, XSD_BOOLEAN, XSD_DOUBLE, XSD_INTEGER, XSD_INT, XSD_LONG, XSD_SHORT, XSD_DECIMAL, XSD_BASE64, XSD_HEXBINARY, XSD_BYTE, XSD_DATETIME, XSD_QNAME, SOAP_STRING, SOAP_BOOLEAN, SOAP_DOUBLE, SOAP_BASE64, SOAP_FLOAT, SOAP_INT, SOAP_LONG, SOAP_SHORT, SOAP_BYTE, SOAP_ARRAY, UNKNOWN }; enum Mode { IN, INOUT, OUT }; Types _type; // type Mode _mode; // input/output mode SFXAnsiString _name; // name SFXBuffer _value; // value SFXProperty _attrlist; // attribute information } PARAMETER;
Variable | Description |
---|---|
_type | type of parameter |
_mode | Input/Output mode of parameter |
_name | name of parameter |
_value | value of parameter(instance of SFXBuffer class) |
_attrlist | attribute information of parameter |
_type values
For definition of XML schema
For definition of SOAP message
_mode values
_attrlist is the list of parameter attributes. To store the attribute of a parameter, use the SFXSOAPRPC::AddAttribute function.
SFXSOAPRPC::LPPARAMETER | SFXSOAPRPC::AddAttribute | SFXBuffer
SFMTYPEDEFALIAS(SFXArray<LPPARAMETER>, Params)
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |