网上文摘 小说 Flash游戏 最近更新 下载排行 资源分类 下载指南
经典编程资源 精彩不容错过
设为首页
加入收藏
联系我们
当前位置:Delphi园地技巧文章网络通讯 → 关于调用Dot Net2.0的WebService的问题
关于调用Dot Net2.0的WebService的问题
日期:2007年12月20日 作者: 人气: 查看:[大字体 中字体 小字体]
最近发现用delphi调用Dot Net2.0写的WebService程序,传入的参数都是NULL值,后来查证,是RPC|Encoded 与Document|Literal 的问题,delphi写的服务器程序只能支持RPC|Encoded编码,但是delphi写的客户端程序则可以用两种方式的编码,如果是调用Document|Literal 编码方式的服务,需要把HTTPRio1.Converter.Options.soLiteralParams的属性设置为True,但这种方法只能应用于delphi7以上版本,如果是delphi7的话,必须在生成的接口单元initialization中加入InvRegistry.RegisterInvokeOptions(TypeInfo(DataServiceSoap), ioDocument);
注意:DataServiceSoap为接口名,要根据实际情况更改。


附:
RPC|Encoded vs. Document|Literal
   The biggest problem in interoperability is the fact that some servers use Document|Literal encoding, which most others use RPC|Encoded. Delphi servers only understand RPC|Encoded packages, but Delphi Clients can talk to both RPC|Encoded and Document|Literal servers.
    To communicate with a Doc|Lit server (Most .NET web services are doc|lit) you must set HTTPRio1.Converter.Options.soLiteralParams to true. This ensures that parameters encoded with "literal" are not unwound, which is necessary in doc|lit cases where a parameter name might be encapsulated under a sub tag under the XML element representing the function.
   In Delphi 7, Document encoding is supported in one way - you can make Delphi 7 client applications (consumers) for Document based webservices. What you cannot do is write Document based servers. If you're writing a client for a document based server, you can import the WSDL and Delphi's WSDL Importer will recognize that this is a document based server and generate necessary code for the conversion. FOr instance it will add the following call to the initialization section of your imported .pas file:
InvRegistry.RegisterInvokeOptions(TypeInfo(DataServiceSoap), ioDocument);
   This ensures that an Invoke call that uses the interface DataServiceSoap will be formatted using Document rules (not RPC). You can also use ioLiteral for doc-lit services. Using ioLiteral also ensures that your input and output types won't be "unwound" - this needs some explanation. In RPC encoding, each method call is preceded by a method node in the XML datapacket. In Literal encoding, the method name is skipped and the parameters are unwound into XML. This and many small differences are actually handled directly by the Delphi SOAP runtime itself, so you don't have to worry about them individually. But, use a proxy server to actually find out what's happening behind the scenes in case there's a problem.

(出处:DelphiFans.com)

相关文章:
·免费WEB空间资源分享
·使WebBrowser得到焦点
·用Delphi开发Web服务数据库程序
·如何用delphi2005的WebService返回各种类型数据
·TWebBrowser的常见属性和方法
·Delphi的TWebBrowser编程综述
·Delphi for PHP:这是一种对web技术前所未有的震撼
·Delphi for PHP Webinar总结
·用友华表Cell插件,优秀的Web报表工具
·WebBrowser组件和MSHTML 在Delphi中的使用
 → 特别推荐
 → 热点TOP10
关于我们 | 广告服务 | 发布资源 | 联系站长 Copyright © 2002-2006 Delphi园地 All Rights Reserved