【问题标题】:Running WCF Service on Vista 64 bit在 Vista 64 位上运行 WCF 服务
【发布时间】:2010-01-14 08:32:44
【问题描述】:

我有一个简单的控制台应用程序,它作为 WCF 服务主机运行。使用 bsicHttpBinding。 当我尝试在我的客户端(另一个控制台应用程序)中获取服务引用时,我收到此错误

"下载 http://localhost:9999/TS 时出错。 请求失败,HTTP 状态为 400:错误请求。 元数据包含无法解析的引用:“http://localhost:9999/TS”。 内容类型应用程序/soap+xml;服务 http://localhost:9999/TS 不支持 charset=utf-8。客户端和服务绑定可能不匹配。 远程服务器返回错误:(415)无法处理消息,因为内容类型'application/soap+xml; charset=utf-8' 不是预期的类型 'text/xml;字符集=utf-8'.. 如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用。"

请提供任何指示。

App.config:

<configuration>
    <system.serviceModel>
        <services>
            <service
                name="TimeServiceLibrary.TimeService"
                behaviorConfiguration="TSConfig">
                <endpoint address="localhost:9999/TS"
                    binding="basicHttpBinding"
                    contract="TimeServiceLibrary.ITime">
                </endpoint>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="TSConfig">
                    <serviceMetadata httpGetEnabled="True"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>

【问题讨论】:

    标签: .net wcf


    【解决方案1】:

    该错误似乎表明它试图在 wsHttpBinding 上使用 SOAP 1.2,但我还不确定为什么(一定是缺少咖啡)。如果您发布配置文件的相关部分可能会有所帮助,或者如果文件太大则将其上传到某处

    当您浏览到http://localhost:9999/TS/?WSDL 时,您会得到什么?

    您是否配置了 mex 端点(元数据交换)?有关示例配置,请参阅 here

    【讨论】:

    • 我的浏览器出现同样的 HTTP 状态 400 错误。无法查看我的服务元数据。
    • 这就是我的 app.config 的样子:
    • 那么,还没有 mex 端点吗?为了便于阅读,我已将配置添加到您的问题中。
    【解决方案2】:

    嗯,基本 HTTP 绑定在底层使用 SOAP 1.1,而后者又使用 text/xml 的内容类型。较新的 WS-HTTP 绑定使用 SOAP 1.2,它使用 application/soap+xml 内容类型。 WCF 抱怨,因为您的服务似乎设置为使用带有 application/soap+xml 内容类型的基本 HTTP 绑定,这将无法正常工作。

    也许您可以尝试在地址中的localhost 之前添加http://,或者只使用TS 作为地址,并在基本地址元素中指定http://localhost:9999,例如在&lt;service&gt; 元素内:

    <baseAddress>
       <add baseAddress="http://localhost:9999/" />
    </baseAddress>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-08
      • 1970-01-01
      • 1970-01-01
      • 2011-08-19
      • 1970-01-01
      相关资源
      最近更新 更多