【发布时间】:2012-12-29 11:59:59
【问题描述】:
首先我要道歉,因为这可能是重复的,但我读到的所有内容似乎都不完整或令人困惑,因为我对 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 调用,我猜这与 @987654328 中的条目有关@
我还阅读了有关创建继承这些接口的类的信息,但我不确定如何根据上面的内容来实现它。需要修改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
}
任何帮助将不胜感激,谢谢:)
【问题讨论】:
-
我看到的一件小事是您为服务 1 和 2 指定了不同的命名空间,即 WCFServices.TestServices.ITestSvc1 和 WCFServices.TestService.ITestSvc2。注意 TestServices.ITestSvc2 中缺少的 s。
-
是的,抱歉,这只是一个错字,只是为了更好地说明问题,请编辑:)
标签: wcf c#-4.0 wcf-binding