用Delphi7 调用.NET 2.0的WebService 所要注意的问题(Document格式和UTF8编码)
Delphi7 调用VS.NET 2005开发的基于.NET 2.0的WebService时发生了错误。查阅资料 http://www.community.borland.com/article/borcon/files/4132/paper/4132.html 发现原来Delphi7客户端虽然支持WebService的RPC|Encoded 和 Document|Literal编码,但 默认的是使用RPC。而.NET 2.0下的WebService却是默认采用Documnet|Literal编码的。因此我们需要显示地声明让Delphi客户端采用Documnet|Literal编码就可以了。在Delphi的WSDL Importer产生了WebService的接口文件中加入如下行:
InvRegistry.RegisterInterface(TypeInfo(ServiceSoap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterInvokableClass(ServiceSoapImpl);
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ServiceSoap), 'http://tempuri.org/HelloWorld');
InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap), ioDocument);//指明Delphi采用Document编码
end.
如果需要在WebService中传送汉字的参数,则建议在Service.pas中再添加一行代码
const
defWSDL = 'http://localhost/myservice/service.asmx?wsdl';
defURL = 'http://localhost/myservice/service.asmx';
defSvc = 'Service';
defPrt = 'ServiceSoap';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
RIO.HTTPWebNode.UseUTF8InHeader := True; //添加该行,指定采用UTF-8代码传输
try
Result := (RIO as ServiceSoap);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
需要说明的是使用Delphi2006则不需要上述的改变即可以正确调用VS.NET 2005书写的WebService.
http://www.cnblogs.com/sonicit/archive/2007/06/02/768753.html
用Delphi7 调用.NET 2.0的WebService 所要注意的问题(Document格式和UTF8编码)的更多相关文章
- delphi7调用java写的webservice,在调用的时候弹出“wssecurityhandler:request does not contain required security header”
delphi7调用java编写的webservice问题我用delphi7调用java写的webservice,在调用的时候弹出“wssecurityhandler:request does not ...
- 用delphi的THTTPRIO控件调用了c#写的webservice。
用delphi的THTTPRIO控件调用了c#写的webservice. 下面是我调试时遇到的一些问题: 1,导入wsdl文件:file--new----other----wenservice---W ...
- Delphi XE3写DLL,用Delphi7调用,报错!
http://bbs.csdn.net/topics/390870532 用delphi xe3写的DLL,delphi7调用,参数都是PAnsiChar,DLL里的函数接收delphi7传的入参,没 ...
- spring 3.0系统集成webservice
spring 3.0系统集成webservice,踩了很多坑以后总算成功了,故写下这篇博客以记录. 1.准备jar包 由于项目是spring3.0,所以应该要使用cxf 2.7版本才可以成功配置,高版 ...
- Eclipse中通过Android模拟器调用OpenGL ES2.0函数操作步骤
原文地址: Eclipse中通过Android模拟器调用OpenGL ES2.0函数操作步骤 - 网络资源是无限的 - 博客频道 - CSDN.NET http://blog.csdn.net/fen ...
- webservice接口测试wsdl,参数是xml格式。python,入参转化成str,返回值转化成dict调用
1.用SoapUI测试webservice接口,传入参数是xml格式时.xml格式需要将xml的外围增加<![CDATA[xml]]> 2.但是用python去做webservice测试, ...
- python调用虹软2.0(全网首发)-更新中
python调用虹软2.0目前没有任何demo可以参考,自己研究了2个晚上终于把第一步做出来了,使用了opencv来加载和显示图片,龟速更新中 这一版作废,新版已发出:https://www.cnbl ...
- DELPHI7调用BERLIN中间件的中文字段名乱码的解决办法
MSSQL数据库的表使用中文字段名,BERLIN开发的DATASNAP中间件,DELPHI7调用中间件的查询方法返回数据给CLIENTDATASET.DATA,发现中文字段名乱码,中文字段名的值可以正 ...
- 调用支付宝PHP接口API实现在线即时支付功能(UTF-8编码)
这次在项目中要实现订单功能,所以要完成在线支付,在线支付一般有网银支付和第三方支付(支付宝.paypal等)这两种途径,未简单起见,先完成支付宝在线支付功能,由于项目基于Yii框架,且使用UTF-8编 ...
随机推荐
- HDU4405-Aeroplane chess(概率DP求期望)
Hzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz start ...
- Bichrome Tree
Bichrome Tree 时间限制: 1 Sec 内存限制: 128 MB 题目描述 We have a tree with N vertices. Vertex 1 is the root of ...
- uva 10515 规律打表
Problem G Power et al. Input: Standard Input Output: Standard Output Finding the exponent of any num ...
- 洛谷 [P2216] 理想的正方形
二维单调队列 先横向跑一边单调队列,记录下每一行长度为n的区间的最值 在纵向跑一边单调队列,得出结果 注意,mi要初始化为一个足够大的数 #include <iostream> #incl ...
- 16.1114 模拟考试T1
1.正确答案 [题目描述] 小H与小Y刚刚参加完UOIP外卡组的初赛,就迫不及待的跑出考场对答案. “吔,我的答案和你都不一样!”,小Y说道,”我们去找神犇们问答案吧”. 外卡组试卷中共有m道判断题, ...
- 「CodePlus 2018 4 月赛」最短路
$n \leq 100000$,$m \leq 500000$的有向图,两点之间还可以以$a \ \ xor \ \ b$的代价从$a$到$b$,问$s$到$t$的最短路. 被自己蠢哭QAQ 首先两个 ...
- svn服务安装与配置
SVN安装 centos系统下执行yum install subversion 创建项目 svnadmin create dxk-test 创建项目dxk-test 服务配置与权限控制 vim con ...
- Python入门---易错已错易混淆----知识点
1.not 1 or 0 and 1 or 3 and 4 or 5 and 6 or 7 and 8 and 9 结果会输出啥? 根据优先级:(not 1) or (0 and 1) or (3 a ...
- substring用法
字符串截取,substring(int beginIndex) 返回一个新的字符串,它是此字符串的一个子字符串. substring(int beginIndex, int endIndex) 返回一 ...
- jqeury设置元素屏幕居中
jQuery.fn.center = function () { this.css(“position”,”absolute”); this.css(“top”, ( $(window).height ...