现在的位置: 首页 > 综合 > 正文

c++ builder 使用indy http调用webservice方法

2013年01月03日 ⁄ 综合 ⁄ 共 865字 ⁄ 字号 评论关闭
TIdHTTP *http = new TIdHTTP(NULL);
TStringList *formData = new TStringList();
try{
IdAntiFreeze1->OnlyWhenIdle = false;

formData->Add("<?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>\
<get_print_templates xmlns=\"http://tempuri.org/\">\
 <ai_id>6598</ai_id>\
</get_print_templates>\
  </soap:Body>\
</soap:Envelope>");
http->Request->CharSet="utf-8";
http->Request->ContentType = "text/xml";
http->Request->CustomHeaders = new TIdHeaderList();
http->Request->CustomHeaders->AddValue("SOAPAction", "http://tempuri.org/get_print_templates");
UnicodeString url = serverRootUrl + "inlineadminsite/common/print/PrintWordWin.asmx";
UnicodeString result = http->Post(url, formData);
return result;
}
__finally{
delete formData;
delete http;
}

抱歉!评论已关闭.