我有一个WCF服务已运行多年,我经常更新/添加。我通常在部署到生产服务器之前从VS内测试服务。我最近尝试添加一个新的端点,如this(DeliveryReport),接口和实现:
[ServiceContract (Namespace = "carsweb.no/")]
public interface IService1
{
[OperationContract]
[WebInvoke]
string DeliveryReport(string s);
//[OperationContract]
//string GetData(string value); several here....
public class Verksted : IService1
{
public string DeliveryReport(string rep)
{
return "You posted " + rep;
}
然后VS中的WCF测试客户端拒绝添加该服务并给我这条消息: "无法添加服务。可能无法访问服务元数据。确保您的服务正在运行并公开元数据。" 然后,我评论了所有我的更改(不是很多),同样删除了对ServiceModel.Web'的引用。我不得不补充一下。但是在启动WCF测试客户端时我仍然会遇到相同的错误,尽管一切都和以前一样。没有对配置进行任何更改(我已经检查过)。之前和之后的配置是相同的:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<configSections>
<section name="CarsGlobalService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<appSettings>
<add key="LogFolder" value="C:\usr\INF05\TMP\"/>
<add key="ConfigFolder" value="c:\CarsGlobal\Config\"/>
</appSettings>
<system.web>
<compilation debug="true"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICommissionFacade" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport"/>
</binding>
<binding name="MedlemServiceSoap">
<security mode="Transport"/>
</binding>
<binding name="dbsBinding" sendTimeout="00:10:00">
<security mode="Transport"/>
</binding>
<binding name="ServiceSoap"/>
<binding name="ApplicationWebService" maxReceivedMessageSize="20000000">
<security mode="Transport"/>
</binding>
<binding name="emsPortBinding"/>
<binding name="VerkstedSoap" maxReceivedMessageSize="20000000">
<security mode="Transport"/>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint Several endpoints in here which all works well"/>
</client>
<services>
<service name="CarsGlobalService.Verksted">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/CarsGlobalService/Verksted/mex"/>
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" contract="CarsGlobalService.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
来自WCF客户端的完整消息
Error: Cannot obtain Metadata from http://localhost:8733/Design_Time_Addresses/CarsGlobalService/Verksted/mex?wsdl 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:8733/Design_Time_Addresses/CarsGlobalService/Verksted/mex?wsdl
Metadata contains a reference which cannot be resolved: http://localhost:8733/Design_Time_Addresses/CarsGlobalService/Verksted/mex?wsdl.
No endpoints listening on http://localhost:8733/Design_Time_Addresses/CarsGlobalService/Verksted/mex?wsdl, som kunne godta meldingen. Dette skyldes ofte en feil adresse eller SOAP-handling. Se InnerException, hvis tilgjengelig, hvis du vil ha flere detaljer.
Cannot connect to the external server.
Cannot connect because the computer refused connection on 127.0.0.1:8733HTTP GET Error
URI: http://localhost:8733/Design_Time_Addresses/CarsGlobalService/Verksted/mex?wsdl
Error occurred during downloading of http://localhost:8733/Design_Time_Addresses/CarsGlobalService/Verksted/mex?wsdl.
Cannot connect to the external server Cannot connect because the target computer refused connection 127.0.0.1:8733
我几天前尝试制作一些其他的WCF服务,我得到了同样的消息。 这是与网络,我的电脑,我的VS环境或什么?我完全卡住了!