本文整理汇总了C++中KDSoapMessage类的典型用法代码示例。如果您正苦于以下问题:C++ KDSoapMessage类的具体用法?C++ KDSoapMessage怎么用?C++ KDSoapMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KDSoapMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleError
void KDSoapServerSocket::handleError(KDSoapMessage &replyMsg, const char *errorCode, const QString &error)
{
qWarning("%s", qPrintable(error));
replyMsg.setFault(true);
replyMsg.addArgument(QString::fromLatin1("faultcode"), QString::fromLatin1(errorCode));
replyMsg.addArgument(QString::fromLatin1("faultstring"), error);
}
示例2: processRequest
void KDSoapServerObjectInterface::processRequest(const KDSoapMessage &request, KDSoapMessage &response, const QByteArray &soapAction)
{
const QString method = request.name();
qDebug() << "Slot not found:" << method << "[soapAction =" << soapAction << "]" /* << "in" << metaObject()->className()*/;
const KDSoap::SoapVersion soapVersion = KDSoap::SOAP1_1; // TODO version selection on the server side
response.createFaultMessage(QString::fromLatin1("Server.MethodNotFound"), QString::fromLatin1("%1 not found").arg(method), soapVersion);
}
示例3: makeCall
void KDSoapServerSocket::makeCall(KDSoapServerObjectInterface* serverObjectInterface, const KDSoapMessage &requestMsg, KDSoapMessage& replyMsg, const KDSoapHeaders& requestHeaders, const QByteArray& soapAction, const QString& path)
{
Q_ASSERT(serverObjectInterface);
//const QString method = requestMsg.name();
if (requestMsg.isFault()) {
// Can this happen? Getting a fault as a request !? Doesn't make sense...
// reply with a fault, but we don't even know what main element name to use
// Oh well, just use the incoming fault :-)
replyMsg = requestMsg;
handleError(replyMsg, "Client.Data", QString::fromLatin1("Request was a fault"));
} else {
// Call method on m_serverObject
serverObjectInterface->setRequestHeaders(requestHeaders, soapAction);
KDSoapServer* server = m_owner->server();
if (path != server->path()) {
serverObjectInterface->processRequestWithPath(requestMsg, replyMsg, soapAction, path);
} else {
serverObjectInterface->processRequest(requestMsg, replyMsg, soapAction);
}
if (serverObjectInterface->hasFault()) {
//qDebug() << "Got fault!";
replyMsg.setFault(true);
serverObjectInterface->storeFaultAttributes(replyMsg);
}
}
}
示例4: testParseComplexReply
// Test parsing of complex replies, like with SugarCRM
void testParseComplexReply()
{
HttpServerThread server(complexTypeResponse(), HttpServerThread::Public);
KDSoapClientInterface client(server.endPoint(), countryMessageNamespace());
const KDSoapMessage response = client.call(QLatin1String("getEmployeeCountry"), countryMessage());
QVERIFY(!response.isFault());
QCOMPARE(response.arguments().count(), 1);
const KDSoapValueList lst = response.arguments().first().childValues();
QCOMPARE(lst.count(), 3);
const KDSoapValue id = lst.first();
QCOMPARE(id.name(), QString::fromLatin1("id"));
QCOMPARE(id.value().toString(), QString::fromLatin1("12345"));
const KDSoapValue error = lst.at(1);
QCOMPARE(error.name(), QString::fromLatin1("error"));
const KDSoapValueList errorList = error.childValues();
QCOMPARE(errorList.count(), 3);
const KDSoapValue number = errorList.at(0);
QCOMPARE(number.name(), QString::fromLatin1("number"));
QCOMPARE(number.value().toString(), QString::fromLatin1("0"));
const KDSoapValue name = errorList.at(1);
QCOMPARE(name.name(), QString::fromLatin1("name"));
QCOMPARE(name.value().toString(), QString::fromLatin1("No Error"));
const KDSoapValue description = errorList.at(2);
QCOMPARE(description.name(), QString::fromLatin1("description"));
QCOMPARE(description.value().toString(), QString::fromLatin1("No Error"));
const KDSoapValue array = lst.at(2);
QCOMPARE(array.name(), QString::fromLatin1("testArray"));
//qDebug() << array;
// Code from documentation
const QString sessionId = response.arguments()[0].value().toString();
Q_UNUSED(sessionId);
}
示例5: processRequest
void KDSoapServerObjectInterface::processRequest(const KDSoapMessage &request, KDSoapMessage& response, const QByteArray& soapAction)
{
const QString method = request.name();
qDebug() << "Slot not found:" << method << "[soapAction =" << soapAction << "]" /* << "in" << metaObject()->className()*/;
response.setFault(true);
response.addArgument(QString::fromLatin1("faultcode"), QString::fromLatin1("Server.MethodNotFound"));
response.addArgument(QString::fromLatin1("faultstring"), QString::fromLatin1("%1 not found").arg(method));
}
示例6: processRequestWithPath
void KDSoapServerObjectInterface::processRequestWithPath(const KDSoapMessage &request, KDSoapMessage &response, const QByteArray &soapAction, const QString &path)
{
Q_UNUSED(soapAction);
const QString method = request.name();
qWarning("Invalid path: \"%s\"", qPrintable(path));
//qWarning() << "Invalid path:" << path << "[method =" << method << "; soapAction =" << soapAction << "]" /* << "in" << metaObject()->className()*/;
const KDSoap::SoapVersion soapVersion = KDSoap::SOAP1_1; // TODO version selection on the server side
response.createFaultMessage(QString::fromLatin1("Client.Data"), QString::fromLatin1("Method %1 not found in path %2").arg(method, path), soapVersion);
}
示例7: testInvalidUndefinedEntityXML
void testInvalidUndefinedEntityXML()
{
HttpServerThread server(QByteArray(xmlEnvBegin11()) + "><soap:Body>&doesnotexist;</soap:Body>" + xmlEnvEnd() + '\n', HttpServerThread::Public);
KDSoapClientInterface client(server.endPoint(), QString::fromLatin1("urn:msg"));
KDSoapMessage message;
KDSoapMessage ret = client.call(QLatin1String("Method1"), message);
QVERIFY(ret.isFault());
QCOMPARE(ret.faultAsString(), QString::fromLatin1(
"Fault code 3: XML error: [1:291] Entity 'doesnotexist' not declared."));
}
示例8: testFault
void testFault() // HTTP error, creates fault on client side
{
HttpServerThread server(QByteArray(), HttpServerThread::Public | HttpServerThread::Error404);
KDSoapClientInterface client(server.endPoint(), QString::fromLatin1("urn:msg"));
KDSoapMessage message;
KDSoapMessage ret = client.call(QLatin1String("Method1"), message);
QVERIFY(ret.isFault());
QCOMPARE(ret.faultAsString(), QString::fromLatin1(
"Fault code 203: Error downloading %1 - server replied: Not Found").arg(server.endPoint()));
}
示例9: kWarning
void FetchEntryJob::Private::getEntryError(const KDSoapMessage &fault)
{
if (!q->handleLoginError(fault)) {
kWarning() << "Fetch Entry Error:" << fault.faultAsString();
q->setError(SugarJob::SoapError);
q->setErrorText(fault.faultAsString());
q->emitResult();
}
}
示例10: testInvalidXML
void testInvalidXML()
{
HttpServerThread server(QByteArray(xmlEnvBegin11()) + "><soap:Body><broken></xml></soap:Body>", HttpServerThread::Public);
KDSoapClientInterface client(server.endPoint(), QString::fromLatin1("urn:msg"));
KDSoapMessage message;
KDSoapMessage ret = client.call(QLatin1String("Method1"), message);
QVERIFY(ret.isFault());
QCOMPARE(ret.faultAsString(), QString::fromLatin1(
"Fault code 3: XML error: [1:354] Opening and ending tag mismatch."));
}
示例11: processRequestWithPath
void KDSoapServerObjectInterface::processRequestWithPath(const KDSoapMessage &request, KDSoapMessage &response, const QByteArray &soapAction, const QString &path)
{
Q_UNUSED(soapAction);
const QString method = request.name();
qWarning("Invalid path: \"%s\"", qPrintable(path));
//qWarning() << "Invalid path:" << path << "[method =" << method << "; soapAction =" << soapAction << "]" /* << "in" << metaObject()->className()*/;
response.setFault(true);
response.addArgument(QString::fromLatin1("faultcode"), QString::fromLatin1("Client.Data"));
response.addArgument(QString::fromLatin1("faultstring"), QString::fromLatin1("Method %1 not found in path %2").arg(method, path));
}
示例12: testCallRefusedAuth
// Test for refused auth, with sync call (i.e. in thread)
void testCallRefusedAuth()
{
HttpServerThread server(countryResponse(), HttpServerThread::BasicAuth);
KDSoapClientInterface client(server.endPoint(), countryMessageNamespace());
KDSoapAuthentication auth;
auth.setUser(QLatin1String("kdab"));
auth.setPassword(QLatin1String("invalid"));
client.setAuthentication(auth);
KDSoapMessage reply = client.call(QLatin1String("getEmployeeCountry"), countryMessage());
QVERIFY(reply.isFault());
}
示例13: sendReply
void KDSoapServerSocket::sendReply(KDSoapServerObjectInterface* serverObjectInterface, const KDSoapMessage& replyMsg)
{
const bool isFault = replyMsg.isFault();
QByteArray xmlResponse;
if (!replyMsg.isNull()) {
KDSoapMessageWriter msgWriter;
// Note that the kdsoap client parsing code doesn't care for the name (except if it's fault), even in
// Document mode. Other implementations do, though.
QString responseName = isFault ? QString::fromLatin1("Fault") : replyMsg.name();
if (responseName.isEmpty())
responseName = m_method;
QString responseNamespace = m_messageNamespace;
KDSoapHeaders responseHeaders;
if (serverObjectInterface) {
responseHeaders = serverObjectInterface->responseHeaders();
if (!serverObjectInterface->responseNamespace().isEmpty()) {
responseNamespace = serverObjectInterface->responseNamespace();
}
}
msgWriter.setMessageNamespace(responseNamespace);
xmlResponse = msgWriter.messageToXml(replyMsg, responseName, responseHeaders, QMap<QString, KDSoapMessage>());
}
const QByteArray response = httpResponseHeaders(isFault, "text/xml", xmlResponse.size());
if (m_doDebug) {
qDebug() << "KDSoapServerSocket: writing" << response << xmlResponse;
}
qint64 written = write(response);
Q_ASSERT(written == response.size()); // Please report a bug if you hit this.
written = write(xmlResponse);
Q_ASSERT(written == xmlResponse.size()); // Please report a bug if you hit this.
Q_UNUSED(written);
// flush() ?
// All done, check if we should log this
KDSoapServer* server = m_owner->server();
const KDSoapServer::LogLevel logLevel = server->logLevel(); // we do this here in order to support dynamic settings changes (at the price of a mutex)
if (logLevel != KDSoapServer::LogNothing) {
if (logLevel == KDSoapServer::LogEveryCall ||
(logLevel == KDSoapServer::LogFaults && isFault)) {
if (isFault)
server->log("FAULT " + m_method.toLatin1() + " -- " + replyMsg.faultAsString().toUtf8() + '\n');
else
server->log("CALL " + m_method.toLatin1() + '\n');
}
}
}
示例14: storeFaultAttributes
void KDSoapServerObjectInterface::storeFaultAttributes(KDSoapMessage& message) const
{
// SOAP 1.1 <faultcode>, <faultstring>, <faultfactor>, <detail>
message.addArgument(QString::fromLatin1("faultcode"), d->m_faultCode);
message.addArgument(QString::fromLatin1("faultstring"), d->m_faultString);
message.addArgument(QString::fromLatin1("faultactor"), d->m_faultActor);
if (d->m_detailValue.isNil() || d->m_detailValue.isNull())
message.addArgument(QString::fromLatin1("detail"), d->m_detail);
else {
KDSoapValueList detailAsList;
detailAsList.append( d->m_detailValue );
message.addArgument(QString::fromLatin1("detail"), detailAsList);
}
// TODO : Answer SOAP 1.2 <Code> , <Reason> , <Node> , <Role> , <Detail>
}
示例15: testDocumentStyle
void testDocumentStyle()
{
HttpServerThread server(countryResponse(), HttpServerThread::Public);
KDSoapClientInterface client(server.endPoint(), countryMessageNamespace());
client.setStyle(KDSoapClientInterface::DocumentStyle);
QByteArray expectedRequestXml = expectedCountryRequest();
KDSoapMessage message;
message = KDSoapValue(QLatin1String("getEmployeeCountry"), QVariant());
KDSoapValueList& args = message.childValues();
args.append(KDSoapValue(QLatin1String("employeeName"), QString::fromUtf8("David Ä Faure")));
{
KDSoapMessage ret = client.call(QLatin1String("UNUSED"), message);
// Check what we sent
QVERIFY(xmlBufferCompare(server.receivedData(), expectedRequestXml));
QVERIFY(!ret.isFault());
QCOMPARE(ret.arguments().child(QLatin1String("employeeCountry")).value().toString(), QString::fromLatin1("France"));
}
}