http 调用soap webservice
2015-09-17 09:40
603 查看
delphi使用控件idhttp,post xml字符串,获取返回结果有用记得回复一下,满足我小小的虚荣心//下面是是调用AAA的接口,返回的也是xml字符串//这个调了一整天,网上没找到完整的资料,一些属性猜了又猜,还用抓包工具不断调,才搞定,程序员有时也要踩狗屎才行啊很多人都习惯用httprio控件,不过我用的是delphi7, 然后这个控件就不稳定了,要到Delphi2010后的版本才能稳定使用不然一些启用了数据保护的电脑就会报内存错误,(右键 我的电脑 => 属性 => 高级 选项卡 在性能那点设置 => 数据执行保护 ),要禁用数据保护才能跑.
delphi
<span style="font-family:Microsoft YaHei;font-size:14px;">var IdHTTP1: TIdHTTP; Params: TStrings; html: string; begin IdHTTP1 := TidHTTp.create(self); Params := TStringList.Create; IdHTTP1.AllowCookies := True; IdHTTP1.HTTPOptions := [hoKeepOrigProtocol]; IdHTTP1.ProtocolVersion := pv1_1; IdHTTP1.Request.Accept := '*/*'; IdHTTP1.Request.ContentType := 'text/xml; charset=utf-8'; IdHTTP1.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0)'; IdHTTP1.Request.ContentLength := -1; IdHTTP1.Request.Connection := 'Keep-Alive'; IdHTTP1.Request.CacheControl := 'no-cache'; IdHTTP1.Request.CustomHeaders.Add('SOAPAction: "http://tempuri.org/AAA"'); Params.Text := '<?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>' + ' <AAA xmlns="http://tempuri.org/" />' + ' </soap:Body>' + '</soap:Envelope>'; try params.SaveToFile(ExtractFilePath(ParamStr(0)) + 'my.txt'); html := Utf8ToAnsi(IdHTTP1.Post('http://192.168.2.26/Services/App/WebService.asmx', Params)); except //showmessage('error'); end; memo2.Text := IdHTTP1.ResponseText; IdHTTP1.Disconnect; FreeAndNil(IdHTTP1); FreeAndNil(Params); end;</span>
相关文章推荐
- Asynchttpclient的使用及请求与响应封装
- ios9用http
- Hdu 5439 Aggregated Counting (2015长春网络赛 ACM/ICPC Asia Regional Changchun Online 找规律)
- 【Android技术整理】HTTP操作
- iOS开发-------网络请求(自定义请求管理类,解决在Block中传值问题)
- Volley框架解析(五)-----HttpStack接口及其默认实现类解析
- C++各大有名库的介绍 http://my.oschina.net/qihh/blog/55591
- C/C++ 开发库 | C/C++ Development Library http://blog.csdn.net/herorenme/article/details/18795935
- java网络编程【精简篇】
- Filedescriptor out of range in select
- iOS网络开发-AFNetworking请求asp.net WebService
- http协议
- Linux NAT网络连接权威指南
- Web API应用支持HTTPS的经验总结
- Android 多线程通信 访问网络
- 三次握手四次挥手
- VIEWGOOD(远古)高清网络电视直播介绍
- HTTP协议
- 关于Xcode7.1beta版使用http报错的解决方法
- 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。