开发者

How to send WCF's ClientCredentials using Delphi XE

开发者 https://www.devze.com 2023-03-07 14:26 出处:网络
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 f

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 alternativ开发者_运维知识库es?

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.


Some weeks ago I also had to connect to a WCF service. I ended up writing the client in .net and using UnmanagedExports https://sites.google.com/site/robertgiesecke/Home/uploads/unmanagedexports

The dll can then be consumed in Delphi like a native dll

0

精彩评论

暂无评论...
验证码 换一张
取 消