首先我要道歉,因为这可能是重复的内容,但是我读到的所有东西似乎都不完整或令人困惑,因为我对WCF非常陌生。
我基本上想在IIS中部署一个WCF服务,并有2个可访问的端点,但我一整天都在打转 :(
我有一个以下结构的服务库WCF dll:
App.config
TestSvc1.cs
ITestSvc1.cs
TestSvc2.cs
ITestSvc2.cs
这在VS WCF测试客户端中运作良好,现在我正在部署到IIS,因此我创建了一个WCF服务应用程序并引用了dll。此项目具有以下结构:
Service1.svc
Web.config
Service1.svc
包含以下内容
<%@ ServiceHost Language="C#" Debug="true"
Service="WCFServices.TestServices.ITestSvc1" CodeBehind="Service1.svc.cs" %>
我的web.config
文件如下所示
<services>
<service name="WCFServices.TestServices.TestSvc2">
<endpoint
address=""
binding="wsHttpBinding" bindingConfiguration="LargeSizeMessages"
contract="WCFServices.TestServices.ITestSvc2">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/wcf2/TestServices/TestSvc2/" />
</baseAddresses>
</host>
</service>
<service name="WCFServices.TestServices.TestSvc1">
<endpoint
address=""
binding="wsHttpBinding" bindingConfiguration="LargeSizeMessages"
contract="WCFServices.TestServices.ITestSvc1"
listenUri="http://localhost:8080/wcf2/service1.svc">
<identity>
<dns value="" />
</identity>
</endpoint>
<endpoint
address=""
binding="wsHttpBinding" bindingConfiguration="LargeSizeMessages"
contract="WCFServices.TestServices.ITestSvc2"
listenUri="http://localhost:8080/wcf2/service1.svc">
<identity>
<dns value="" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/wcf2/TestServices/TestSvc1/" />
</baseAddresses>
</host>
</service>
</services>
非常感谢您的帮助。如您所见,我已尝试在
web.config
中添加一个附加端点,但这并不起作用,出现了一个错误,提示无法在TestSvc1中找到TestSvc2调用,我想这与Service1.svc
中的条目有关。我还阅读了有关创建继承这些接口的类的内容,但我不确定如何根据上述内容来实现它。我需要修改
Service1.svc
吗?public interface MultipleSvc : ITestSvc1, ITestSvc2
{
// What exactly do I put here? I have no idea, do I leave it blank? This didn't work for me
}
任何帮助都将不胜感激,谢谢大家 :)