KD SOAP API Documentation  2.1
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:
Inheritance graph
[legend]
Collaboration diagram for KDSoapUdpClient:
Collaboration graph
[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)
 

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.setNamespaceUri(QStringLiteral("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01"));
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"));
message.setMessageAddressingProperties(addressing);
soapUdpClient->sendMessage(message, KDSoapHeaders(), QHostAddress("239.255.255.250"), 3702);
void setReplyEndpointAddress(const QString &replyEndpoint)
static QString predefinedAddressToString(KDSoapAddressingPredefinedAddress address, KDSoapAddressingNamespace addressingNamespace=Addressing200508)
void setMessageAddressingProperties(const KDSoapMessageAddressingProperties &map)
void setUse(Use use)
KDSoapMessageAddressingProperties messageAddressingProperties() const
void receivedMessage(const KDSoapMessage &message, const KDSoapHeaders &headers, const QHostAddress &address, quint16 port)
KDSoapUdpClient(QObject *parent=nullptr)
@ LiteralUse
data is serialized according to a given schema, no xsi:type attributes are written out
Definition: KDSoapValue.h:267
void setNamespaceUri(const QString &ns)
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 KDSoapUdpClientPrivate::readyRead().

◆ ~KDSoapUdpClient()

KDSoapUdpClient::~KDSoapUdpClient ( )

Definition at line 40 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
portThe UDP port to bind to. When port is 0, a random port is chosen.
modeThis is passed directly to QUdpSocket::bind().
See also
receivedMessage()
Since
1.9

Definition at line 45 of file KDSoapUdpClient.cpp.

◆ 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
messageThe parsed message received over the socket. Use KDSoapMessage::messageAddressingProperties() to see who the recipient is and what SOAP action is requested.
headersThe additional headers of the message
addressThe IP-address of the sender
portThe 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
messageThe actual message to be send. Use KDSoapMessage::setMessageAddressingProperties() to set the WS-Addressing properties of the message.
headerscan be used to add additional SOAP headers.
addressThe address to send to message to. Messages send to a multicast address will be send to all interfaces.
portThe UDP port to send the message to
Since
1.9

Definition at line 64 of file KDSoapUdpClient.cpp.

References isMulticastAddress(), KDSoapMessageWriter::messageToXml(), and KDSoapMessageWriter::setVersion().

◆ setSoapVersion()

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

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

Parameters
versionSOAP1_1 or SOAP1_2 The default version is SOAP 1.2.

Definition at line 58 of file KDSoapUdpClient.cpp.


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

© 2010-2022 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 Tue Jun 13 2023 12:18:34 for KD SOAP API Documentation by doxygen 1.9.1