I dispose a WCF Service Implemented with WCF 4.6.1 Framework containing an Endpoint binded with WS2007HttpBinding. My purpose is to implement a .NET Core client Side application that calls this service. When i tried to use CustomBinding, it generates this error :
System.InvalidOperationException : 'The CustomBinding on the ServiceEndpoint with contract 'IWSTrust13Sync' lacks a TransportBindingElement. Every binding must have at least one binding element that derives from TransportBindingElement.'
public class Program
{
public static void Main(string[] args)
{
Message requestmessage = Message.CreateMessage(
MessageVersion.Soap12WSAddressing10,
"http://test/test",
"This is the body data");
var binding = new CustomBinding();
var endpoint = new EndpointAddress(new Uri("http://servicetest.service.svc"));
var channelFactory = new ChannelFactory<ServiceSTS.IWSTrust13Sync>(binding, endpoint);
var serviceClient = channelFactory.CreateChannel();
var result = serviceClient.Trust13ValidateAsync(requestmessage);
channelFactory.Close();
Console.WriteLine(result.Status);
}
}
Is there a replacement of WS2007HttpBinding in .NET Core ?
Notice that i should not change any things in the service because it is in use by other applications
As the error shows, you lack TransportBindingElement. Binding consists of BingingElement, a custom binding without bingingelement makes no sense. If you want to use custom binding , you should add binging element into it.
But since you are using ws2007httpbinging in server side, why not directly use ws2007httpbinding in your client side. Using ws2007httpbinging, you needn't add bingingelements into it.(They have been added).
Below is a simple use of ws2007httpbinding.
But if your service side has special configuration of ws2007httpbinging, you had better config your ws2007httpbinging of client side according to its service side configuration.
If your service side has publish its metadata, you could add reference to it and directly use the client to call the service. https://www.dotnetforall.com/adding-wcf-service-reference-client/ For svc, the default service metadata address is its address + WSDL,
for example , you metadata address is http://servicetest.service.svc?wsdl
You could also use App.config to configure your client.
And then , you could directly create the client as follows,
Please configure your client according to the endpoint configuration of your server side. Mine is