Не удается получить доступ к службе WCF с моего IP-адреса - PullRequest
0 голосов
/ 25 февраля 2019

Я опубликовал службу WCF на своем локальном IIS, и я могу получить к ней доступ по http://localhost/MyTaxiService/MyTaxiServices.svc/TestMethod или http://127.0.0.1/MyTaxiService/MyTaxiServices.svc/TestMethod, но когда я использую свой IP-адрес, например http://192.168.x.x/MyTaxiService/MyTaxiServices.svc/TestMethod,говорит 192.168.xx отказался подключиться.

Вот мой код:

namespace MyTaxiService.Interfaces
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IMyTaxiServices" in both code and config file together.
    [ServiceContract]
    public interface IMyTaxiServices
    {
        [OperationContract]
        [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Xml, UriTemplate = "AddMyTripInformation/{sourceAddress}/{destinationAddress}/{rideDuration}/{rideDistance}")]
        bool AddMyTripInformation(string sourceAddress, string destinationAddress, string rideDuration, string rideDistance);

        [OperationContract]
        [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Xml, UriTemplate = "TestMethod")]
        string TestMethod();


        [OperationContract]
        [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Xml, UriTemplate = "AddMyTripInformation1/{id}")]
        bool AddMyTripInformation1(string id);

        [OperationContract]
        [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Xml, UriTemplate = "AuthenticateRider/{email}/{password}")]
        bool AuthenticateRider(string email, string password);

        [OperationContract]
        [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Xml, UriTemplate = "RiderRegistration/{mobileNumber}/{email}/{name}/{password}/{gender}")]
        bool RiderRegistration(string mobileNumber, string email, string name, string password, string gender);

    }
}

Webconfig:

    <?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="AppDBConnection" connectionString="Data Source=INV-QOVDBMSS7G5.homelinux.com, 1433;Initial Catalog=HRMWF_DGL_Dev;Integrated Security=False;User ID=sa;Password=KRB123rz*" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2"/>
    <httpRuntime targetFramework="4.5.2"/>
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
    </httpModules>
  </system.web>
  <system.serviceModel>
    <services>
      <!--<service name="MyTaxiService.Service1" behaviorConfiguration="ServiceBehaviour">
        <endpoint address="" binding="webHttpBinding" contract="MyTaxiService.IService1" behaviorConfiguration="web">
        </endpoint>
      </service>-->
      <service name="MyTaxiService.MyTaxiServices" behaviorConfiguration="ServiceBehaviour">
        <endpoint address="" binding="webHttpBinding" contract="MyTaxiService.Interfaces.IMyTaxiServices" behaviorConfiguration="web">

        </endpoint>
      </service>
    </services>

    <behaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>

        <behavior name="">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
        <behavior name="useRequestHeadersForMetadataAddress">
          <useRequestHeadersForMetadataAddress/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="ApplicationInsightsWebTracking"/>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
        preCondition="managedHandler"/>
    </modules>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
    <validation validateIntegratedModeConfiguration="false"/>
  </system.webServer>
</configuration>

Есть ли проблемы с моим web.Config?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...