如何使用Delphi XE发送WCF的ClientCredentials
我使用HTTPS开发了一个带有自定义UserNamePasswordValidator和带有basicHttpBinding的WCF服务.它适用于.Net客户端,使用ClientCredentials发送用于身份验证的用户名和密码.
但是,我需要从Delphi XE客户端调用它.如何使用Delphi发送等效的.Net ClientCredentials?那可能吗?如果是,怎么样?如果不是,还有其他选择吗? TKS 编辑 下面是.Net中的客户端代码: EndpointAddress oTransac = new EndpointAddress(GetAddress()); using (WebServiceClient oClient = new WebServiceClient ("httpbasic",oTransac)) { oClient.ClientCredentials.UserName.UserName = "username"; oClient.ClientCredentials.UserName.Password = "password"; oClient.DoStuff(); } 编辑 我一直在做一些研究,并且我已经能够使用SOAP Hearders在Delphi和旧的asmx Web服务之间进行身份验证.我在下面找到了这篇文章.我是否能够使用文章的技术实现旧[WebMethod] [System.Web.Services.Protocols.SoapHeader(“SoapHeader”)]的相同行为? http://weblogs.asp.net/paolopia/archive/2008/02/25/handling-custom-soap-headers-via-wcf-behaviors.aspx 编辑BOUNTY 获得标记为赏金的正确答案,我希望能够在服务器端使用WCF服务UserNamePasswordValidator从Delphi调用Web服务. 解决方法
首先,basicHttpBinding是通过HTTP(而不是HTTPS)
http://msdn.microsoft.com/en-us/library/ms731361.aspx 从Delphi使用WFC服务通常是通过从服务生成WSDL来完成的 How to create a single WSDL file from existing WCF service? http://social.msdn.microsoft.com/Forums/en/wcf/thread/fc2c5074-1116-4f92-a972-01bb3a142535 WCF: how to generate a single WSDL document,without WSDL:import? 并通过将该WSDL导入Delphi项目来生成Delphi代理类. >wsdlimport.exe service.wsdl 然后在Delphi项目中使用生成的Delphi单元 http://www.drbob42.com/examines/examinB9.htm http://edn.embarcadero.com/article/36962 您发送给服务调用的参数(用户名,密码,ClientCredientials等)将在生成的Delphi单元中定义 – 只要您可以连接到该服务,应该没有问题. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |