c++ builder 使用indy http調用webservice方法
來源:互聯網
上載者:User
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;}