Delphi编写的webservice和windows 2003的兼容问题
2009-07-09 10:20
453 查看
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
近日在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
相关文章推荐
- delphi编写仿windows记事本遇到的问题
- (转)Delphi 调用C#编写的WebService 参数为Null解决方法 附中文乱码问题
- windows 2003 Server平台Delphi程序不支持直接调用webservice
- Delphi 7 在windows 2003 server上调用webservice 发生 access violation at address
- C#调用Delphi编写的WebService时的问题
- Delphi 7.0编写程序访问JAX-WS提供的WebService问题
- 遭遇Audition 2.0,Windows 2003兼容问题
- windows 2003 sp1 无法安装IIS 6.0 问题
- 解决在windows下用gtk编写的程序运行时弹出console窗口的问题
- 在Windows 2003下运行VMware碰到的问题
- 用Delphi编写ASP的ActiveX服务器组件的问题
- Windows Server 2003 添加/删除Windows组件出现错误的问题
- 在Windows 2003下运行VMware碰到的问题
- 关于windows 2003 + tomcat7.0响应速度慢的问题
- Windows Server 2003 添加/删除Windows组件出现错误的问题
- 2003_由于不可识别问题_windows无法显示windows防火墙设置解决方法
- 解决在用HTML+DIV+CSS编写网页时,各个浏览器的兼容问题
- Windows Server 2003 添加/删除Windows组件出现错误的问题
- Windows Server 2003 添加/删除Windows组件出现错误的问题
- Windows Server 2003 添加/删除Windows组件出现错误的问题