错误:无法添加服务.服务元数据可能无法访问.确保您的服务正在运行并公开元数据. [英] Error : Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.

查看:368
本文介绍了错误:无法添加服务.服务元数据可能无法访问.确保您的服务正在运行并公开元数据.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行WCF服务库时,出现以下错误:

错误:无法从获取元数据 http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary5/Service1/mex

如果这是您有权访问的Windows(R)Communication Foundation服务,请检查是否已在指定地址启用了元数据发布.有关启用元数据发布的帮助,请参阅MSDN文档,网址为 http://go.microsoft.com/fwlink/?LinkId=65455 .

WS-Metadata交换错误
    URI: http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary5/Service1/mex

  元数据包含无法解析的引用:"http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary5/Service1/mex".

  无法连接到 http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary5/Service1/mex . TCP错误代码10061:无法建立连接,因为目标计算机主动拒绝了127.0.0.1:8731.

  无法连接到远程服务器

  无法建立连接,因为目标计算机主动拒绝了127.0.0.1:8731

HTTP GET错误
    URI: http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary5/Service1/mex

  下载'http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary5/Service1/mex'时出错.

  无法连接到远程服务器

  无法建立连接,因为目标计算机主动拒绝了127.0.0.1:8731

请提出解决方案.

App.config

 

xml 版本 = " "" 编码 = " " ?>

<

 

配置 >

 

system.web >

<

 

编译 调试 = " "" />

</

 

system.web >

<!-

 

在部署服务库项目时,内容配置文件必须添加到主机的

app.config文件. System.Configuration不支持库的配置文件.

 

->

 

system.serviceModel >

<

 

服务 >

 

服务 名称 = " &"; behaviorConfiguration = " &"; >

 

主机 >

 

baseAddresses >

 

添加 baseAddress = &; http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary5/Service1/

</

 

baseAddresses >

 

主机 >

 

服务端点 ->

<!-

 

除非完全限定,否则地址是相对于基数的以上提供的地址 ->

<

 

端点 地址 = "" 绑定 = " " 合同 = " &"; >

 

部署后,应删除或替换以下标识元素以反映

运行已部署服务的身份.如果删除,WCF将推断出适当的身份

自动.

 

 

->

 

身份 >

 

dns = " "" />

 

身份 >

 

端点 >

 

元数据端点 ->

<!-

 

服务使用了元数据交换终结点向客户描述自己. ->

<!-

 

此端点未使用安全绑定,部署前应固定或移除 ->

<

 

端点 地址 = " "" 绑定 = " &"; 合同 = " "" />

 

服务 >

 

服务 >

 

行为 >

 

服务行为 >

 

行为 名称 = " "" >

 

为避免泄露元数据信息,

将下面的值设置为false并在部署之前删除上面的元数据终结点

 

->

 

serviceMetadata httpGetEnabled = " "" />

 

在故障中接收异常详细信息以进行调试,

将下面的值设置为true.部署前设置为false

为避免泄露异常信息

 

->

 

serviceDebug includeExceptionDetailInFaults = " "" />

</

 

行为 >

 

服务行为 >

 

行为 >

 

system.serviceModel >

</

 

配置 >

解决方案

您好,我在配置文件中找不到任何问题.但是,如果服务未正确启动,也可能导致此错误.您可以尝试在控制台应用程序中托管服务并对其进行调试吗?


While running the WCF Service Library, i m getting following error:

Error: Cannot obtain Metadata from http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary5/Service1/mex

If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.  For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.

WS-Metadata Exchange Error
    URI: http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary5/Service1/mex

    Metadata contains a reference that cannot be resolved: 'http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary5/Service1/mex'.

    Could not connect to http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary5/Service1/mex. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8731.

    Unable to connect to the remote server

    No connection could be made because the target machine actively refused it 127.0.0.1:8731

HTTP GET Error
    URI: http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary5/Service1/mex

    There was an error downloading 'http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary5/Service1/mex'.

    Unable to connect to the remote server

    No connection could be made because the target machine actively refused it 127.0.0.1:8731

Kindly suggest solutions..

App.config

<?

 

xml version="1.0" encoding="utf-8" ?>

<

 

configuration>

<

 

system.web>

<

 

compilation debug="true" />

</

 

system.web>

<!--

 

When deploying the service library project, the content of the config file must be added to the host's

app.config file. System.Configuration does not support config files for libraries.

 

-->

<

 

system.serviceModel>

<

 

services>

<

 

service name="WcfServiceLibrary5.Service1" behaviorConfiguration="WcfServiceLibrary5.Service1Behavior">

<

 

host>

<

 

baseAddresses>

<

 

add baseAddress = "http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary5/Service1/" />

</

 

baseAddresses>

</

 

host>

<!--

 

Service Endpoints -->

<!--

 

Unless fully qualified, address is relative to base address supplied above -->

<

 

endpoint address ="" binding="wsHttpBinding" contract="WcfServiceLibrary5.IService1">

<!--

 

Upon deployment, the following identity element should be removed or replaced to reflect the

identity under which the deployed service runs. If removed, WCF will infer an appropriate identity

automatically.

 

 

-->

<

 

identity>

<

 

dns value="localhost"/>

</

 

identity>

</

 

endpoint>

<!--

 

Metadata Endpoints -->

<!--

 

The Metadata Exchange endpoint is used by the service to describe itself to clients. -->

<!--

 

This endpoint does not use a secure binding and should be secured or removed before deployment -->

<

 

endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

</

 

service>

</

 

services>

<

 

behaviors>

<

 

serviceBehaviors>

<

 

behavior name="WcfServiceLibrary5.Service1Behavior">

<!--

 

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>

</

 

configuration>

解决方案

Hello, I can't spot any problems in the configuration file. But this error can also be caused if the service did not start correctly. Can you try to host the service in a console application, and debug it?


这篇关于错误:无法添加服务.服务元数据可能无法访问.确保您的服务正在运行并公开元数据.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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