本文整理汇总了C++中KDSoapMessage::addArgument方法的典型用法代码示例。如果您正苦于以下问题:C++ KDSoapMessage::addArgument方法的具体用法?C++ KDSoapMessage::addArgument怎么用?C++ KDSoapMessage::addArgument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDSoapMessage
的用法示例。
在下文中一共展示了KDSoapMessage::addArgument方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()*/;
response.setFault(true);
response.addArgument(QString::fromLatin1("faultcode"), QString::fromLatin1("Server.MethodNotFound"));
response.addArgument(QString::fromLatin1("faultstring"), QString::fromLatin1("%1 not found").arg(method));
}
示例3: 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));
}
示例4: 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>
}
示例5: main
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
const int year = 2009;
const QString endPoint = QLatin1String("http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx");
const QString messageNamespace = QLatin1String("http://www.27seconds.com/Holidays/US/Dates/");
KDSoapClientInterface client(endPoint, messageNamespace);
KDSoapMessage message;
message.setQualified(true);
message.addArgument(QLatin1String("year"), year);
qDebug("Looking up the date of Valentine's Day in %i...", year);
KDSoapMessage response = client.call(QLatin1String("GetValentinesDay"), message);
if (response.isFault())
printf("%s\n", qPrintable(response.faultAsString()));
else
printf("%s\n", qPrintable(response.arguments()[0].value().toString()));
return 0;
}
示例6: shouldWriteAProperSoapMessageWithRightsAddressingProperties
void shouldWriteAProperSoapMessageWithRightsAddressingProperties()
{
// GIVEN
HttpServerThread server(emptyResponse(), HttpServerThread::Public);
KDSoapClientInterface client(server.endPoint(), "http://www.ecerami.com/wsdl/HelloService");
KDSoapMessage message;
KDSoapMessageAddressingProperties map;
// with some message addressing properties
map.setAction("sayHello");
map.setDestination("http://www.ecerami.com/wsdl/HelloService");
map.setSourceEndpointAddress("http://www.ecerami.com/wsdl/source");
map.setFaultEndpoint(KDSoapEndpointReference("http://www.ecerami.com/wsdl/fault"));
map.setMessageID("uuid:e197db59-0982-4c9c-9702-4234d204f7f4");
map.setReplyEndpointAddress(KDSoapMessageAddressingProperties::predefinedAddressToString(KDSoapMessageAddressingProperties::Anonymous));
// two relationships related to previous message
KDSoapMessageRelationship::Relationship relationship("uuid:http://www.ecerami.com/wsdl/someUniqueString"); // no type means implicit Reply
KDSoapMessageRelationship::Relationship relationshipBis("uuid:http://www.ecerami.com/wsdl/someUniqueStringBis", "CustomTypeReply");
map.addRelationship(relationship);
map.addRelationship(relationshipBis);
// some reference parameters...
// one with a value
KDSoapValue refParam("myReferenceParameter", "ReferencParameterContent");
map.addReferenceParameter(refParam);
// an other one, with children
KDSoapValue childOne("myReferenceParameterChildOne", "ChildOneContent");
KDSoapValue childTwo("myReferenceParameterChildTwo", "ChildTwoContent");
KDSoapValueList childrenList;
childrenList << childOne << childTwo;
KDSoapValue refParamWithChildren("myReferenceParameterWithChildren", childrenList);
map.addReferenceParameter(refParamWithChildren);
// some metadata
KDSoapValueList metadataContainer;
KDSoapValue metadata("myMetadata", "MetadataContent");
metadataContainer << metadata;
KDSoapValue child("myMetadataBisChild", "MetadataBisChildContent");
KDSoapValueList childList; childList << child;
KDSoapValue metadataBis("myMetadataBis", childList);
map.setMetadata(metadataContainer);
map.addMetadata(metadataBis);
// and some request content
const QString action = QString::fromLatin1("sayHello");
message.setUse(KDSoapMessage::EncodedUse);
message.addArgument(QString::fromLatin1("msg"), QVariant::fromValue(QString("HelloContentMessage")), KDSoapNamespaceManager::xmlSchema2001(), QString::fromLatin1("string"));
message.setNamespaceUri(QString::fromLatin1("http://www.ecerami.com/wsdl/HelloService.wsdl"));
// WHEN
message.setMessageAddressingProperties(map);
KDSoapMessage reply = client.call(QLatin1String("sayHello"), message, action);
// THEN
QVERIFY(xmlBufferCompare(server.receivedData(), expectedSoapMessage()));
}
示例7: testRequestXml
void testRequestXml() // this tests the serialization of KDSoapValue[List] in KDSoapClientInterface
{
HttpServerThread server(emptyResponse(), HttpServerThread::Public);
KDSoapClientInterface client(server.endPoint(), countryMessageNamespace());
KDSoapMessage message;
message.setUse(KDSoapMessage::EncodedUse); // write out types explicitely
// Test simpletype element
message.addArgument(QString::fromLatin1("testString"), QString::fromUtf8("Hello Klarälvdalens"));
// Test simpletype extended to have an attribute
KDSoapValue val(QString::fromLatin1("val"), 5, countryMessageNamespace(), QString::fromLatin1("MyVal"));
val.childValues().attributes().append(KDSoapValue(QString::fromLatin1("attr"), QString::fromLatin1("attrValue")));
message.arguments().append(val);
// Test complextype with child elements and attributes
KDSoapValueList valueList;
KDSoapValue orderperson(QString::fromLatin1("orderperson"), QString::fromLatin1("someone"), countryMessageNamespace(), QString::fromLatin1("Person"));
valueList.append(orderperson);
valueList.attributes().append(KDSoapValue(QString::fromLatin1("attr"), QString::fromLatin1("attrValue")));
message.addArgument(QString::fromLatin1("order"), valueList, countryMessageNamespace(), QString::fromLatin1("MyOrder"));
// Code from documentation
QRect rect(0, 0, 100, 200);
KDSoapValueList rectArgument;
rectArgument.addArgument(QLatin1String("x"), rect.x());
rectArgument.addArgument(QLatin1String("y"), rect.y());
rectArgument.addArgument(QLatin1String("width"), rect.width());
rectArgument.addArgument(QLatin1String("height"), rect.height());
message.addArgument(QLatin1String("rect"), rectArgument); // NOTE: type information is missing; setQualified() is missing too.
const QString XMLSchemaNS = KDSoapNamespaceManager::xmlSchema2001();
// Test array
KDSoapValueList arrayContents;
arrayContents.setArrayType(XMLSchemaNS, QString::fromLatin1("string"));
arrayContents.append(KDSoapValue(QString::fromLatin1("item"), QString::fromLatin1("kdab"), XMLSchemaNS, QString::fromLatin1("string")));
arrayContents.append(KDSoapValue(QString::fromLatin1("item"), QString::fromLatin1("rocks"), XMLSchemaNS, QString::fromLatin1("string")));
message.addArgument(QString::fromLatin1("testArray"), arrayContents, QString::fromLatin1("http://schemas.xmlsoap.org/soap/encoding/"), QString::fromLatin1("Array"));
// Add a header
KDSoapMessage header1;
header1.setUse(KDSoapMessage::EncodedUse);
header1.addArgument(QString::fromLatin1("header1"), QString::fromLatin1("headerValue"));
KDSoapHeaders headers;
headers << header1;
client.call(QLatin1String("test"), message, QString::fromLatin1("MySoapAction"), headers);
// Check what we sent
QByteArray expectedRequestXml =
QByteArray(xmlEnvBegin11()) +
" xmlns:n1=\"http://www.kdab.com/xml/MyWsdl/\""
"><soap:Header>"
"<n1:header1 xsi:type=\"xsd:string\">headerValue</n1:header1>"
"</soap:Header>";
const QByteArray expectedRequestBody =
QByteArray("<soap:Body>"
"<n1:test>"
"<testString xsi:type=\"xsd:string\">Hello Klarälvdalens</testString>"
"<val xsi:type=\"n1:MyVal\" attr=\"attrValue\">5</val>"
"<order xsi:type=\"n1:MyOrder\" attr=\"attrValue\"><orderperson xsi:type=\"n1:Person\">someone</orderperson></order>"
"<rect><x xsi:type=\"xsd:int\">0</x><y xsi:type=\"xsd:int\">0</y><width xsi:type=\"xsd:int\">100</width><height xsi:type=\"xsd:int\">200</height></rect>"
"<testArray xsi:type=\"soap-enc:Array\" soap-enc:arrayType=\"xsd:string[2]\">"
"<item xsi:type=\"xsd:string\">kdab</item>"
"<item xsi:type=\"xsd:string\">rocks</item>"
"</testArray>"
"</n1:test>"
"</soap:Body>") + xmlEnvEnd()
+ '\n'; // added by QXmlStreamWriter::writeEndDocument
QVERIFY(xmlBufferCompare(server.receivedData(), expectedRequestXml + expectedRequestBody));
// Now using persistent headers
server.resetReceivedBuffers();
client.setHeader(QLatin1String("header1"), header1);
client.call(QLatin1String("test"), message, QString::fromLatin1("MySoapAction"));
QVERIFY(xmlBufferCompare(server.receivedData(), expectedRequestXml + expectedRequestBody));
// Now remove the persistent header (using setHeader + empty message)
server.resetReceivedBuffers();
client.setHeader(QLatin1String("header1"), KDSoapMessage());
client.call(QLatin1String("test"), message, QString::fromLatin1("MySoapAction"));
const QByteArray expectedRequestXmlNoHeader =
QByteArray(xmlEnvBegin11()) +
" xmlns:n1=\"http://www.kdab.com/xml/MyWsdl/\""
"><soap:Header/>"; // the empty element does not matter
QVERIFY(xmlBufferCompare(server.receivedData(), expectedRequestXmlNoHeader + expectedRequestBody));
}