Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.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服务:无法使用wcfTestClient-无法获取元数据_C#_Wcf_Utf 8 - Fatal编程技术网

C# 自托管WCF服务:无法使用wcfTestClient-无法获取元数据

C# 自托管WCF服务:无法使用wcfTestClient-无法获取元数据,c#,wcf,utf-8,C#,Wcf,Utf 8,该服务确实正常工作,但由于某些原因,我无法从本地pc向服务器使用wcftestclient.exe-我想使用wcftestclient.exe调用一个方法 它的所有公司内部、自托管(在windows服务中运行,无iis)。框架4。基本的TPBinding,不需要任何安全的东西 这是我的servicemodelconfig <system.serviceModel> <services> <service name="myService">

该服务确实正常工作,但由于某些原因,我无法从本地pc向服务器使用wcftestclient.exe-我想使用wcftestclient.exe调用一个方法

它的所有公司内部、自托管(在windows服务中运行,无iis)。框架4。基本的TPBinding,不需要任何安全的东西

这是我的servicemodelconfig

<system.serviceModel>
    <services>
      <service name="myService">

        <endpoint
          address="http://servername:8001/myService" 
          binding="basicHttpBinding"
          contract="IMyService" />

      </service>
    </services>


    <behaviors>
      <serviceBehaviors>
        <behavior name ="MyDefaultBehaviour">
          <serviceMetadata httpGetEnabled="true" httpGetUrl="http://servername:8001/myService/mex" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceThrottling maxConcurrentCalls="1" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

我得到

错误:无法获得元数据,如果这是您可以访问的Windows(R)通信基础服务,请检查您是否已在指定地址启用元数据发布。有关启用元数据发布的帮助,请参阅位于Exchange错误URI的MSDN文档:

元数据包含无法解析的引用:'。内容类型应用程序/soap+xml;服务不支持字符集=utf-8

客户端和服务绑定可能不匹配。远程服务器返回错误:(415)无法处理消息,因为内容类型为“application/soap+xml”;charset=utf-8“不是预期的类型”text/xml;字符集=utf-8'..HTTP获取错误URI:

下载“http://

请求失败,HTTP状态为400:请求错误

我已经在上面划掉了我们的服务器名,所以有很多空白,但希望消息足够清楚

我做了添加额外端点的实验

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

但是有了这个,windows服务就无法启动了

谢谢

-----后来添加---我们也尝试过这个,但再一次,服务无法启动

<system.serviceModel>
    <services>
      <service name="myService" behaviorConfiguration="MyDefaultBehaviour">
        <host>
          <baseAddresses>
            <add baseAddress="http://myServer:8001/myService" />
          </baseAddresses>
        </host>

        <endpoint
          address=""
          binding="basicHttpBinding"
          contract="Contracts.ImyService" />

        <endpoint
          address="mex"
          binding="mexHttpBinding"
          contract="IMetaDataExchange" />
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name ="MyDefaultBehaviour">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceThrottling maxConcurrentCalls="1" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

如果添加mexendpoint,则需要添加基地址: 如下图所示:

<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:9999/WcfTcp/Service1"/>
          </baseAddresses>
        </host>


我的第二个配置毕竟可以工作,即使用BasAddress、标准端点的空字符串和“mex”端点。IMetadataExchange的大写字母D拼写不正确。已排序。非常感谢@Grady

谢谢@Grady-我确实尝试了基址方式,但不是在端点标记内,而是在服务标记内,但windows服务无法启动。另外,我正在使用http。