我想在IIS上托管我的服务,让本地网络的人们使用它。这是我的界面:
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);
}
}
和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上添加此服务,但它没有工作。我设置了sitename&#34;我的服务&#34;,带有svc文件的目录路径,主机名&#34; myservice&#34;和港口。它没有用。即使在我的本地机器上,A也无法访问它。