问题
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.
回答1:
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.
回答2:
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
来源:https://stackoverflow.com/questions/6095887/how-to-send-wcfs-clientcredentials-using-delphi-xe