[英]local web service access from remote computer (localhost vs. ip address)
I'm new to using web services. 我是使用Web服务的新手。
I created a web service in C# using visual studio 2017 (the service is a .svc file). 我使用Visual Studio 2017在C#中创建了一个Web服务(该服务是.svc文件)。
This web service is published to a folder on a remote machine. 该Web服务将发布到远程计算机上的文件夹中。
When I connect to the remote machine, I can run the web service with the url: 当我连接到远程计算机时,可以使用url运行Web服务:
http://localhost:1869/ServiceName.svc/ http:// localhost:1869 / ServiceName.svc /
But when I'm trying to run the web service from my computer, I tried to modify the url by replacing 'localhost' with the ip address but it doesn't work. 但是,当我尝试从计算机上运行Web服务时,我试图通过用IP地址替换“ localhost”来修改url,但是它不起作用。
Is it possible to access remotely a local web service? 是否可以远程访问本地Web服务?
If not, what is the best way to publish the web service so that it can be accessed remotely? 如果不是,那么发布Web服务以便可以对其进行远程访问的最佳方法是什么?
Thanks for your help! 谢谢你的帮助!
-EDIT- -编辑-
See Web.config code below. 请参阅下面的Web.config代码。
I tried to create a web server on the remote machine and place the Visual Studio solution project / compile it in C:\\inetpub\\wwwroot, did not help 我试图在远程计算机上创建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>
Thanks for your help! 谢谢你的帮助!
I was able to make it work following instruction from there: link 我能够按照那里的指示进行操作: 链接
It boils down to configuring IIS and the website correctly. 归结为正确配置IIS和网站。
The key questions to answer were: 要回答的关键问题是:
Have you enabled basic authentication at the server level in IIS? 您是否在IIS中在服务器级别启用了基本身份验证?
Have you enabled remote connections to the Web Management Service? 是否启用了到Web管理服务的远程连接?
Have you started the Web Management Service? 您是否启动了Web管理服务?
Are there management service delegation rules in place? 是否有管理服务委托规则?
Does your firewall allow incoming connections to the server on TCP port 8172? 您的防火墙是否允许TCP端口8172上的服务器的传入连接?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.