![]() ![]() ![]()
|
BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1 |

SFXSOAPRPC is the class that supports the SOAP-RPC protocol.
![]() |
About Simple Object Access Protocol ( SOAP ) |
|---|---|
W3C SOAP latest information: Latest SOAP versions (SOAP 1.1 and SOAP 1.2 are supported. However, SOAP Attachment has not been implemented and only SOAP Fault of SOAP 1.1 is supported.) | |
Example 488. 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 empty, display its content TRACE("faultstring: %s", fault._faultdetail->GetText().GetCString()); } return; }
| Constructor/Destructor |
|---|
|
SFXSOAPRPC( Void ) Constructor of SFXSOAPRPC class.
|
|
SFXSOAPRPC(
SFXAnsiStringConstRef targeturi
, SFXAnsiStringConstRef prefix
, SFXAnsiStringConstRef method
, ParamsConstRef params
, SFXAnsiStringConstRef encodingstyle = "NONE"
, SFXAnsiStringConstRef port = SFXAnsiString::EmptyInstance()
) Constructor of SFXSOAPRPC class.
|
|
~SFXSOAPRPC( Void ) Destructor of 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 list of parameters.
|
| const LPPARAMETER |
GetResultValueByName(
SFXAnsiStringConstRef name
) Get the return value of a specified parameter.
|
| ParamsConstPtr |
GetResultValues( Void ) Get the list 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
) 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 Prototype of the callback function.
|
|
PARAMETER Data structure for the parameter.
|
[ 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);
Return the pointer to the SFXSOAPRPC::LPPARAMETER structure.
Get the SFXSOAPRPC::PARAMETER structure.
![]() |
Note |
|---|---|
| SFXSOAPRPC::LPPARAMETER is the type of pointer to the SFXSOAPRPC::PARAMETER structure. | |
SFXSOAPRPC _rpc; // variable for processing SOAP-RPC protocol SFXSOAPRPC::ParamsConstPtr lp; lp = _rpc.GetParams(); // get list of 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
[ public, const ]
const LPPARAMETER GetResultValueByName(
SFXAnsiStringConstRef name
);[ public, const ] ParamsConstPtr GetResultValues(Void);
Return the pointer to the SFXSOAPRPC::LPPARAMETER structure.
Get the SFXSOAPRPC::PARAMETER structure.
![]() |
Note |
|---|---|
| SFXSOAPRPC::LPPARAMETER is the type of pointer to the SFXSOAPRPC::PARAMETER structure. | |
SFXSOAPRPC _rpc; // variable for processing SOAP-RPC protocol 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
[ public, const ] ACharConstPtr GetTargetObjectURI(Void);
[ public, const ] UInt32 GetTrustMode(Void);
The SSL trust mode can be one of the following values.
![]() |
Note |
|---|---|
| Detailed information: 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 VoidPtr reference = null // data passed to the callback function );
[ 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 |
|---|---|
| Detailed information: ISSL_NegotiateV in the BREW API Reference | |
typedef struct SFXSOAPRPC::_Fault SFXSOAPRPC::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.
SFXSOAPParser::GetFault | SFXSOAPParser::GetFaultActor | SFXSOAPParser::GetFaultCode | SFXSOAPParser::GetFaultDetail | SFXSOAPParser::GetFaultString
typedef struct SFXSOAPRPC::_Fault * SFXSOAPRPC::LPFAULT
typedef struct SFXSOAPRPC::_Parameter * SFXSOAPRPC::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
| 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.
|
Copyright (C) 2002 - 2009 Sophia Cradle, Inc. All Rights Reserved. |
![]() ![]() ![]()
|