如何使用Delphi XE送WCF的ClientCredentials [英] How to send WCF's ClientCredentials using Delphi XE

查看:437
本文介绍了如何使用Delphi XE送WCF的ClientCredentials的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经developd WCF服务与自定义 UserNamePasswordValidator 使用HTTPS一个 basicHttpBinding的用。它与.NET客户端的伟大工程,使用ClientCredentials发送认证的用户名和密码。

不过,我需要从德尔福XE客户端调用它。如何我送使用Delphi的.Net ClientCredentials相当于?那可能吗?如果是,怎么了?如果不是,有没有办法?

韩国社交协会

修改

下面是我的客户端code在.net:

 的EndpointAddress oTransac =新的EndpointAddress(的getAddress());
使用(WebServiceClient此类OCLIENT =新WebServiceClient此类(httpbasic,oTransac))
{
  oClient.ClientCredentials.UserName.UserName =用户名;
  oClient.ClientCredentials.UserName.Password =密码;
  oClient.DoStuff();
}

修改

我一直在做一些研究,我已经能够德尔福和使用SOAP Hearders旧ASMX Web服务之间做认证。我发现下面的文章。我将能够实现旧的行为相同 [的WebMethod] [System.Web.Services.Protocols.SoapHeader(SOAPHEADER)]用文章的技巧 <? / p>

<一个href=\"http://weblogs.asp.net/paolopia/archive/2008/02/25/handling-custom-soap-headers-via-wcf-behaviors.aspx\">http://weblogs.asp.net/paolopia/archive/2008/02/25/handling-custom-soap-headers-via-wcf-behaviors.aspx

编辑BOUNTY

获取标记为赏金的正确答案,我想能够调用从德尔福在服务器端使用WCF服务 UserNamePasswordValidator Web服务。


解决方案

首先,basicHttpBinding的是通过HTTP(HTTPS不是)

<一个href=\"http://msdn.microsoft.com/en-us/library/ms731361.aspx\">http://msdn.microsoft.com/en-us/library/ms731361.aspx

要使用来自德尔福WFC服务通常是由服务产生的WSDL完成

<一个href=\"http://stackoverflow.com/questions/5216624/how-to-create-a-single-wsdl-file-from-existing-wcf-service\">How创建从现有的WCF服务的单一WSDL文件?

<一个href=\"http://social.msdn.microsoft.com/Forums/en/wcf/thread/fc2c5074-1116-4f92-a972-01bb3a142535\">http://social.msdn.microsoft.com/Forums/en/wcf/thread/fc2c5074-1116-4f92-a972-01bb3a142535

<一个href=\"http://stackoverflow.com/questions/985320/wcf-how-to-generate-a-single-wsdl-document-without-wsdlimport\">WCF:如何生成一个WSDL文档,无需WSDL:进口

和通过导入WSDL到您的Delphi工程产生一个Delphi代理类。

 &GT; wsdlimport.exe service.wsdl

,然后使用生成的德尔福单位在Delphi工程

<一个href=\"http://www.drbob42.com/examines/examinB9.htm\">http://www.drbob42.com/examines/examinB9.htm

http://edn.embarcadero.com/article/36962

您发送给服务电话(用户名,密码,ClientCredientials等)将在生成的德尔福单位被定义的参数 - 应该没问题,只要你可以连接到服务

I've developd a WCF Service with a custom UserNamePasswordValidator with a basicHttpBinding using HTTPS. It works great with a .Net client, using ClientCredentials to send the username and password for authentication.

However, I need to call this from a Delphi XE client. How to I send the equivalent of .Net ClientCredentials using Delphi? Is that possible? If it is, how? If it is not, are there alternatives?

Tks

EDIT

Below is my client side code in .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();
}

EDIT

I've been doing some research, and I've been able to do authentication between Delphi and old asmx web services using SOAP Hearders. I found the article below. Will I be able to achieve the same behavior of the old [WebMethod] [System.Web.Services.Protocols.SoapHeader("SoapHeader")] using the article's technique?

http://weblogs.asp.net/paolopia/archive/2008/02/25/handling-custom-soap-headers-via-wcf-behaviors.aspx

EDIT BOUNTY

The get marked as the correct answer of the bounty, I would like to be able to call the web service from Delphi using WCF Service UserNamePasswordValidator on the server side.

解决方案

First, basicHttpBinding is over HTTP (not HTTPS)

http://msdn.microsoft.com/en-us/library/ms731361.aspx

To consume a WFC service from Delphi is usually done by producing a WSDL from the service

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?

and generating a Delphi proxy class by importing that WSDL into your Delphi project.

>wsdlimport.exe service.wsdl

and then use the generated Delphi unit in your Delphi project

http://www.drbob42.com/examines/examinB9.htm

http://edn.embarcadero.com/article/36962

The parameters you send to service calls (username, password, ClientCredientials, etc) will be defined in the generated Delphi unit - should be no problem as long as you can connect to the service.

这篇关于如何使用Delphi XE送WCF的ClientCredentials的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆