KD SOAP API Documentation: KDSoapServerObjectInterface Class Reference

| KD SOAP API Documentation 2.2

Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
KDSoapServerObjectInterface Class Reference

`#include <KDSoapServerObjectInterface.h>`

## Classes
struct | HttpResponseHeaderItem

## Public Types
typedef QVector< HttpResponseHeaderItem > | HttpResponseHeaderItems

## Public Member Functions
| KDSoapServerObjectInterface ()
| KDSoapServerObjectInterface (const KDSoapServerObjectInterface &)=delete
virtual | ~KDSoapServerObjectInterface ()
virtual HttpResponseHeaderItems | additionalHttpResponseHeaderItems () const
void | doneProcessingRequestWithPath (const KDSoapServerObjectInterface &otherInterface)
bool | hasFault () const
bool | isDelayedResponse () const
KDSoapServerObjectInterface & | operator= (const KDSoapServerObjectInterface &)=delete
KDSoapDelayedResponseHandle | prepareDelayedResponse ()
virtual QIODevice * | processFileRequest (const QString &path, QByteArray &contentType)
virtual void | processRequest (const KDSoapMessage &request, KDSoapMessage &response, const QByteArray &soapAction)
virtual void | processRequestWithPath (const KDSoapMessage &request, KDSoapMessage &response, const QByteArray &soapAction, const QString &path)
KDSoapHeaders | requestHeaders () const
void | sendDelayedResponse (const KDSoapDelayedResponseHandle &responseHandle, const KDSoapMessage &response)
QAbstractSocket * | serverSocket () const
void | setFault (const QString &faultCode, const QString &faultString, const QString &faultActor, const KDSoapValue &detail)
void | setFault (const QString &faultCode, const QString &faultString, const QString &faultActor=QString(), const QString &detail=QString())
void | setResponseHeaders (const KDSoapHeaders &headers)
void | setResponseNamespace (const QString &ns)
QByteArray | soapAction () const
void | writeHTTP (const QByteArray &httpReply)
void | writeXML (const QByteArray &reply, bool isFault=false)

## Detailed Description

Base class for server objects, i.e. objects implementing the methods that can be called by SOAP clients.

Your server object must derive from both QObject (directly or indirectly) and from KDSoapServerObjectInterface. The virtual method processRequest is called whenever a SOAP request is being made. To handle the call, either reimplement processRequest and do the dispatching manually (not recommended), or use kdwsdl2cpp to generate the base class for your server object.

Example: `class EmployeeServerObject : public MyServerBase // base class generated from the wsdl file { Q_OBJECT`

`public: // methods published to SOAP QString getEmployeeCountry(const QString& employeeName); [...] };`

The generated base class provides the pure virtual methods for each method defined in the WSDL file, such as getEmployeeCountry() in this example, as well as a generated processRequest() method which calls getEmployeeCountry when parsing a KDSoapMessage that is a "getEmployeeCountry" request.

Multi-threading note: KDSoapServer will create one instance of a "server object" per thread. So the code in this class does not need to be protected for thread-safety. Make sure to protect any shared resources though.

Definition at line 59 of file KDSoapServerObjectInterface.h.

## Member Typedef Documentation

## ◆ HttpResponseHeaderItems

typedef QVector<HttpResponseHeaderItem> KDSoapServerObjectInterface::HttpResponseHeaderItems

Definition at line 131 of file KDSoapServerObjectInterface.h.

## Constructor & Destructor Documentation

## ◆ KDSoapServerObjectInterface() [1/2]

KDSoapServerObjectInterface::KDSoapServerObjectInterface | ( |  | ) |

Constructor

Definition at line 47 of file KDSoapServerObjectInterface.cpp.

## ◆ ~KDSoapServerObjectInterface()

KDSoapServerObjectInterface::~KDSoapServerObjectInterface | ( |  | ) |
| virtual

Destructor

Definition at line 52 of file KDSoapServerObjectInterface.cpp.

## ◆ KDSoapServerObjectInterface() [2/2]

KDSoapServerObjectInterface::KDSoapServerObjectInterface | ( | const KDSoapServerObjectInterface & |  | ) |
| delete

## Member Function Documentation

## ◆ additionalHttpResponseHeaderItems()

KDSoapServerObjectInterface::HttpResponseHeaderItems KDSoapServerObjectInterface::additionalHttpResponseHeaderItems | ( |  | ) | const
| virtual

Returns additional HTTP response header items to be added to each HTTP response header The default implementation in this base class returns an empty list Subclasses can override this method as needed

Since
  1.8

Definition at line 85 of file KDSoapServerObjectInterface.cpp.

Referenced by httpResponseHeaders().

## ◆ doneProcessingRequestWithPath()

void KDSoapServerObjectInterface::doneProcessingRequestWithPath | ( | const KDSoapServerObjectInterface & | otherInterface | ) |

Call this after processRequestWithPath has finished handling a request, in order to copy response headers, faults, etc. from the secondary object interface into this one.

Since
  1.4

Definition at line 90 of file KDSoapServerObjectInterface.cpp.

## ◆ hasFault()

bool KDSoapServerObjectInterface::hasFault | ( |  | ) | const

Returns true if setFault was called in the current method invocation.

Definition at line 135 of file KDSoapServerObjectInterface.cpp.

## ◆ isDelayedResponse()

bool KDSoapServerObjectInterface::isDelayedResponse | ( |  | ) | const

Returns true if prepareDelayedResponse was called, during this soap call. Mostly useful internally in KDSoap.

Since
  1.2

## ◆ operator=()

KDSoapServerObjectInterface & KDSoapServerObjectInterface::operator= | ( | const KDSoapServerObjectInterface & |  | ) |
| delete

## ◆ prepareDelayedResponse()

KDSoapDelayedResponseHandle KDSoapServerObjectInterface::prepareDelayedResponse | ( |  | ) |

When a server object wants to implement a SOAP method call using an asynchronous operation (I/O or network for instance), it should call prepareDelayedResponse() from within the call handler, store the handle, return a dummy value (this allows to go back to the event loop), and use the handle later on (typically from a slot) in order to send the delayed response.

Since
  1.2

Definition at line 174 of file KDSoapServerObjectInterface.cpp.

## ◆ processFileRequest()

QIODevice * KDSoapServerObjectInterface::processFileRequest | ( | const QString & | path,
|  | QByteArray & | contentType
| ) |  |
| virtual

Handle an HTTP GET request, typically by returning a file.

If a NULL device is returned by this method, a 404 error will be returned to the client.

Parameters

  path | the HTTP path sent by the client (this could also include a fragment and/or a query, see QUrl)
  contentType | output variable, your method should set it to the content type header to send back with the file. For instance "text/plain" for a plain text file.

Returns
  an iodevice for reading from. For instance a new QFile. KDSoap will delete the iodevice after reading all its contents.

Since
  1.3

Definition at line 65 of file KDSoapServerObjectInterface.cpp.

## ◆ processRequest()

void KDSoapServerObjectInterface::processRequest | ( | const KDSoapMessage & | request,
|  | KDSoapMessage & | response,
|  | const QByteArray & | soapAction
| ) |  |
| virtual

Handle `request` and return `response`. The default implementation in this base class is to simply return a fault "method not found". Subclasses must implement the dispatching to actual implementation methods.

This method is called when calls are made to the default path for the server, as configured in KDSoapServer. For other paths, see processRequestWithPath().

When using kdwsdl2cpp to generate the server-side code, this is the method that will be generated, so that you don't have to implement it, only the pure virtual methods called by processRequest.

Definition at line 57 of file KDSoapServerObjectInterface.cpp.

References KDSoapMessage::createFaultMessage(), QString::fromLatin1(), KDSoapValue::name(), KDSoap::SOAP1_1, and soapAction().

## ◆ processRequestWithPath()

void KDSoapServerObjectInterface::processRequestWithPath | ( | const KDSoapMessage & | request,
|  | KDSoapMessage & | response,
|  | const QByteArray & | soapAction,
|  | const QString & | path
| ) |  |
| virtual

Handle a SOAP request that was sent to a different path than the one configured in KDSoapServer.

Parameters

  request | the incoming SOAP request
  response | the SOAP response to be sent back
  soapAction | the SOAP action string sent by the client
  path | the HTTP path sent by the client (this could also include a fragment and/or a query, see QUrl)

Note that a GET request with Accept="application/soap+xml" will trigger a call to this method with an empty incoming soap request, in order to make it possible to return SOAP responses. This is as documented in https://www.ibm.com/developerworks/xml/library/x-tipgetr/.

The default implementation in this base class is to simply return a fault "method not found". Subclasses must implement the dispatching to actual implementation methods. Usually this will be done by calling processRequest on other KDSoapServerObjectInterface instances, for instance generated by kdwsdl2cpp.

Since
  1.3

Definition at line 72 of file KDSoapServerObjectInterface.cpp.

References KDSoapMessage::createFaultMessage(), QString::fromLatin1(), KDSoapValue::name(), KDSoap::SOAP1_1, and soapAction().

## ◆ requestHeaders()

KDSoapHeaders KDSoapServerObjectInterface::requestHeaders | ( |  | ) | const

Returns the SOAP headers that were provided together with the SOAP request. This can be used to retrieve authentication headers, or any kind of session (per-client) data.

Definition at line 145 of file KDSoapServerObjectInterface.cpp.

## ◆ sendDelayedResponse()

void KDSoapServerObjectInterface::sendDelayedResponse | ( | const KDSoapDelayedResponseHandle & | responseHandle,
|  | const KDSoapMessage & | response
| ) |  |

Send a delayed response.

Parameters

  responseHandle | the identifier of the call we are responding to
  response | the response message for that call

Since
  1.2

Definition at line 184 of file KDSoapServerObjectInterface.cpp.

References KDSoapServerSocket::sendDelayedReply().

## ◆ serverSocket()

QAbstractSocket * KDSoapServerObjectInterface::serverSocket | ( |  | ) | const

Returns a pointer to the server socket. Only valid during processRequest(). This can be used to retrieve information from the server socket, such as peerAddress etc.

Since
  1.3

Definition at line 140 of file KDSoapServerObjectInterface.cpp.

## ◆ setFault() [1/2]

void KDSoapServerObjectInterface::setFault | ( | const QString & | faultCode,
|  | const QString & | faultString,
|  | const QString & | faultActor,
|  | const KDSoapValue & | detail
| ) |  |

Instructs KD SOAP to return a fault message instead of the return value of the slot.

Parameters

  faultCode | A code for identifying the fault. Example: "Server.EntryNotFound", or "Client.Authentication". Must not be empty.
  faultString | A human-readable explanation of the fault
  faultActor | Information about who caused the fault to happen
  detail | Holds application-specific error information related to the Body element, it is given as a KDSoapValue and hence can be parsed

See https://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383507 for more details.

Definition at line 110 of file KDSoapServerObjectInterface.cpp.

References QString::isEmpty().

## ◆ setFault() [2/2]

void KDSoapServerObjectInterface::setFault | ( | const QString & | faultCode,
|  | const QString & | faultString,
|  | const QString & | faultActor = `QString()`,
|  | const QString & | detail = `QString()`
| ) |  |

Instructs KD SOAP to return a fault message instead of the return value of the slot.

Parameters

  faultCode | A code for identifying the fault. Example: "Server.EntryNotFound", or "Client.Authentication". Must not be empty.
  faultString | A human-readable explanation of the fault
  faultActor | Information about who caused the fault to happen
  detail | Holds application-specific error information related to the Body element

See https://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383507 for more details.

Definition at line 101 of file KDSoapServerObjectInterface.cpp.

References QString::isEmpty().

## ◆ setResponseHeaders()

void KDSoapServerObjectInterface::setResponseHeaders | ( | const KDSoapHeaders & | headers | ) |

Sets the soap headers to be sent in the response

Definition at line 159 of file KDSoapServerObjectInterface.cpp.

## ◆ setResponseNamespace()

void KDSoapServerObjectInterface::setResponseNamespace | ( | const QString & | ns | ) |

Sets the message namespace to be used in the response. If the requests comes with a message namespace("qualified"), then this can be determined from that namespace. But if the request is not qualified, this is very much necessary (at least when the response has headers, which are always qualified).

Since
  1.2

Definition at line 204 of file KDSoapServerObjectInterface.cpp.

## ◆ soapAction()

QByteArray KDSoapServerObjectInterface::soapAction | ( |  | ) | const

Returns the "Soap Action" header sent by the client.

Definition at line 169 of file KDSoapServerObjectInterface.cpp.

Referenced by processRequest(), and processRequestWithPath().

## ◆ writeHTTP()

void KDSoapServerObjectInterface::writeHTTP | ( | const QByteArray & | httpReply | ) |

Low-level method, not needed for normal operations. Call this method to write an HTTP reply back, e.g. in case of an error. Example: writeHTTP("HTTP/1.1 404 Not Found\r\nContent-Length: 0\r\n\r\n");

Since
  1.5

Definition at line 192 of file KDSoapServerObjectInterface.cpp.

References QByteArray::size().

## ◆ writeXML()

void KDSoapServerObjectInterface::writeXML | ( | const QByteArray & | reply,
|  | bool | isFault = `false`
| ) |  |

Low-level method, not needed for normal operations. Call this method to write an XML reply back. KDSoapServer will take care of the necessary HTTP headers.

Parameters

  reply | the SOAP reply in XML
  isFault | true if the reply is a fault (which means sending back the HTTP error code 500, as per the specification)

Since
  1.5

Definition at line 199 of file KDSoapServerObjectInterface.cpp.

The documentation for this class was generated from the following files:

- KDSoapServerObjectInterface.h
- KDSoapServerObjectInterface.cpp

© 2010-2024 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-soap/
Generated on Sun Jan 7 2024 11:47:36 for KD SOAP API Documentation by doxygen 1.9.8