Justin Dearing
Justin Dearing

Reputation: 14928

Connecting to a WCF service in php via NetTcpBinding

I can't find a duplicate for this question, but I honestly hope I'm not the first to ask.

I have a WCF service that is sitting inside my LAN. For .NET clients on my lan, NetTcpBinding is the appropriate binding. However, one of my clients is a PHP web application. Is there any way to do this?

Update: I am well aware I can have multiple endpoints. I want to know if I can enjoy the speed, reduced network traffic and lack of latency of nettcp compared to wshttp from a php app.

It happens to be a PHP app running on windows so COM interop or .NET Interop would work. I'm wondering if there is a "native" solution, such a a pecl module or pear library.

Upvotes: 1

Views: 1996

Answers (3)

Justin Dearing
Justin Dearing

Reputation: 14928

The following options are possible hacks. I include them there for others that find this question.

  • This allows you to make a .NET assembly with unmanaged exports you could call from a custom PHP module,

  • Phalanger interprets PHP into the .NET runtime. It also gives you full access to the .NET API. I've only toyed a little with this. However, it definitely reads you web.config file. If it does not respect the WCF services aspect of the web.config, I would use this PowerShell script, originally developed by Christian Glessner, as a reference for configuring a WCF service client stub completely in code.

Upvotes: 0

Daniel Vassallo
Daniel Vassallo

Reputation: 344301

NetTcpBinding is intended "for WCF-to-WCF communication" only. (MSDN)

This binding uses a proprietary protocol to communicate, and it is not meant to be interoperable since it is optimized for WCF-to-WCF.

You could have different endpoints for your WCF service. Why don't you expose another endpoint with a binding that could be consumed easily from your php application? (like BasicHttpBinding or WebHttpBinding)

Upvotes: 2

softveda
softveda

Reputation: 11066

You can add another binding to an existing service endpoint. So why don't you just add a basichttp or wshttp binding in addition to the nettcpbinding. It is just a few lines in your config file and doesn't require any code change.

Upvotes: 0

Related Questions