KDSoapClientInterface Class Reference

#include <KDSoapClientInterface.h>

List of all members.

Public Types

enum  SoapVersion { SOAP1_1 = 1, SOAP1_2 = 2 }

Public Member Functions

 KDSoapClientInterface (const QString &endPoint, const QString &messageNamespace)
 ~KDSoapClientInterface ()
KDSoapPendingCall asyncCall (const QString &method, const KDSoapMessage &message, const QString &soapAction=QString(), const KDSoapHeaders &headers=KDSoapHeaders())
KDSoapMessage call (const QString &method, const KDSoapMessage &message, const QString &soapAction=QString(), const KDSoapHeaders &headers=KDSoapHeaders())
void callNoReply (const QString &method, const KDSoapMessage &message, const QString &soapAction=QString(), const KDSoapHeaders &headers=KDSoapHeaders())
void setAuthentication (const KDSoapAuthentication &authentication)
void setHeader (const QString &name, const KDSoapMessage &header)
void setSoapVersion (SoapVersion version)
SoapVersion soapVersion ()
void ignoreSslErrors ()

Detailed Description

KDSoapClientInterface is a generic accessor class that is used to place calls to remote SOAP objects. This class is useful for dynamic access to remote objects: that is, when you do not have a generated code that represents the remote interface.

  const int year = 2009;

  const QString endPoint = QLatin1String("http://www.27seconds.com/Holidays/US/Dates/USHolidayDates.asmx");
  const QString messageNamespace = QLatin1String("http://www.27seconds.com/Holidays/US/Dates/");
  KDSoapClientInterface client(endPoint, messageNamespace);

  KDSoapMessage message;
  message.addArgument(QLatin1String("year"), year);

  qDebug("Looking up the date of Valentine's Day in %i...", year);

  KDSoapMessage response = client.call(QLatin1String("GetValentinesDay"), message);

  qDebug("%s", qPrintable(response.arguments()[0].value().toString()));

Member Enumeration Documentation

Version of the SOAP protocol to use when sending requests.

See also:
setSoapVersion()
Enumerator:
SOAP1_1 

Use format version 1.1 of the SOAP specification

SOAP1_2 

Use format version 1.2 of the SOAP specification


Constructor & Destructor Documentation

KDSoapClientInterface::KDSoapClientInterface ( const QString &  endPoint,
const QString &  messageNamespace 
) [explicit]

Creates a KDSoapClientInterface object associated with the end point endPoint.

Note:
No connection is done yet at this point, the parameters are simply stored for later use.
Parameters:
endPoint the URL of the SOAP service, including http or https scheme, port number if needed, and path. Example: http://server/path/soap.php
messageNamespace the namespace URI used for the message and its arguments. Example: http://server/path, but could be any URI, it doesn't have to exist or even to be http, this is really just a namespace, which is part of the specification of the SOAP service.
KDSoapClientInterface::~KDSoapClientInterface (  ) 

Destroy the object interface and frees up any resource used.

Warning:
Any running asynchronous calls will be canceled.

Member Function Documentation

KDSoapPendingCall KDSoapClientInterface::asyncCall ( const QString &  method,
const KDSoapMessage message,
const QString &  soapAction = QString(),
const KDSoapHeaders headers = KDSoapHeaders() 
)

Calls the method method on this interface and passes the arguments specified in message to the method.

Parameters:
method method name, without arguments. For instance "addContact".
message arguments for the method call
soapAction optional "SoapAction" header, see the specification of the SOAP service.
headers optional arguments which will be passed as <soap:Header>.

This is an asynchronous call, so this function returns immediately. The returned KDSoapPendingCall object can be used to find out information about the reply. You should create a KDSoapPendingCallWatcher to connect to the finished() signal.

Warning:
The returned KDSoapPendingCall object (or a copy of it) must stay alive for the whole duration of the call. If you do not want to wait for a response, use callNoReply instead.
  const int year = 2009;

  const QString endPoint = QLatin1String("http://www.27seconds.com/Holidays/US/Dates/USHolidayDates.asmx");
  const QString messageNamespace = QLatin1String("http://www.27seconds.com/Holidays/US/Dates/");
  KDSoapClientInterface* client= new KDSoapClientInterface(endPoint, messageNamespace);

  KDSoapMessage message;
  message.addArgument(QLatin1String("year"), year);

  qDebug("Looking up the date of Valentine's Day in %i...", year);

  KDSoapPendingCall pendingCall = client->asyncCall(QLatin1String("GetValentinesDay"), message);

  // create a watcher object that will signal the call's completion
  KDSoapPendingCallWatcher* watcher = new KDSoapPendingCallWatcher(pendingCall, this);
  connect(watcher, SIGNAL(finished(KDSoapPendingCallWatcher*)),
          this, SLOT(pendingCallFinished(KDSoapPendingCallWatcher*)));

  void MyClass::pendingCallFinished(KDSoapPendingCallWatcher* pendingCall)
  {
      KDSoapMessage response = pendingCall->returnMessage();
      qDebug("%s", qPrintable(response.arguments()[0].value().toString()));
  }
KDSoapMessage KDSoapClientInterface::call ( const QString &  method,
const KDSoapMessage message,
const QString &  soapAction = QString(),
const KDSoapHeaders headers = KDSoapHeaders() 
)

Calls the method method on this interface and passes the parameters specified in message to the method.

Parameters:
method method name, without arguments. For instance "addContact".
message arguments for the method call
soapAction optional "SoapAction" header, see the specification of the SOAP service.
headers optional arguments which will be passed as <soap:Header>.
Warning:
This is a blocking call. It is NOT recommended to use this in the main thread of graphical applications, since it will block the event loop for the duration of the call. Use this only in threads, or in non-GUI programs.
void KDSoapClientInterface::callNoReply ( const QString &  method,
const KDSoapMessage message,
const QString &  soapAction = QString(),
const KDSoapHeaders headers = KDSoapHeaders() 
)

Calls the method method on this interface and passes the parameters specified in message to the method.

Parameters:
method method name, without arguments. For instance "addContact".
message arguments for the method call
soapAction optional "SoapAction" header, see the specification of the SOAP service.
headers optional arguments which will be passed as <soap:Header>.

This is an asynchronous call, where the caller does not want to wait for a response. The method returns immediately, the call is performed later. No error handling is possible.

void KDSoapClientInterface::setAuthentication ( const KDSoapAuthentication authentication  ) 

Provide the necessary authentication for this service.

Parameters:
authentication the authentication data
void KDSoapClientInterface::setHeader ( const QString &  name,
const KDSoapMessage header 
)

Sets a persistent header, which will be sent with any subsequent SOAP call.

Parameters:
name internal name, used to replace any existing header previously set with this name
header the actual message to be sent
void KDSoapClientInterface::setSoapVersion ( KDSoapClientInterface::SoapVersion  version  ) 

Sets the SOAP version to be used for any subsequent SOAP call.

Parameters:
version SOAP1_1 or SOAP1_2 The default version is SOAP 1.1.
KDSoapClientInterface::SoapVersion KDSoapClientInterface::soapVersion (  ) 

Returns the version of SOAP being used in this instance.

void KDSoapClientInterface::ignoreSslErrors (  ) 

Asks Qt to ignore ssl errors in https requests. Use this for testing only!


The documentation for this class was generated from the following files:
 All Classes Functions Enumerations Enumerator Friends

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
http://www.kdab.com/products/kd-soap/