如何在WCF服务中使用域名替换计算机名称

时间:2014-11-21 11:44:24

标签: wcf wcf-data-services wcf-binding

我在WCF代理中获取Machine Name并在调用WCF服务时获得以下异常

  

远程服务器返回错误:(415)无法处理消息   因为内容类型'application / soap + xml; charset = utf-8'是   不是预期的类型'text / xml; charset = utf-8'.. HTTP GET错误
  URI:http://MyDomine.com/TCIService/TCIService/TCIService.svc?wsdl
  该文件已被理解,但无法处理。 -   WSDL文档包含无法解析的链接。 - 有   下载错误   'http://MyMachine.Name/TCIService/TCIService/TCIService.svc?xsd=xsd0'。    - 无法解析远程名称:'MyMachineName'

任何人都可以帮我解决这个问题。以下是我的web.config

<system.serviceModel>
        <services>
            <service name="MyService.TCIService.TCIService" behaviorConfiguration="MyServiceBehaviour" >
                <endpoint address="Account" binding="basicHttpBinding" contract="MyService.TCIContract.IAccount"  >
                </endpoint>
                <endpoint address="Location" binding="basicHttpBinding" contract="MyService.TCIContract.ILocation"  >
                </endpoint>
                <endpoint address="Camera" binding="basicHttpBinding" contract="MyService.TCIContract.ICamera" >
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">
                </endpoint>

                <!--<host>
                    <baseAddresses>
                        <add baseAddress="http://localhost:8080/"></add>
                    </baseAddresses>
                </host>-->
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="MyServiceBehaviour">
                    <serviceMetadata httpGetEnabled="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>

1 个答案:

答案 0 :(得分:0)

感谢您的回复汤姆。 我使用

解决了这个问题
<behavior name="MyServiceBehaviour">
    <serviceMetadata httpGetEnabled="true" />
    <useRequestHeadersForMetadataAddress />
</behavior>