我很擅长使用网络服务。
我使用Visual Studio 2017在C#中创建了一个Web服务(该服务是一个.svc文件)。
此Web服务将发布到远程计算机上的文件夹中。
当我连接到远程计算机时,我可以使用url运行Web服务:
http://localhost:1869/ServiceName.svc/
但是当我尝试从我的计算机上运行网络服务时,我尝试通过替换“localhost”来修改网址。使用IP地址,但它不起作用。
是否可以远程访问本地Web服务?
如果没有,发布Web服务以便远程访问它的最佳方法是什么?
感谢您的帮助!
- 编辑 -
请参阅下面的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>
答案 0 :(得分:0)
感谢您的帮助!
我能够按照那里的指示开始工作:link
归结为正确配置IIS和网站。
要回答的关键问题是:
您是否在IIS中的服务器级启用了基本身份验证?
您是否启用了与Web管理服务的远程连接?
您是否启动了Web管理服务?
是否有管理服务授权规则?
您的防火墙是否允许在TCP端口8172上与服务器建立传入连接?