远程计算机的本地Web服务访问(本地主机与IP地址)
问题描述:
我是使用Web服务的新手。远程计算机的本地Web服务访问(本地主机与IP地址)
我使用visual studio 2017在C#中创建了一个Web服务(该服务是一个.svc文件)。
此Web服务发布到远程计算机上的文件夹。
当我连接到远程机器,我可以运行带有URL的Web服务:
http://localhost:1869/ServiceName.svc/
但是,当我试图从我的计算机上运行的Web服务,我试图修改通过用ip地址替换'localhost'来实现url,但它不起作用。
是否可以远程访问本地Web服务?
如果没有,发布Web服务的最佳方式是什么,以便它可以远程访问?
感谢您的帮助!
-EDIT-
请参阅下面的Web.config代码。
我试图在远程机器上创建一个Web服务器并把Visual Studio解决方案项目/用C编译:\的Inetpub \ wwwroot文件,并没有帮助
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="RsConnString" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|RestDB.mdf;User Instance=true" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data></configuration>
答
感谢您的帮助!
我能够使它从那里以下指令:link
它归结为正确配置IIS和网站。
的关键问题,回答是:
你有没有在IIS服务器级别启用基本身份验证?
您是否启用了到Web管理服务的远程连接?
您是否开始Web管理服务?
是否有管理服务委派规则?
防火墙是否允许TCP端口8172上的服务器传入连接?
它取决于您如何托管服务。它是自己托管的,还是在iis上? – Digvijay
感谢您的回答!它是自我托管的。 – yoann
你使用basicHttpBinding,wsHttpBinding等什么绑定?如果你可以显示一些代码 - 你试过的东西等等会很棒。 – Digvijay