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 :)"));
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,523 questions
Microsoft Technologies based on the .NET software framework.
3,181 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lan Huang-MSFT 23,306 Reputation points Microsoft Vendor

    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.

    0 comments No comments