none
Wcf Service Over internet and intranet RRS feed

  • Question

  • Hello,

      I got the requirement such that same wcf service contract should work on internet and intranet. So, I have created two endpoints for the same service contract i.e, for intranet i am planing to use TCP binding and for internet planing to use wshttpbinding. So you please suggest me whether I have chosen the right decision for exposing the same service over intranet and internet.

     I appreciate your help.

    Thanks

     Shiva

    Thursday, October 24, 2013 2:21 PM

Answers

  • Hi,

    In order to let the wcf service can be accessed over internet, we can use the ip address. Then your service can be accessed in the same domain.

    From your description, I have created a simple example which is self host:
    In the service.config:

      <system.serviceModel>
        <services>
          <service name="WcfServiceLibrary2.Service1">
            <host>
              <baseAddresses>
                <add baseAddress="http://Your IP Address/Service1"/>
              </baseAddresses>
            </host>
            <endpoint address="net.tcp://localhost:8023/Service1" binding="netTcpBinding" contract="WcfServiceLibrary2.IService1"/>
            <endpoint address="net.tcp://localhost:8023/Service1/mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
            <endpoint address="" binding="wsHttpBinding" contract="WcfServiceLibrary2.IService1"/>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceMetadata httpGetEnabled="True"/>
              <serviceDebug includeExceptionDetailInFaults="True" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>

    Then host:

        class Program
        {
            static void Main(string[] args)
            {
                ServiceHost host = new ServiceHost(typeof(WcfServiceLibrary2.Service1));
                host.Open();
                Console.WriteLine("The service is running");
                Console.ReadLine();
            }
        }

    After that you can call the wcf service from the localhost or over the internet in the same domain.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Friday, October 25, 2013 5:34 AM
    Moderator

All replies

  • Hi,

    In order to let the wcf service can be accessed over internet, we can use the ip address. Then your service can be accessed in the same domain.

    From your description, I have created a simple example which is self host:
    In the service.config:

      <system.serviceModel>
        <services>
          <service name="WcfServiceLibrary2.Service1">
            <host>
              <baseAddresses>
                <add baseAddress="http://Your IP Address/Service1"/>
              </baseAddresses>
            </host>
            <endpoint address="net.tcp://localhost:8023/Service1" binding="netTcpBinding" contract="WcfServiceLibrary2.IService1"/>
            <endpoint address="net.tcp://localhost:8023/Service1/mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
            <endpoint address="" binding="wsHttpBinding" contract="WcfServiceLibrary2.IService1"/>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceMetadata httpGetEnabled="True"/>
              <serviceDebug includeExceptionDetailInFaults="True" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>

    Then host:

        class Program
        {
            static void Main(string[] args)
            {
                ServiceHost host = new ServiceHost(typeof(WcfServiceLibrary2.Service1));
                host.Open();
                Console.WriteLine("The service is running");
                Console.ReadLine();
            }
        }

    After that you can call the wcf service from the localhost or over the internet in the same domain.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Friday, October 25, 2013 5:34 AM
    Moderator
  • Thanks you very much Amy
    Friday, October 25, 2013 6:52 AM