Home > OS >  WCF service giving no response with TCP and Http protocols from azure
WCF service giving no response with TCP and Http protocols from azure

Time:01-06

Have two clients to use the service the two protocls

<system.serviceModel>
<services>
<Service  name ="ServcieName">
<endpoint address ="" binding="basicHttpBinding" contract="ContractName">
</endpoint> 
<endpoint address ="" binding="netTcpBinding" contract="ContractName">
</endpoint> 
</services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
   </system.serviceModel>

I want a responses from both the end points.

CodePudding user response:

The namespace system.serviceModel need to be used in the project, as this converts the interface into a service model.

Config file:

In the configuration file for communicating with the Service need to use the Mex behaviour as a service Behaviour

<serviceMetadata httpGetEnabled="true"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

And for 2 different bindings, need to use

<endpoint address="SampleService" binding="basicHttpBinding" contract="SampleService.ISampleService"/>
<endpoint address="SampleService" binding="netTcpBinding" contract="SampleService.ISampleService"/>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <services>
            <service name="SampleService.SampleService" behaviorConfiguration="mexBehaviour">
                <endpoint address="SampleService" binding="basicHttpBinding" contract="SampleService.ISampleService"/>
                <endpoint address="SampleService" binding="netTcpBinding" contract="SampleService.ISampleService"/>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
                <host>
                    <baseAddresses>
                        <add baseAddress="http://loclahost:8080"/>
                        <add baseAddress="net.tcp://loclahost:8090"/>
                    </baseAddresses>
                </host>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="mexBehaviour">
                    <serviceMetadata httpGetEnabled="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>

Sample service code

 public class SampleService : ISampleService
    {
        public string GetMessage(string name)
        {
            return " Hello "   name;
        }
    }

enter image description here

  • Related