• 4198阅读
  • 2回复

QHttp WebService返回值? [复制链接]

上一主题 下一主题
离线hats
 

只看楼主 正序阅读 楼主  发表于: 2012-01-08
— 本帖被 XChinux 从 Qt基础编程 移动到本区(2012-01-09) —
要用c++调用C#写的WebService,现在能用Qhttp直接发送XML字符串调用成功,但是取不到返回值。
用信号responseHeaderReceived const QHttpResponseHeader & resp )readyRead ( const QHttpResponseHeader & resp )


都只取到返回的头部信息,用QHttp::readAll没读取成功。
代码大概是这样:
  1. QUrl url(urlLineEdit->text());
  2.     QHttpRequestHeader header("POST", url.path() );
  3.     header.setValue("Host", url.host() );
  4.     header.setContentType("text/xml; charset=utf-8");
  5.     header.setValue("SOAPAction", ""http://tempuri.org/HelloWorld"");
  6.     QString content("<?xml version="1.0" encoding="utf-8"?>"
  7.                     "<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/">"
  8.                     "  <soap:Body>"
  9.                     "    <HelloWorld xmlns="http://tempuri.org/">sdafwer</HelloWorld>"
  10.                     "  </soap:Body>"
  11.                     "</soap:Envelope>"
  12.                     );
  13.     //header.setValue("Content-Length", tr("%1").arg(11) );
  14.     http->setHost( url.host() );
  15.     httpRequestAborted = false;
  16.      httpGetId = http->request( header, content.toUtf8 (), buffer);





怎样用QHttp取WebService的返回值啊?
VC2005 + Qt 4.7.0
VC6 + Qt 4.5.0
WIndows XP
Mac OS X 10.6.8
CentOS6.2
离线hats

只看该作者 2楼 发表于: 2012-01-09
好像可以取到了。
VC2005 + Qt 4.7.0
VC6 + Qt 4.5.0
WIndows XP
Mac OS X 10.6.8
CentOS6.2
离线wxj120bw

只看该作者 1楼 发表于: 2012-01-09
回 楼主(hats) 的帖子
最好用监测工具wireshark查看到底有没有回复 然后qt4最好用qnetworkmanager类来操作http请求
快速回复
限100 字节
 
上一个 下一个