C#WCF Web.Config中的多个服务
我试图在我的web.config文件中启用多个WCF服务,但由于某些原因,我得到以下错误C#WCF Web.Config中的多个服务,c#,wcf,C#,Wcf,我试图在我的web.config文件中启用多个WCF服务,但由于某些原因,我得到以下错误 Metadata publishing for this service is currently disabled. 我觉得一切都很好。下面是web.config中的servicemodel。我在网上搜索并遵循了这些方法,但奇怪的是,它对我来说不起作用 <system.serviceModel> <serviceHostingEnvironment multipleSiteBi
Metadata publishing for this service is currently disabled.
我觉得一切都很好。下面是web.config中的servicemodel。我在网上搜索并遵循了这些方法,但奇怪的是,它对我来说不起作用
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
</serviceHostingEnvironment>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingConfig">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<!-- Note: the service name must match the configuration name for the service implementation. -->
<service name="ProductDataService" behaviorConfiguration="ProductDataServiceBehavior">
<!-- Add the following endpoint. -->
<!-- Note: your service must have an http base address to add this endpoint. -->
<endpoint
address="http://api.xxx.com/services/Product.svc"
binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingConfig"
contract="ProductDataService" />
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
<service name="MediaContentService" behaviorConfiguration="MediaContentServiceBehavior">
<!-- Add the following endpoint. -->
<!-- Note: your service must have an http base address to add this endpoint. -->
<endpoint
address="http://api.xxx.com/services/Media.svc"
binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingConfig"
contract="MediaContentService" />
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ProductDataServiceBehavior" >
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" externalMetadataLocation="http://api.xxx.com/wsdl/ProductDataService.wsdl"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
<behavior name="MediaContentServiceBehavior" >
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" externalMetadataLocation="http://api.xxx.com/wsdl/MediaContentService.wsdl"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
编辑
即使我只添加一个服务,它也会中断。它仅在为行为添加名称时发生。以下是仅配置了1个服务的servicemodel
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
</serviceHostingEnvironment>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingConfig">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<!-- Note: the service name must match the configuration name for the service implementation. -->
<service name="ProductDataService" >
<!-- Add the following endpoint. -->
<!-- Note: your service must have an http base address to add this endpoint. -->
<endpoint
address="http://api.xxx.com/services/Product.svc"
binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingConfig"
contract="ProductDataService" />
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" externalMetadataLocation="http://api.xxx.com/wsdl/ProductDataService.wsdl"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
您能检查一下服务名称吗
namespace MyNameSpace
{
.....
public class MyClass: IInterface
{
config中标记上的name=属性必须与服务类的名称完全一致-完全限定,包括名称空间-因此在这里的示例中,它应该是:
<service name="MyNameSpace.MyClass" ......>
此外,您还可以使用mexHttpsBinding,因此可以使用httpsGetEnabled。('s'在您的配置中丢失)在将完整名称空间添加到服务名称和将完整名称空间添加到契约之后,我需要使端点地址相对。下面是我的完整解决方案。对于“Proactive_WebAPI.Services.Media”服务,那么contract给出了一个错误,所以从中删除了名称空间,并且一切正常
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
</serviceHostingEnvironment>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingConfig">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<!-- Note: the service name must match the configuration name for the service implementation. -->
<service name="Proactive_WebAPI.Services.Product" behaviorConfiguration="ProductDataServiceBehavior">
<!-- Add the following endpoint. -->
<!-- Note: your service must have an http base address to add this endpoint. -->
<endpoint
address="Product.svc"
binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingConfig"
contract="Proactive.Product.ProductDataService" />
</service>
<service name="Proactive_WebAPI.Services.Media" behaviorConfiguration="MediaContentServiceBehavior">
<!-- Add the following endpoint. -->
<!-- Note: your service must have an http base address to add this endpoint. -->
<endpoint
address="Media.svc"
binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingConfig"
contract="MediaContentService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ProductDataServiceBehavior" >
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" externalMetadataLocation="http://api.xxx.com/wsdl/ProductDataService.wsdl"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
<behavior name="MediaContentServiceBehavior" >
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" externalMetadataLocation="http://api.xxx.com/wsdl/MediaContentService.wsdl"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
当我添加behaviorConfiguration时,它似乎是在托管或调试时发生爆炸错误?@DarshanPatel while hosting inendpoint
标记契约应该是您与namespace exAbc.Pqr.IXyz
@DarshanPatel的接口名称当我这样做时,它仍然会中断。问题是添加行为名称。只有当我说,然后当我访问服务时它才会抱怨。当我删除完全限定路径并同时删除行为配置时,我仍然会收到相同的错误。所以只需打开1个服务。那么它工作得很好。只要我为行为添加一个名称,它就会complains@Orion您还可以使用MEXHTTPS绑定,因此请使用httpsGetEnabled。(“s”在您的配置中丢失)或删除“s”,希望它能帮助它与mexHttpsBinding一起正常工作。只要我不添加行为名称:/