KD SOAP API Documentation: KDSoapUdpClient Class Reference

| KD SOAP API Documentation 2.2

Loading...
Searching...
No Matches
Public Slots | Signals | Public Member Functions | List of all members
KDSoapUdpClient Class Reference

KDSoapUdpClient provides an interface for implementing a SOAP-over-UDP client. More...

`#include <KDSoapUdpClient.h>`

Inheritance diagram for KDSoapUdpClient:
[legend]
Collaboration diagram for KDSoapUdpClient:
[legend]

## Public Slots
bool | sendMessage (const KDSoapMessage &message, const KDSoapHeaders &headers, const QHostAddress &address, quint16 port)

## Signals
void | receivedMessage (const KDSoapMessage &message, const KDSoapHeaders &headers, const QHostAddress &address, quint16 port)

## Public Member Functions
| KDSoapUdpClient (QObject *parent=nullptr)
| ~KDSoapUdpClient ()
bool | bind (quint16 port=0, QAbstractSocket::BindMode mode=QAbstractSocket::DefaultForPlatform)
void | setSoapVersion (KDSoap::SoapVersion version)
Public Member Functions inherited from QObject
| QObject (QObject *parent)
virtual | ~QObject ()
bool | blockSignals (bool block)
const QObjectList & | children () const const
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
void | deleteLater ()
void | destroyed (QObject *obj)
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const
bool | disconnect (const QObject *receiver, const char *method) const const
void | dumpObjectInfo ()
void | dumpObjectInfo () const const
void | dumpObjectTree ()
void | dumpObjectTree () const const
QList< QByteArray > | dynamicPropertyNames () const const
virtual bool | event (QEvent *e)
virtual bool | eventFilter (QObject *watched, QEvent *event)
T | findChild (const QString &name, Qt::FindChildOptions options) const const
QList< T > | findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const
bool | inherits (const char *className) const const
void | installEventFilter (QObject *filterObj)
bool | isWidgetType () const const
bool | isWindowType () const const
void | killTimer (int id)
virtual const QMetaObject * | metaObject () const const
void | moveToThread (QThread *targetThread)
QString | objectName () const const
void | objectNameChanged (const QString &objectName)
QObject * | parent () const const
QVariant | property (const char *name) const const
| Q_CLASSINFO (Name, Value)
| Q_DISABLE_COPY (Class)
| Q_DISABLE_COPY_MOVE (Class)
| Q_DISABLE_MOVE (Class)
| Q_EMIT Q_EMIT
| Q_ENUM (...)
| Q_ENUM_NS (...)
| Q_ENUMS (...)
| Q_FLAG (...)
| Q_FLAG_NS (...)
| Q_FLAGS (...)
| Q_GADGET Q_GADGET
| Q_INTERFACES (...)
| Q_INVOKABLE Q_INVOKABLE
| Q_NAMESPACE Q_NAMESPACE
| Q_NAMESPACE_EXPORT (EXPORT_MACRO)
| Q_OBJECT Q_OBJECT
| Q_PROPERTY (...)
| Q_REVISION Q_REVISION
| Q_SET_OBJECT_NAME (Object)
| Q_SIGNAL Q_SIGNAL
| Q_SIGNALS Q_SIGNALS
| Q_SLOT Q_SLOT
| Q_SLOTS Q_SLOTS
T | qFindChild (const QObject *obj, const QString &name)
QList< T > | qFindChildren (const QObject *obj, const QRegExp &regExp)
QList< T > | qFindChildren (const QObject *obj, const QString &name)
T | qobject_cast (const QObject *object)
T | qobject_cast (QObject *object)
| QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
void | removeEventFilter (QObject *obj)
void | setObjectName (const QString &name)
void | setParent (QObject *parent)
bool | setProperty (const char *name, const QVariant &value)
bool | signalsBlocked () const const
int | startTimer (int interval, Qt::TimerType timerType)
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
QThread * | thread () const const

## Additional Inherited Members
Static Public Member Functions inherited from QObject
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool | disconnect (const QMetaObject::Connection &connection)
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
QString | tr (const char *sourceText, const char *disambiguation, int n)
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n)
Public Attributes inherited from QObject
typedef | QObjectList
Protected Member Functions inherited from QObject
virtual void | childEvent (QChildEvent *event)
virtual void | connectNotify (const QMetaMethod &signal)
virtual void | customEvent (QEvent *event)
virtual void | disconnectNotify (const QMetaMethod &signal)
bool | isSignalConnected (const QMetaMethod &signal) const const
int | receivers (const char *signal) const const
QObject * | sender () const const
int | senderSignalIndex () const const
virtual void | timerEvent (QTimerEvent *event)
Properties inherited from QObject
| objectName

## Detailed Description

KDSoapUdpClient provides an interface for implementing a SOAP-over-UDP client.

One-way SOAP-over-UDP can be send by simply using sendMessage().

Request-response SOAP-over-UDP is supported by bind()ing to a sender UDP port. You can send the request using sendMessage() and the response will is signaled using receivedMessage(). receivedMessage() will signal any response, including those of other requests, there is no help with finding the correct response. The WS-Addressing properties of the message can be used to filter the received responses.

auto soapUdpClient = new KDSoapUdpClient(this);
connect(soapUdpClient, &KDSoapUdpClient::receivedMessage, [=](const KDSoapMessage &message, const KDSoapHeaders &headers, const QHostAddress
&address, quint16 port) { if(message.messageAddressingProperties().action() ==
QStringLiteral("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ProbeMatches")) { TNS__ProbeMatchesType probeMatches;
probeMatches.deserialize(message);
qDebug() << "Received probe match from" << address;
}
});
soapUdpClient->bind(3702);
TNS__ProbeType probe;
KDSoapMessage message;
message = probe.serialize(QStringLiteral("Probe"));
message.setUse(KDSoapMessage::LiteralUse);
message.setNamespaceUri(QStringLiteral("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01"));
KDSoapMessageAddressingProperties addressing;
addressing.setAction(QStringLiteral("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Probe"));
addressing.setMessageID(QStringLiteral("urn:uuid:") + QUuid::createUuid().toString(QUuid::WithoutBraces)); // WithoutBraces requires Qt 5.11
addressing.setDestination(QStringLiteral("urn:docs-oasis-open-org:ws-dd:ns:discovery:2009:01"));
addressing.setReplyEndpointAddress(KDSoapMessageAddressingProperties::predefinedAddressToString(KDSoapMessageAddressingProperties::Anonymous));
message.setMessageAddressingProperties(addressing);
soapUdpClient->sendMessage(message, KDSoapHeaders(), QHostAddress("239.255.255.250"), 3702);
KDSoapHeaders
Definition KDSoapMessage.h:185
KDSoapMessageAddressingProperties
Definition KDSoapMessageAddressingProperties.h:76
KDSoapMessageAddressingProperties::Anonymous
@ Anonymous
Definition KDSoapMessageAddressingProperties.h:89
KDSoapMessageAddressingProperties::setAction
void setAction(const QString &action)
Definition KDSoapMessageAddressingProperties.cpp:69
KDSoapMessageAddressingProperties::predefinedAddressToString
static QString predefinedAddressToString(KDSoapAddressingPredefinedAddress address, KDSoapAddressingNamespace addressingNamespace=Addressing200508)
Definition KDSoapMessageAddressingProperties.cpp:207
KDSoapMessageAddressingProperties::action
QString action() const
Definition KDSoapMessageAddressingProperties.cpp:64
KDSoapMessage
Definition KDSoapMessage.h:29
KDSoapMessage::setMessageAddressingProperties
void setMessageAddressingProperties(const KDSoapMessageAddressingProperties &map)
Definition KDSoapMessage.cpp:179
KDSoapMessage::setUse
void setUse(Use use)
Definition KDSoapMessage.cpp:195
KDSoapMessage::messageAddressingProperties
KDSoapMessageAddressingProperties messageAddressingProperties() const
Definition KDSoapMessage.cpp:174
KDSoapUdpClient
KDSoapUdpClient provides an interface for implementing a SOAP-over-UDP client.
Definition KDSoapUdpClient.h:71
KDSoapUdpClient::receivedMessage
void receivedMessage(const KDSoapMessage &message, const KDSoapHeaders &headers, const QHostAddress &address, quint16 port)
KDSoapValue::LiteralUse
@ LiteralUse
data is serialized according to a given schema, no xsi:type attributes are written out
Definition KDSoapValue.h:267
KDSoapValue::setNamespaceUri
void setNamespaceUri(const QString &ns)
Definition KDSoapValue.cpp:462
QHostAddress
QObject::connect
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject::qobject_cast
T qobject_cast(QObject *object)
QUuid::WithoutBraces
WithoutBraces
QUuid::createUuid
QUuid createUuid()
QUuid::toString
QString toString() const const

Since
  1.9

Definition at line 70 of file KDSoapUdpClient.h.

## Constructor & Destructor Documentation

## ◆ KDSoapUdpClient()

KDSoapUdpClient::KDSoapUdpClient | ( | QObject * | parent = `nullptr` | ) |
| explicit

Definition at line 29 of file KDSoapUdpClient.cpp.

References QObject::connect(), QObject::qobject_cast(), KDSoapUdpClientPrivate::readyRead(), and QIODevice::readyRead().

## ◆ ~KDSoapUdpClient()

KDSoapUdpClient::~KDSoapUdpClient | ( |  | ) |

Definition at line 38 of file KDSoapUdpClient.cpp.

## Member Function Documentation

## ◆ bind()

bool KDSoapUdpClient::bind | ( | quint16 | port = `0`,
|  | QAbstractSocket::BindMode | mode = `QAbstractSocket::DefaultForPlatform`
| ) |  |

Bind UDP socket to port. This is needed to receive messages. Both the IPv4 and IPv6 port will be bound.

Parameters

  port | The UDP port to bind to. When port is 0, a random port is chosen.
  mode | This is passed directly to QUdpSocket::bind().

See also
  receivedMessage()

Since
  1.9

Definition at line 43 of file KDSoapUdpClient.cpp.

References QHostAddress::Any, and QObject::qobject_cast().

## ◆ receivedMessage

void KDSoapUdpClient::receivedMessage | ( | const KDSoapMessage & | message,
|  | const KDSoapHeaders & | headers,
|  | const QHostAddress & | address,
|  | quint16 | port
| ) |  |
| signal

emitted when a SOAP-over-UDP message is received over a bound socket. KDSoapUdpClient doesn't do any filtering, so duplicate messages, spoofed or responses to other requests will all be received. For example, if a message is send via both IPv4 and IPv6, then the receivedMessage will be emitted twice (with the same message, but with a different address)

Parameters

  message | The parsed message received over the socket. Use KDSoapMessage::messageAddressingProperties() to see who the recipient is and what SOAP action is requested.
  headers | The additional headers of the message
  address | The IP-address of the sender
  port | The UDP port of the sender

See also
  bind()

Since
  1.9

## ◆ sendMessage

bool KDSoapUdpClient::sendMessage | ( | const KDSoapMessage & | message,
|  | const KDSoapHeaders & | headers,
|  | const QHostAddress & | address,
|  | quint16 | port
| ) |  |
| slot

Send a SOAP-over-UDP message to IP address.

Parameters

  message | The actual message to be send. Use KDSoapMessage::setMessageAddressingProperties() to set the WS-Addressing properties of the message.
  headers | can be used to add additional SOAP headers.
  address | The address to send to message to. Messages send to a multicast address will be send to all interfaces.
  port | The UDP port to send the message to

Since
  1.9

Definition at line 59 of file KDSoapUdpClient.cpp.

References QNetworkInterface::allInterfaces(), QNetworkInterface::CanMulticast, isMulticastAddress(), QNetworkInterface::IsUp, QObject::qobject_cast(), KDSoapMessageWriter::setVersion(), and QByteArray::size().

## ◆ setSoapVersion()

void KDSoapUdpClient::setSoapVersion | ( | KDSoap::SoapVersion | version | ) |

Sets the SOAP version to be used for any subsequent send message.

Parameters

  version | SOAP1_1 or SOAP1_2 The default version is SOAP 1.2.

Definition at line 53 of file KDSoapUdpClient.cpp.

References QObject::qobject_cast().

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

- KDSoapUdpClient.h
- KDSoapUdpClient.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