VS2010中的WCF服务库显示“WCF无法添加Service.Service元数据可能无法访问。请确保您的服务正在运行一个展示元数据” [英] WCF Service Library in VS2010 showing "WCF Failed to Add Service.Service Metadata may not be accessible.Make Sure your Service is Running andexposing metadata"

查看:65
本文介绍了VS2010中的WCF服务库显示“WCF无法添加Service.Service元数据可能无法访问。请确保您的服务正在运行一个展示元数据”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

我在VS 2010中创建了WCF服务库,参考了codeproject.com上的WCF服务示例文章。

接口是 IBookService

实现接口的类是 BookService

名称空间包含类以及接口 WCFCodeProjectSampleService



请帮我解决这个问题。我尝试了很多方法,但我无法解决。



下面是我正在使用的App.config文件:





I have created WCF Service library in VS 2010 with reference to WCF Service Sample article from codeproject.com.
Interface is IBookService
Class which implements interface is BookService
Namespace which contains class as well Interface WCFCodeProjectSampleService

Please help me to solve this issue.I have tried so many ways but i am not able to solve it.

Below is App.config file which currently i am using:


<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="NewBinding0" />
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="WCFCodeProjectSampleService.ServiceBehaviour" name="WCFCodeProjectSampleService.BookService">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="NewBinding0"

          contract="WCFCodeProjectSampleService.IBookService">
          <identity>
            <dns value="localhost" />
            <certificateReference storeLocation="LocalMachine" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""

          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/WCFCodeProjectSampleService/BookService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WCFCodeProjectSampleService.ServiceBehaviour">
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- 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="False"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

推荐答案

您的服务应该运行,然后,您可以将端点地址设置为目标应用程序中的Web服务地址。

此外,当存在与WCF服务关联的多个端点时,您可以定义主地址然后通过相对地址解决这些端点。主地址称为基地址。您可以按如下方式定义基址:

Your service should be run,then, you can set the endpoint address as your webservice address in the target application.
Additionally, When there are multi endpoints which are associated with a WCF service, you can define a primary address and then address those endpoints through a relative address. The primary address is called Base Address. You can define the base addresses as below:
<host>
<baseAddresses>
<add baseaddress="http://localhost:8080/QuickReturns" />
<add baseaddress="net.pipe://localhost/QuickReturns" />
</baseAddresses>
</host>



端点的相对地址如下:


And the relative addresses for endpoint would be like this:

<endpoint>
name="BasicHttpBinding"
address="Exchange"
bindingsSectionName="BasicHttpBinding"
contract="IExchange" />
<endpoint>
name="NetNamedPipeBinding"
address="Exchange"
bindingsSectionName="NetNamedPipeBinding"
contract="IExchange" />
</endpoint></endpoint>



你当前的地址是空的,这就是你打电话时它不可用的原因。


You current address is empty and this is why it is not available when you call it.


这篇关于VS2010中的WCF服务库显示“WCF无法添加Service.Service元数据可能无法访问。请确保您的服务正在运行一个展示元数据”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆