QT QHttp 访问 WEBSERVICE 范例

http://blog.csdn.net/cangwu_lee/archive/2007/06/04/1637722.aspx

 

根据 SOAP 1.1 标准,POST XML 来访问 WEBSERVICE ,会非常方便,QT 本身有 XML 的解析工具QDomDocument/ QXmlReader。将 POST 的结果进行处理也是非常方便的。

实际应用的时候,只要更改 URL、SOAPAction 、参数、NameSpace 等必要的元素,即可。

        QUrl url(urlLineEdit->text());
    QHttpRequestHeader header("POST", url.path() );
    header.setValue("Host", url.host() );
    header.setContentType("text/xml; charset=utf-8");
    header.setValue("SOAPAction", ""http://tempuri.org/HelloWorld"");

    QString content("<?xml version="1.0" encoding="utf-8"?>"
                    "<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">"
                    "  <soap:Body>"
                    "    <HelloWorld xmlns="http://tempuri.org/">sdafwer</HelloWorld>"
                    "  </soap:Body>"
                    "</soap:Envelope>"
                    );
    //header.setValue("Content-Length", tr("%1").arg(11) );
    http->setHost( url.host() );

    httpRequestAborted = false;
     httpGetId = http->request( header, content.toUtf8 (), buffer);

 本文仅示范如何得到 WEBSERVICE 的结果,没有将结果进行处理。


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/cangwu_lee/archive/2007/06/04/1637722.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值