如何在IIS上托管我的WCF服务
我想在IIS上托管我的服务,并让本地网络的用户使用它。这是我的界面:如何在IIS上托管我的WCF服务,wcf,iis,Wcf,Iis,我想在IIS上托管我的服务,并让本地网络的用户使用它。这是我的界面: namespace SubscriptionService { [ServiceContract] public interface ISubsService { // SOA [OperationContract] [WebGet(UriTemplate = "registerevent/{serviceId}/{name}/{description}"
namespace SubscriptionService
{
[ServiceContract]
public interface ISubsService
{
// SOA
[OperationContract]
[WebGet(UriTemplate = "registerevent/{serviceId}/{name}/{description}")]
string RegisterEvent(string serviceId, string name, string description);
[OperationContract]
[WebGet(UriTemplate = "unregisterevent/{serviceId}/{name}")]
string UnregisterEvent(string serviceId, string name);
[OperationContract]
[WebGet(UriTemplate = "riseevent/{serviceId}/{name}")]
string RiseEvent(string serviceId, string name);
// REST
[OperationContract]
[WebGet(UriTemplate = "events/{token}", ResponseFormat = WebMessageFormat.Json)]
List<EventInfo> EventsList(string token);
[OperationContract]
[WebGet(UriTemplate = "subscribe/{token}/{serviceId}/{name}")]
string Subscribe(string token, string serviceId, string name);
[OperationContract]
[WebGet(UriTemplate = "unsubscribe/{token}/{serviceId}/{name}")]
string UnSubscribe(string token, string serviceId, string name);
}
}
命名空间订阅服务
{
[服务合同]
公共接口服务
{
//SOA
[经营合同]
[WebGet(UriTemplate=“registerevent/{serviceId}/{name}/{description}”)]
string RegisterEvent(字符串服务ID、字符串名称、字符串描述);
[经营合同]
[WebGet(UriTemplate=“unregisterevent/{serviceId}/{name}”)]
字符串注销事件(字符串serviceId、字符串名称);
[经营合同]
[WebGet(UriTemplate=“risevent/{serviceId}/{name}”)]
字符串事件(字符串serviceId、字符串名称);
//休息
[经营合同]
[WebGet(UriTemplate=“events/{token}”,ResponseFormat=WebMessageFormat.Json)]
列表事件列表(字符串标记);
[经营合同]
[WebGet(UriTemplate=“subscribe/{token}/{serviceId}/{name}”)]
字符串订阅(字符串令牌、字符串服务ID、字符串名称);
[经营合同]
[WebGet(UriTemplate=“unsubscribe/{token}/{serviceId}/{name}”)]
字符串取消订阅(字符串标记、字符串服务ID、字符串名称);
}
}
和web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="SubscriptionService.SubsService">
<endpoint address="soap" binding="basicHttpBinding" contract="SubscriptionService.ISubsService"></endpoint>
<endpoint address="rest" binding="webHttpBinding" contract="SubscriptionService.ISubsService" behaviorConfiguration="web"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
我需要同时使用soa和rest方法。我的配置有问题吗?我试图在IIS上添加此服务,但没有成功。我设置了站点名“我的服务”、带svc文件的目录路径、主机名“myservice”和端口。但它不起作用。A甚至在我的本地计算机上也无法访问它。您是否尝试从InetMgr浏览.svc文件?这是什么意思?请发布您收到的错误/异常。我在浏览器中收到404