Delphi编写的webservice和windows 2003的兼容问题

Delphi编写的webservice和windows 2003的兼容问题
近日在delphi中写了个webservice的服务端程序,本机调试通过的,但是部署到windows 2003的时候出了问题。

首先是windows 2003安装时没带IIS,结果下了个IIS6.0,不想配置和xp下的配置不一样了,如果没有配web扩展服务根本就访问不到那个webservice。

琢磨了半天,才能够访问exe了,结果又出了个500错,说是访问ntdll.dll时有个空指针错误。比较了下,发现确实xp和2003的这个dll文件不同,但是copy不了,因为windows2003在检测到这个文件变了之后马上就覆盖回来了。

到网上找了半天,终于在一篇博客中找到原因,原来是delphi的内核中有个bug,需要修改。附上该博客原文。

 

Delphi ISAPI and Windows 2003 compatiblity
I had a perfetly OK ISAPI on my Windows 2000 Server. Spending months to

write and debug it has made it a smoothly working peace of work. Then

suddenly we decided to test it on a Windows 2003 Server. As you'd

expect, when Microsoft changes a piece of its operating system, it

shouldn't surprise you if you end up recompiling your Delphi projects.

For the start, I tryied just to copy the ISAPI to the new machine and

see if it works. It didn't. It couldn't find the damn thing and was

giving me 404 Page Not Found error and many other stupid errors. So here

is how I solved it:

First of all, you need to "introduce" your code (ISAPI or CGI) to the

new IIS 6. In order to do this, go to IIS MMC and "allow" your DLL (or

CGI exe) in Web Service Management branch of the left panel tree.

Now try to run your ISAPI. It might work depending on the instructions

you have used in your code. If it gives you something like
Server Error 500
Exception: EAccessViolation
Message: Access violation at address 77F4831D in module 'ntdll.dll'.
Write of address 0040476D

Then you need to fix a bug in Delphi kernel. Open SysUtils.pas

(delphi/Source/Rtl/Sys) and replace the GetEnvironmentVariable function

with the following:

function GetEnvironmentVariable(const Name: string): string;
var
Len: integer;
W : String;
begin
Result := '';
SetLength(W,1);
Len := GetEnvironmentVariable(PChar(Name), PChar(W), 1);
if Len > 0 then
begin
SetLength(Result, Len - 1);
GetEnvironmentVariable(PChar(Name), PChar(Result), Len);
end;
end;

Recompile your ISAPI and it should work now. Remember to make sure this

new SysUtil.pas file gets compiled. You might need to delete its DCU

file from Bin or other folders or add its folder to Delphi search path

in order to force delphi to compile it again.

I have found this solution somewhere in a newsgroup, but I can't find it

again to give "JP" his/her credit

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值