Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从WCF服务检索元数据时出错_C#_Wcf_Wcf Endpoint - Fatal编程技术网

C# 从WCF服务检索元数据时出错

C# 从WCF服务检索元数据时出错,c#,wcf,wcf-endpoint,C#,Wcf,Wcf Endpoint,我创建了一个非常简单的WCF服务,但由于某些原因,我在使用svcuti时遇到了问题。我正在使用以下命令: svcutil http://localhost:8098/IceVSServer/service?wsdl 我得到以下输出: Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1] Copyright (c) Mi

我创建了一个非常简单的WCF服务,但由于某些原因,我在使用
svcuti
时遇到了问题。我正在使用以下命令:

svcutil http://localhost:8098/IceVSServer/service?wsdl
我得到以下输出:

Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1]
Copyright (c) Microsoft Corporation.  All rights reserved.

Attempting to download metadata from 'http://localhost:8098/IceVsServer/service?wsdl' using WS-Metadata Exchange or DISCO.
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1]
Copyright (c) Microsoft Corporation.  All rights reserved.

Error: Cannot obtain Metadata from http://localhost:8098/IceVsServer/service?wsdl

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


WS-Metadata Exchange Error
    URI: http://localhost:8098/IceVsServer/service?wsdl

    Metadata contains a reference that cannot be resolved: 'http://localhost:8098/IceVsServer/service?wsdl'.

There was no endpoint listening at http://localhost:8098/IceVsServer/service
?wsdl that could accept the message. This is often caused by an incorrect addres
s or SOAP action. See InnerException, if present, for more details.

The remote server returned an error: (404) Not Found.


HTTP GET Error
    URI: http://localhost:8098/IceVsServer/service?wsdl

There was an error downloading 'http://localhost:8098/IceVsServer/service?wsdl'.

The request failed with HTTP status 404: Not Found.

If you would like more help, type "svcutil /?"
该错误似乎表明我没有MEX端点。我确实这样做了,事实上,如果我把URL放到浏览器中,XML就会立即出现

这是我的app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="IceVSService.IceVsService" behaviorConfiguration="IceVsServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8098/IceVsService/service"/>
          </baseAddresses>
        </host>
        <!-- this endpoint is exposed at the base address provided by host: http://localhost:8098/IceVsService/service  -->
        <endpoint address=""
                  binding="wsHttpBinding"
                  contract="IceVSService.IIceVersioningSystem" />
        <!-- the mex endpoint is explosed at http://localhost:8098/IceVsService/service/mex -->
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="IceVsServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

您将
HttpGet
Mex
混淆。这是发布服务详细信息的两种不同方式—“
元数据交换格式”(MEX)或“
web服务描述语言”(WSDL)

在您的配置中,您已经定义了这两个;但是,您尚未定义
httpgeturl
属性,因此它将被视为空字符串。 因此,您的wsdl地址将是:
http://localhost:8098/IceVsService/service?wsdl
而不是
http://localhost:8098/IceVsServer/service
(IceVsServer未在任何地方定义)


您的mex地址也将与svcutil一起使用:
http://localhost:8098/IceVsService/service/mex

你说得对……就是这样。我累了…漫长的一天哈哈。谢谢你的帮助