TCP to HTTP Binding?

1231231232121 1 Reputation point


I am trying to figure out WCF API as we help the world, it is good to share info, this is not school anymore. You answer this, and it will be directly applicable to easing the traffic at the ports.

I have a client and a server. The server accepts HTTPS and they don't want that changed. This client sends out data out TCP, aka NetTcpBinding. How do I take the following code and make it outbound as HTTP? Thanks, you'll help the supply chain if you can answer this:

            endPointAddr = "net.tcp://" + textBox2.Text + ":1111/TempusWCF";
            NetTcpBinding tcpBinding = new NetTcpBinding();
            tcpBinding.TransactionFlow = false;
            tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
            tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
            tcpBinding.Security.Mode = SecurityMode.None;

            EndpointAddress endpointAddress = new EndpointAddress(endPointAddr);

            Append("Attempt to connect to: " + endPointAddr);

            IService1 proxy = ChannelFactory<IService1>.CreateChannel(tcpBinding, endpointAddress);

            using (proxy as IDisposable)
                Append("Message from server: " + (proxy.HelloWorld(textBox1.Text) + " back to you :)"));
Windows 7
Windows 7
A Microsoft operating system.
351 questions
Windows Communication Foundation
Windows Communication Foundation
A Microsoft runtime and set of application programming interfaces in the .NET Framework for building service-oriented applications.
260 questions
Windows 8
Windows 8
A Microsoft operating system.
164 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lan Huang-MSFT 9,281 Reputation points Microsoft Employee

    Hi @1231231232121 ,
    Replace NetTcpBinding on the client side with WSHttpBinding to interact with SOAP servers that comply with WS-* protocols.

    EndpointAddress address = new EndpointAddress("https://uri/to/service.svc");  
    WSHttpBinding binding = new WSHttpBinding();  
    IService1 proxy = ChannelFactory<IService1>.CreateChannel(binding, address);  

    Here are the docs for details:
    Configuring transport security (SSL) for WSHttpBinding:
    Best regards,
    Lan Huang

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    No comments