简体   繁体   English

如何在IIS中注册Web服务?

[英]how to register a web service in iis?

I have a web service made in c# and I want to know how to register it in IIS for consumption from another app. 我有一个用c#制作的Web服务,我想知道如何在IIS中注册它以便从另一个应用程序使用。 I know how to consume it from the same solution but this isn't the same case. 我知道如何从相同的解决方案中使用它,但是情况不一样。 Searching the internet, I've only found how to register an app. 搜索互联网时,我仅找到了如何注册应用程序。

A web service is treated like any other website in IIS. Web服务的处理方式与IIS中的任何其他网站一样。 Simply convert the site to an application and pick the appropriate .Net framework version. 只需将站点转换为应用程序,然后选择适当的.Net框架版本。

After you have setup the website for web service you need to do some setting in your web.config. 设置Web服务网站之后,您需要在web.config中进行一些设置。 I guess you might be missing them 我想你可能会想念他们

Add service to the web.config like following 将服务添加到web.config中,如下所示

<services>
  <service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
    <endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web">         
    </endpoint>
  </service>
</services>

Also add service behaviour and endpoint behaviour 还添加服务行为和端点行为

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM