相关疑难解决方法(0)

请求WCF服务合同时出现HTTP错误请求错误

我有一个WCF服务,具有以下配置:

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="MetadataEnabled">
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceMetadata httpGetEnabled="true" />
            </behavior>
        </serviceBehaviors>
     </behaviors>
      <services>
          <service behaviorConfiguration="MetadataEnabled" name="MyNamespace.MyService">
              <endpoint name="BasicHttp"
                        address=""
                        binding="basicHttpBinding"
                        contract="MyNamespace.IMyServiceContract" />
              <endpoint name="MetadataHttp"
                        address="contract"
                        binding="mexHttpBinding" 
                        contract="IMetadataExchange" />
              <host>
                  <baseAddresses>
                      <add baseAddress="http://localhost/myservice" />
                  </baseAddresses>
              </host>
          </service>
    </services>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

WcfSvcHost.exe进程中托管服务时,如果我浏览到URL:

HTTP://本地主机/为MyService /合同

服务元数据可用的地方我收到HTTP 400 Bad Request错误.

通过检查WCF日志,我发现抛出了System.Xml.XmlException异常,并显示消息:" 无法读取消息正文,因为它是空的. "
以下是日志文件的摘录:

<Exception>
<ExceptionType>
System.ServiceModel.ProtocolException, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
</ExceptionType>
<Message>There is a problem with the XML that was received from the network. See …
Run Code Online (Sandbox Code Playgroud)

wcf wsdl exception http

12
推荐指数
2
解决办法
8万
查看次数

标签 统计

exception ×1

http ×1

wcf ×1

wsdl ×1