none
WCF Service BasicHttpBinding Internet RRS feed

  • Question

  • Hello!

    I created a WCF Service with BasicHttpBinding.

    This is config:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" />
      </system.web>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="SampleSvcBehavior">
              <serviceDebug includeExceptionDetailInFaults="true" />
              <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8080/SampleSvc/mex" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <services>
          <service behaviorConfiguration="SampleSvcBehavior" name="PLEXTask.WcfHost.CalcService">
            <endpoint address="http://localhost:8080/SampleSvc" binding="basicHttpBinding"
              bindingConfiguration="" name="SampleSvcBasicHttpEndPoint" contract="PLEXTask.WcfHost.ICalcService" />
            <endpoint address="http://localhost:8080/SampleSvc/mex" binding="mexHttpBinding"
              bindingConfiguration="" name="SampleSvcMexEndPoint" contract="IMetadataExchange" />
          </service>
        </services>
      </system.serviceModel>
    </configuration>
    

    I want to access this server from another computer by internet.

    How can I do this?

    Wednesday, March 12, 2014 8:59 PM

Answers

  • Hi,

    If the computers are in the same domain. Then you can use the the Ip address instead of using localhost.
    And it seems that your wcf service is self-host. Then I creat the following example by hosting in the console application, please try to check it:

    class Program
        {
            static void Main(string[] args)
            {
                ServiceHost host = new ServiceHost(typeof(PLEXTask.WcfHost.CalcService));
                host.AddServiceEndpoint(typeof(PLEXTask.WcfHost.ICalcService), new BasicHttpBinding(), 
    "http://your IP address:8080/SampleSvc"); ServiceMetadataBehavior behavior = new ServiceMetadataBehavior(); behavior.HttpGetEnabled = true; behavior.HttpGetUrl = new Uri("http://your IP address:8080/SampleSvc/mex"); host.Description.Behaviors.Add(behavior); host.Open(); Console.WriteLine("wcf is running"); Console.ReadLine(); } }

    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.

    • Marked as answer by ArtsiomRusak Saturday, March 15, 2014 12:18 PM
    Thursday, March 13, 2014 9:00 AM
    Moderator