HTTP请求未经授权,客户端身份验证方案为“Negogiate”。身份验证标题...是'Negotiate,Kerberos,NTLM'

时间:2015-03-16 12:39:43

标签: vb.net wcf authentication ntlm

我们正在尝试使用VB.Net从外部Web服务获取数据。

我们添加了一个服务引用,提供了正确的WSDL。

我们获取数据的代码是:

    Dim MyClient As New ExtConn.GetConnectorSoapClient()

    MyClient.ClientCredentials.UserName.UserName = "AOL\12345.abcde"
    MyClient.ClientCredentials.UserName.Password = "pass123"

    Dim MyReq As New ExtConn.GetDataRequest
    Dim MyResponse As New ExtConn.GetDataResponse

    Dim MyCred As New System.ServiceModel.Description.ClientCredentials()

    Dim MyReqBody As New ExtConn.GetDataRequestBody("Environment123", "AOL\12345.abcde", "pass123", "12345.abcde", "GetData", "")

    MyReq.Body = MyReqBody

    MyResponse = MyClient.ExtConn_GetConnectorSoap_GetData(MyReq)

    MsgBox(MyResponse.Body.GetDataResult)

我们的app.config是:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>

    <bindings>
        <basicHttpsBinding>
            <binding name="GetConnectorSoap">
              <security mode="Transport"  >
                <transport clientCredentialType="Ntlm" realm="" />
                <message clientCredentialType="UserName"  />
              </security>
            </binding>

        </basicHttpsBinding>
    </bindings>
    <client>
        <endpoint address="https://ota.externalservice.nl/ourservices/getconnector.asmx"
            binding="basicHttpsBinding" bindingConfiguration="GetConnectorSoap"
            contract="ExtConn.GetConnectorSoap" name="GetConnectorSoap" />
    </client>
</system.serviceModel>
</configuration>

责任在于:

  

HTTP请求未经授权使用客户端身份验证方案'Ntlm'。从服务器收到的身份验证标头是“Negotiate,Kerberos,NTLM”。

我的问题是:我们做错了什么?如果接受NTLM作为身份验证模式,为什么我们会收到此错误?

1 个答案:

答案 0 :(得分:0)

您可以尝试将其添加为网络参考(添加服务参考&gt;高级..&gt;添加网络参考)

GetConnector connector = new GetConnector();
connector.Credentials = new NetworkCredential("username", "password", "domain");
string response = connector.GetData();