.NET 2.0 Web Services的bug?
2006-04-27 10:01
441 查看
今天测试.net 2.0的WebService,发现了一个大问题。就是无法获取参数,参数永远是null。当然了使用.net调用没有任何问题,web测试页也正常。不论是Delphi7还是java调用的结果的都是一样的,难道是.net 2.0的Bug?
测试结果发现:值类型参数全部为缺省值,引用类型全部为null
WebService的代码如下:
delphi调用的代码
--------------------------------------------------------------------------------------------------------------------------------------------------
在不断尝试中发现vs2003生成的web Services,delphi调用的时候不会有任何问题,即使是delphi2006也无法正常调用.net 2.0的Web Service.
最后经过不懈努力,终于找到方法那就是在delphi生成webservices声明单元中加入以行
InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap), ioDocument);
如:
至此问题搞定了。
测试结果发现:值类型参数全部为缺省值,引用类型全部为null
WebService的代码如下:
[WebMethod] public string EchoString(string args) { return args; } [WebMethod] public string EchoInt(int args) { return args.ToString(); }
delphi调用的代码
procedure TForm1.Button3Click(Sender: TObject); var ss:ServiceSoap; hello:WideString; begin try HTTPRIO1.WSDLLocation := edtAddress.Text; HTTPRIO1.Service := edit3.Text; HTTPRIO1.Port := edit4.Text; ss := (HTTPRIO1 as ServiceSoap); hello:= 'hello'; Memo1.Lines.Add(ss.EchoInt(234)); except on e : exception do showmessage(e.Message); end; end;
--------------------------------------------------------------------------------------------------------------------------------------------------
在不断尝试中发现vs2003生成的web Services,delphi调用的时候不会有任何问题,即使是delphi2006也无法正常调用.net 2.0的Web Service.
最后经过不懈努力,终于找到方法那就是在delphi生成webservices声明单元中加入以行
InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap), ioDocument);
如:
unit Service; interface uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns; type ServiceSoap = interface(IInvokable) ['{77573149-9C57-FA51-F11F-EFD527C91BD9}'] function HelloWorld(const asdf: WideString): WideString; stdcall; end; implementation type ServiceSoapImpl = class(TInvokableClass, ServiceSoap) public { ServiceSoap } function HelloWorld(const asdf: WideString): WideString; stdcall; end; function ServiceSoapImpl.HelloWorld(const asdf: WideString): WideString; begin { TODO - Implement method HelloWorld } end; initialization 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);//就是这一行 end.
至此问题搞定了。
相关文章推荐
- .NET 2.0 CookieContainer bug
- .net 2.0 的 Bug?--与 COM 交互时发生奇怪的 InvalidCastException
- [Bug] .NET 2.0 的Bug —— ComboBox中不能添加Component.
- 发现了.net 2.0框架的BUG了,page_load执行了2次
- .net 2.0的URL重写导致的Bug及其解决方法
- Delphi 调用 .net 2.0 的WebService的错误(BUG?)
- .NET 2.0 RC的一个Bug
- .net 2.0的URL重写导致搜索引擎302重定向错误的Bug及其解决方法-完美版-小事一箩筐
- .net2.0的BUG[附源码]
- .net 2.0 .net3.5全部都有输入法bug!
- 郁闷的.NET 2.0中的Remoting和DataSet的Bug
- 关于.NET 2.0中正则表达式的Bug
- 客户端浏览.NET 2.0开发的网站,IE死机
- 西南石油大学--学分绩点计算器(用C#编写,需要有.NET 2.0)
- 基于.NET 2.0的GIS开源项目SharpMap分析手记(六):SharpMap的功能扩展之路
- Fiori2.0学习笔记-BUG汇总
- 用Delphi7 调用.NET 2.0的WebService 所要注意的问题(Document格式和UTF8编码)
- 使用Ajax SlideShowExtender传参的两种方法(.net 2.0/3.5)
- .NET 2.0中SmtpClient的乱码问题
- 在范型中接口和实例间转换的问题Why No? .net 2.0 Generic cast Type From Instance to Interface