2010-09-29 103 views
2

我正在尝试创建一个WCF服务与匿名身份验证。当我将服务部署到目前不在我当前域的目标服务器时,我尝试调用它时收到以下错误:WCF服务绑定wsHttp与基本没有身份验证

内容类型application/soap + xml; charset = utf-8不支持 服务http://myserver.com/page.svc。 客户端和服务绑定可能是 不匹配。

因为目前的情况是我在为我服务的web.config文件中的以下部分:

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"> 
    </modules> 
    </system.webServer> 

我一直在尝试不同的绑定(的wsHttpBinding和basicHttpBinding的),但我要么收到上述错误(使用basicHttpBinding)或“访问被拒绝”消息(使用wsHttpBinding)。以下是我在使用wsHttpBinding时试图使用的web.config部分

<system.serviceModel> 
    <services> 
    <service behaviorConfiguration="AMP.MainBehavior" name="AMP.Main"> 
    <endpoint address="" binding="wsHttpBinding" contract="AMP.IMain"> 
     <identity> 
     <dns value="myservice.com"/> 
     </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
    </service> 
    </services> 
    <behaviors> 
    <serviceBehaviors> 
    <behavior name="AMP.MainBehavior"> 
    <serviceMetadata httpGetEnabled="true"/> 
    <serviceDebug includeExceptionDetailInFaults="true"/> 
    </behavior> 
    </serviceBehaviors> 
    </behaviors> 
</system.serviceModel> 

该服务已使用.NET 4.0框架创建。我需要它是匿名的,但我不确定我错过了什么。我是WCF的新手,所以我没有连续排好所有的鸭子。

谢谢

+0

什么是客户端的配置? – 2010-09-29 11:43:33

回答

4

错误表示您发送的HTTP请求的内容类型不受支持。提到的内容类型在SOAP 1.2中使用,但BasicHttpBinding使用具有不同内容类型(text/xml; charset = utf-8)的SOAP 1.1。因此,您的服务和客户端配置之间可能存在一些不匹配。

在你的第二个例子中,问题是默认的WsHttpBinidng配置。 WsHttpBinding在默认情况下使用邮件安全性进行保护,Windows身份验证= >异常,因为计算机位于不同的域中,因此Windows auhtentication无法工作。你必须定义你自己的WsHttpBinding配置。试试这个(客户端必须使用相同的绑定配置):

<system.serviceModel> 
    <bindings> 
    <wsHttpBinding> 
     <binding name="Unsecured"> 
     <security mode="None" /> 
     </binding> 
    </wsHttpBinding> 
    </bindings> 
    <services> 
    <service ...> 
     <endpoint address="..." contract="..." 
     binding="wsHttpBinding" bindingConfiguration="Unsecured" /> 
     ... 
    </service> 
    </services> 
</system.serviceModel> 
+1

谢谢你的回应!我在你建议的配置中添加了,并将终端地址设置为服务所在的URL,现在我收到了一个不同的错误。它以“由于与远程端点的安全协商失败而无法打开安全通道”开始。 – 2010-09-29 12:03:45