http://blog.csdn.net/stronghill/article/details/48731253
代码如下
- int Form::getUserFee(const QString& userNo)
- {
- QString sUrl = "http://192.168.0.102:8430/systemsoa/services/ChargeService.ChargeServiceHttpSoap12Endpoint/";
- //sUrl += "getUserTotalArrear?bankCode=08&chgBranch=02129&chgTellerId=02754&userNo=123";
- //sUrl += "getUserTotalArrear";
- //QUrl::toPercentEncoding(sUrl);//进行url编码
- QString bankCode = "08";
- QString chgBranch = "02129";
- QString chgTellerId = "02754";
- int tag = 0;
- //QString url = "http://192.168.0.102:8430/systemsoa/services/ChargeService.ChargeServiceHttpSoap12Endpoint/";
- QString key = "7bf6e35f7a7fe23c891d395a74382b64";
- //QString userNo = "HR000069969";
- QString orderId = "20150923135600";
- QString orders = "20150902135603";
- LogUtil::info("FormEc.getUserFee,userNo=" + userNo);
- CryptoPP::SHA256 sha256;
- //int DigestSize = sha256.DigestSize();
- char byDigest[32];
- QString aa = "0124";
- aa = "bankcode=" + bankCode + "&chgbranch=" + chgBranch + "&chgteller=" + chgTellerId +"&orderid=" + orderId
- + "&userno=" + userNo + "&key=" + key;
- sha256.CalculateDigest((byte*)byDigest, (byte*)aa.toAscii().data(), aa.toAscii().length());
- QByteArray ba = QByteArray::fromRawData(byDigest, 32);
- LogUtil::info("FormEc.getUserFee,sha=" + QString(ba.toHex()));
- QString content = QString("<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" ")
- + "xmlns:web=\"http://webservice.netcharge.ysxn.com\" xmlns:xsd=\"http://model.netcharge.ysxn.com/xsd\">"
- + "<soap:Header/>"
- + "<soap:Body>"
- + "<web:getUserTotalArrear>"
- + "<web:paramObj>"
- + "<xsd:bankCode>" + bankCode + "</xsd:bankCode>"
- + "<xsd:chgBranch>" + chgBranch + "</xsd:chgBranch>"
- + "<xsd:chgTeller>" + chgTellerId + "</xsd:chgTeller>"
- + "<xsd:chgTellerId>" + chgTellerId + "</xsd:chgTellerId>"
- + "<xsd:orderid>" + orderId + "</xsd:orderid>"
- + "<xsd:userNo>" + userNo + "</xsd:userNo>"
- + "<xsd:signature>" + QString(ba.toHex()) + "</xsd:signature>"
- + "</web:paramObj>"
- + "</web:getUserTotalArrear></soap:Body></soap:Envelope>";
- //content = "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\"><soap:Body/></soap:Envelope>";
- //LogUtil::info("FormEc.getUserFee,content=" + content);
- ecCode = "3001";
- QNetworkRequest nr;
- nr.setUrl(sUrl);
- nr.setHeader(QNetworkRequest::ContentTypeHeader, " application/soap+xml;charset=UTF-8;action=\"urn:getUserTotalArrear\"");
- netManager->post(nr, content.toAscii());
- connect(netManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(getUserFeeNet(QNetworkReply*)));
- return 0;
- }
- void Form::getUserFeeNet(QNetworkReply* reply)
- {
- QByteArray rdata = reply->readAll();
- QString sret = QString::fromLocal8Bit(rdata.data());
- LogUtil::info("FormEc.getUserFeeNet,reply=" + sret);
- }
另外,这个是用qtcreator创建的工程,要想链接crypto,在pro文件中增加了LIBS += -lcryptopp -lpthread