1

i am learning wcf. so i just write a simple where i use TCP binding & basicHttpBinding. when i am running only service with basicHttpBinding then no problem occur but when i am putting tcp binding then problem occur. so here i am pasting my code and screen shot too. my solution screen shot enter image description here

here is my full code with config entry details

namespace WcfServiceLibrary4
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {

        [OperationContract]
        string GetData(int value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        // TODO: Add your service operations here
    }


    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    [DataContract]
    public class CompositeType
    {
        bool boolValue = true;
        string stringValue = "Hello ";

        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }
    }
}

namespace WcfServiceLibrary4
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    public class Service1 : IService1
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }

        public CompositeType GetDataUsingDataContract(CompositeType composite)
        {
            if (composite == null)
            {
                throw new ArgumentNullException("composite");
            }
            if (composite.BoolValue)
            {
                composite.StringValue += "Suffix";
            }
            return composite;
        }
    }
}

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WcfServiceLibrary4.Service1">
        <host>
          <baseAddresses>
            <!--<add baseAddress = "http://localhost:8733/Service1/" />-->
            <add baseAddress="net.tcp://localhost:8734/Service1/"/>
          </baseAddresses>
        </host>
        <!--<endpoint address="" binding="basicHttpBinding" contract="WcfServiceLibrary4.IService1"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>-->
        <endpoint address=""    binding="netTcpBinding" contract="WcfServiceLibrary4.IService1"/>
        <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="False" httpsGetEnabled="False"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

when i am running the apps from VS2010 IDE then getting error called Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.

so search google and from this url i came to know that i have to start few services http://rohitguptablog.wordpress.com/2011/06/16/configuring-wcf-service-with-nettcpbinding/

enter image description here

but when i try to start those services then i am getting error enter image description here

so please guide me in details how could start those service and also guide me what else i need to setup in my pc as a result i can test my wcf apps with tcp binding from my pc from vs2010 ide. thanks

Mou
  • 15,673
  • 43
  • 156
  • 275

1 Answers1

1

Did you enable NET.TCP in IIS?

See below:

http://randypaulo.wordpress.com/2011/11/14/iis-7-how-to-enable-net-tcp/ Enabling net.tcp in IIS7

Community
  • 1
  • 1
George Philip
  • 704
  • 6
  • 21
  • basically when i am testing my service from wcf test client then i am getting error. that is why i am not thinking about iis. i guess if there would be problem then wcf test client shout and i guess there is some problem may be in my code or in config code or may be i have to start few services. i try to start service but got error. so just tell me how could i start those service? if anything i need to install then tell me. thanks – Thomas Jan 24 '14 at 06:48
  • Did you start the net tcp port sharing service: http://msdn.microsoft.com/en-us/library/ms733925(v=vs.110).aspx – George Philip Jan 24 '14 at 06:52
  • So are you self hosting or IIS hosting? – George Philip Jan 24 '14 at 06:55
  • i have plan to host in iis & self host but first try to run the service from VS2010 IDE. so wcf test client is giving problem.just tell me what i need to fix as a result wcf test client will not throw any error. thanks – Mou Jan 25 '14 at 08:24