惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V2EX - 技术
V2EX - 技术
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
S
Schneier on Security
S
Securelist
P
Privacy & Cybersecurity Law Blog
Scott Helme
Scott Helme
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
Cyberwarzone
Cyberwarzone
Cisco Talos Blog
Cisco Talos Blog
量子位
博客园 - Franky
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Latest news
Latest news
T
Troy Hunt's Blog
N
News | PayPal Newsroom
Google Online Security Blog
Google Online Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
N
Netflix TechBlog - Medium
小众软件
小众软件
P
Palo Alto Networks Blog
Spread Privacy
Spread Privacy
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
L
Lohrmann on Cybersecurity
L
LINUX DO - 最新话题
D
Darknet – Hacking Tools, Hacker News & Cyber Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Last Watchdog
The Last Watchdog
S
Security @ Cisco Blogs
P
Privacy International News Feed
Last Week in AI
Last Week in AI
Microsoft Security Blog
Microsoft Security Blog
T
Tailwind CSS Blog
博客园_首页
云风的 BLOG
云风的 BLOG
V
Vulnerabilities – Threatpost
D
DataBreaches.Net
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
罗磊的独立博客
Engineering at Meta
Engineering at Meta
Forbes - Security
Forbes - Security
T
Tenable Blog

博客园 - Enli

IOS 命令行安装备忘 IOS开发备忘 MAC 编制计划任务 弹出式窗口管理单元备忘 Wininet请求包装类简稿 自备工具库 多屏开发的备忘 界面方面的备忘 rc资源文件的中英文应用备忘 Wininet下载类初稿 关于Window的快捷方式,图标缓存的清理 Delphi 备忘五 http断点续传的单元 Delphi 代码优化(转) [转载]Delphi的四舍五入函数 同名派生的应用(转) 关于delphi的程序在英文操作系统下乱码问题 - Enli - 博客园 TWebBrowser备忘 组件开发中的技巧(转)
Dephi调用C#编写的WebService的一些问题与解决 (转)
Enli · 2011-08-05 · via 博客园 - Enli

转至:http://www.cnblogs.com/Equn93/archive/2010/04/27/1722070.html

问题1:服务端接收的所有中文都是"?????"(乱码)
解决:设置HTTPRIO控件的HTTPRIO.HTTPWebNode.UserUTF8InHeader属性为true

问题2:Dephi编写的客户端在windows2003下调用WebService提示"Access violation at address 00E59195. Write of address 00E59195"
解决:我的电脑属性->高级->性能->设置->数据执行保护。选中"只为关键 Windows 程序和服务启用数据执行保护。当然你可以选择另一个选项,并添加我们的客户端作为例外处理。有二点比较奇怪的,一、并不是每一台windows2003的机器都需要这样设置;二、有问题的2003机器使用.net写的客户端却能正常访问WebService。

问题3:从服务端得到的XML字符串,一分析就出错
解决:先使用WideString变量保存返回的XML字符串。再利用这个变量分析。string不能识别换行符。

问题4:服务端得到的参数都为空值
解决:检查一下引入的WebService单元的最后三行是否如下
initialization
  InvRegistry.RegisterInterface(TypeInfo(YourWebServiceSoap), 'http://tempuri.org/', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(YourWebServiceSoap), 'http://tempuri.org/%operationName%');
  InvRegistry.RegisterInvokeOptions(TypeInfo(YourWebServiceSoap), ioDocument);//这一行有时会没有
end.
这一行 InvRegistry.RegisterInvokeOptions(TypeInfo(YourWebServiceSoap), ioDocument);有时候没有的。举个例子,当我们的WebService的其中一个方法有参数的类型为DataSet时,单元文件的最后几行是这样的
initialization
  InvRegistry.RegisterInterface(TypeInfo(YourWebServiceSoap), 'http://tempuri.org/', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(YourWebServiceSoap), 'http://tempuri.org/%operationName%');
  RemClassRegistry.RegisterXSClass(GetDataSetResult, 'http://tempuri.org/', GetDataSetResult);
  RemClassRegistry.RegisterXSClass(updateSet, 'http://tempuri.org/', 'updateSet');
end.
这时,服务端接收到的所有参数都为null;这里你所手工在中间加入上面所提到的那一行。

问题5:服务端方法返回的DateTime,Delphi取得的时间不对。
解决:引用后,delphi是用TXSDateTime来接收C#的DateTime变量的。TXSDateTime有两个属性AsDateTime、AsUTCDateTime都是TDateTime,也就是Delphi用的日期变量了,但这两个属性得到的时间是不对的。放断点可以观察到TXSDateTime的年、月、时各变量都是正确的,所以解决的方式是取年月时分各变量重新组合成时间变量。
在这个过程,我碰到一个有趣的情况。看下面的C#代码

[WebMethod(EnableSession=true)]
public DateTime MyTime()
{
    DateTime cur 
= DateTime.Now;
    
return cur;
}


[WebMethod(EnableSession
=true)]
public DateTime YourTime(DateTime pTime)
{
    
return pTime.AddDays(1);
}

Delphi调用后者,TXSDateTime中的AsDateTime属性保存的时间是对的。调用MyTime(),AsDateTime保存的时间就不对! 我以为AsUTCDateTime的情况可能会有所不同,但其实这里他与AsDateTime是一样的。另外,.net能不能再做些什么呢?我注意到.net的DateTime有这么一个方法ToUniversalTime;我在MyTime中尝试应用这个方法,结果更遭,delphi得到的年时分各变量的值不对了;期待AsUTCDateTime会给我惊喜,结果他还是与AsDateTime非常的一致;结果都不对。