首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IIS中的多个wcf服务

IIS中的多个wcf服务
EN

Stack Overflow用户
提问于 2013-01-08 17:34:05
回答 1查看 746关注 0票数 1

我试图在IIS下运行多个WCF服务,使用相同的基本URL (因此我的项目有多个.svc文件)。当我有一个服务时,一切都很好,但是当我添加额外的服务时,问题就出现了。当我尝试访问这些附加服务时,客户似乎认为合同是"IMerchantService“合同。例如,如果我浏览到http://merchants.localtest.me/MerchantProductService.svc?wsdl (本地托管服务的地址),返回的服务定义是IMerchantService而不是IMerchantProductService。此外,当我浏览到http://merchants.localtest.me/MerchantProductService.svc时,标题是"MerchantService“,而不是我所期望的"MerchantProductService”。

我的服务配置如下:

代码语言:javascript
复制
  <services>
  <service name="MyCompany.Services.Merchants.MerchantProductService">
    <endpoint address="" behaviorConfiguration="Proto.Common.EndpointBehavior" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Common" contract="MyCompany.Api.Merchants.Services.IMerchantProductService"/>
    <endpoint address="mexMerchantProductService"
          binding="mexHttpBinding"
          contract="IMetadataExchange" />
  </service>
  <service name="MyCompany.Services.Merchants.MerchantService">
    <endpoint address="" behaviorConfiguration="Proto.Common.EndpointBehavior" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Common" contract="MyCompany.Api.Merchants.Services.IMerchantService"/>
    <endpoint address="mexMerchantService"
          binding="mexHttpBinding"
          contract="IMetadataExchange"  />
  </service>
  <service name="MyCompany.Services.Merchants.Workflows.NewMerchantWorkflow">
    <endpoint address="" behaviorConfiguration="Proto.Common.EndpointBehavior" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Common" contract="MyCompany.Api.Merchants.Services.INewMerchantServiceWorkflow"/>
    <endpoint address="mexNewMerchantWorkflow"
  binding="mexHttpBinding"
  contract="IMetadataExchange" />
  </service>
  <service name="MyCompany.Services.Merchants.MerchantFreightService">
    <endpoint address="" behaviorConfiguration="Proto.Common.EndpointBehavior" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Common" contract="MyCompany.Api.Merchants.Services.IMerchantFreightService"/>
    <endpoint address="mexMerchantFreightService"
  binding="mexHttpBinding"
  contract="IMetadataExchange" />
  </service>
  <service name="MyCompany.Services.Merchants.MerchantAuctionService">
    <endpoint address="" behaviorConfiguration="Proto.Common.EndpointBehavior" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Common" contract="MyCompany.Api.Pricing.Services.IMerchantAuctionService"/>
    <endpoint address="mexMerchantAuctionService"
  binding="mexHttpBinding"
  contract="IMetadataExchange" />
  </service>
</services>

我尝试过移除额外的mex端点,但这并没有什么区别。另外,我检查了合同,在我看来,它们看上去还不错。IMerchantProductService合同如下:

代码语言:javascript
复制
[ServiceContract(Namespace = "http://www.MyCompany.com/services/", Name = "MerchantProductService")]
[ContractClass(typeof(MerchantProductServiceContracts))]
public interface IMerchantProductService
{
    /// <summary>
    /// Searchs the merchants product catalog using product name, merchant sku or product global id
    /// </summary>
    /// <param name="searchTerm"></param>
    /// <returns></returns>
    [OperationContract]
    List<MerchantProductQuickSearchItem> QuickSearchMerchantProducts(int merchantId, string searchTerm);

    /// <summary>
    /// Gets a merchant product based on the Id
    /// </summary>
    /// <param name="ourMerchantProductId">The id of the product to get</param>
    /// <returns></returns>
    [OperationContract]
    MerchantProduct GetMerchantProduct(int ourMerchantProductId, int merchantId);

    ///etc.

}

IMerchantService的合同如下:

代码语言:javascript
复制
[ServiceContract(Namespace = "http://www.MyCompany.com/services/", Name = "MerchantService")]
[ContractClass(typeof(MerchantServiceContracts))]
public interface IMerchantService
{
    /// <summary>
    /// Gets a merchant instance
    /// </summary>
    /// <param name="merchantId"></param>
    /// <returns></returns>
    [OperationContract]
    Merchant GetMerchant(int merchantId);

    /// <summary>
    /// Gets a merchant's bid settings
    /// </summary>
    /// <param name="merchantId"></param>
    /// <returns></returns>
    [OperationContract]
    MerchantBidSettings GetMerchantBidSettings(int merchantId);

    //etc.
}

到目前为止我尝试过的事情:

  1. 将所有内容更改为basicHttpBinding。没什么区别。
  2. 删除Protobuf行为配置。没什么区别。
  3. 删除单个mex端点。没什么区别
  4. 尝试不同的客户端(WCFStorm,WCF测试客户端)并报告错误的合同
  5. 检查各个svc文件是否正在实现预期的契约(它们是)。

我想我的问题是( 1)这是否可能(即多个.svc文件与IIS托管),如果是的话,我的配置是否有问题,可能导致我的问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-08 18:09:28

检查每个.svc文件的内容。您是否引用正确的服务实现?您需要web.config + .svc文件+ c#契约定义+ c#服务实现来实现它。

代码语言:javascript
复制
<%@ ServiceHost 
    Language="C#"
    Debug="true"
    Service="MyCompany.Services.Merchants.MerchantService" %>
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14220814

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档