I'm attempting to call a web service from a VB .NET 3.5 Win Forms application. I have been able to create a Service Reference but when I call the web service I receive the SOAP fault:
A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint.
The web service uses username and password authentication with a certificate. I also need to connect to different URLs depending on the environment (development or production). For these reasons I was attempting to use a WSHttpBinding created in code. However, it appears that type of binding assumes SOAP 1.2. I've been told by the author of the web service that they are unable to support SOAP 1.2.
Is there a way, either with the WSHttpBinding or a CustomBinding in code, to consume a web service that only supports SOAP 1.1 using a WCF Service Reference?
Dim binding As New System.ServiceModel.WSHttpBinding
binding.Security.Mode = ServiceModel.SecurityMode.Transport
binding.Security.Transport.ClientCredentialType = ServiceModel.HttpClientCredentialType.Basic
Dim service As New ServiceReference.ServiceClient(binding, New System.ServiceModel.EndpointAddress(baseUrl))
service.ClientCredentials.UserName.UserName = serviceUsername
service.ClientCredentials.UserName.Password = servicePassword
Any help is appreciated!
Related
I have an existing WCF webservice using TransportWithMessageCredential works fine
I need to access it from new CORE apps as I upgrade my system piece by piece.
MS CORE Microsoft WCF Web Service Reference Provider does not support message credentials
I have created an endpoint using TransportCredentialOnly.
Unprotected webservice methods work fine but webservice does not receive the credentials for PrincipalPermission authorisation passed as:
Client.ClientCredentials.UserName.UserName = "MyUserName";
Client.ClientCredentials.UserName.Password = "MyPassword!";
It may be because I set transport clientCredentialType="None" but "Basic" setting throws an error.
I have a wcf project and I'm creating a client to test it. For some reasons, on my local machine I can run the service only within IIS Express from visual studio. After I start the project, I'm trying to connect to the service from a client, but I'm getting an error:
You have tried to create a channel to a service that does not support
.Net Framing. It is possible that you are encountering an HTTP
endpoint.
I've read this and this but they're discussing about IIS and not IIS Express.
Here is my code from the client:
NetTcpBinding binding = new NetTcpBinding();
EndpointAddress address = new EndpointAddress("net.tcp://localhost:64255/MyService.svc");
ChannelFactory<IMyInterface> channelFactory = new ChannelFactory<IMyInterface>(binding, address);
channelFactory.Open();
IMyInterface _clientProxy = channelFactory.CreateChannel();
((IClientChannel)_clientProxy).Open();
And when I'm calling the method Open, I'm getting the error above...
Please note that the service accepts only net.tcp protocol.
What do I need to change to call this service hosted in IIS Express from my client?
Edit: when I'm running the project from visual Studio, in the browser I'm seeing the url: http://localhost:64255/MyService.svc
Long story short: IIS Express does not support non-HTTP protocols such as net.tcp. IIS Express only supports HTTP and HTTPS as its protocol
I'm new in WCF service and I need to consume the WCF service from my client for my current .net 2.0 windows app. I successfully added the WCF service as web reference in my .net 2.0 application but when using the web method of the service it took long time to execute the method and in the end my application is not responding. Base on the request in fiddler, the request has been timed out. My client provides me a user name and password but I don't know where to use it. Base on the wcf web service wsdl of my client, it uses WSHttpBinding.
I also created a sample .net 4.0 windows application and added the service as reference but still cannot use the web method. I check also the request in fiddler and gives me a response error "The request for security token could not be satisfied because authentication failed.".
Please help. I need to consume the WCF service using my existing .net 2.0 application.
Thank you very much in advance!
If you want to consume your WCF service from .NET 2.0 via adding web reference you must use BasicHttpBinding - that is only backward compatible build-in binding (except custom defined binding) with ASMX based client.
Your exception in case of .NET 4.0 test complains about security token - WsHttpBinding uses Windows security by default. It is hard to diagnose the problem further because you didn't provide enough information.
I am using wsHttpBinding with a WCF service.
I've added a web reference and I've got the web proxy (it is based on SoapHttpClientProtocol).
Also I've tried to build a proxy using wsdl.exe and the actual wsdl generated by the wcf service (http://zzzz/zz.svc?wsdl).
When the client calls the service, I get the following error:
The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'http://tempuri.org/Service1/Operation1'.
Why doesn't the client (the web proxy) work with my WCF service?
What steps should I take to make them work?
I am running .NET FW 3.5 and ASP.NET 2.0.
You cannot consume service exposed on wsHttpBinding with default configuration by old ASMX proxy. You must either use add service reference / svcutil or change your binding to basicHttpBinding. Default configuration of wsHttpBinding uses advanced security and ASMX doesn't support it.
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.
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