【问题标题】:Client authentication scheme 'Negotiate' - The authentication header received from the server was 'Basic realm=\“EJBWebServiceEndpointServlet Realm\”'客户端身份验证方案 'Negotiate' - 从服务器收到的身份验证标头是 'Basic realm=\“EJBWebServiceEndpointServlet Realm\”'
【发布时间】:2015-02-19 09:43:26
【问题描述】:

以下 SOAP 操作采用搜索参数并返回搜索结果对象:

public static void SearchWebServiceClient()
{
    SearchWebServiceClient client = new SearchWebServiceClient(); // Creates client

    client.ClientCredentials.UserName.UserName = "someUsername"; // Assigns client credentials
    client.ClientCredentials.UserName.Password = "somePassword";

    client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

    searchForComponents componentSearch = new searchForComponents(); // Creates operation
    searchForComponentsResponse componentSearchResponse = new searchForComponentsResponse(); // Creates operation response

    componentSearch.searchTerm = "someSearchTerm"; // The parameter being passed to the operation

    componentSearchResponse = client.searchForComponents(componentSearch); // Sends request. Exception happens here.
}

发出请求时,会导致此异常:

$exception {"HTTP 请求未经客户端授权 身份验证方案“协商”。收到的认证头 从服务器是 'Basic realm=\"EJBWebServiceEndpointServlet 领域\"'."} System.Exception {System.ServiceModel.Security.MessageSecurityException}

App.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
  </startup>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="SearchWebServiceBinding"
                 closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
            <message clientCredentialType="UserName" algorithmSuite="Default"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://someaddress.com:80/somedirectory/somedirectory/search-service?wsdl"
          binding="basicHttpBinding" bindingConfiguration="SearchWebServiceBinding"
          contract="SearchWebService.SearchWebService" name="Search" />
    </client>
  </system.serviceModel>
</configuration>

服务器托管在我的网络外部,我无法查看/编辑其配置。

有谁知道这可能是什么原因造成的?提前致谢!

【问题讨论】:

    标签: c# authentication soap jboss


    【解决方案1】:

    问题出在这一行:

    <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
    

    您想要进行 Windows 身份验证,即协商。尝试将其更改为:

    <transport clientCredentialType="Basic" proxyCredentialType="None" realm=""/>
    

    【讨论】:

    • 感谢您的回复。我进行了调整,结果却导致了这个异常:$exception {"HTTP 请求未经客户端身份验证方案'匿名'的授权。从服务器接收的身份验证标头是'Basic realm=\"EJBWebServiceEndpointServlet Realm\" '."} System.Exception {System.ServiceModel.Security.MessageSecurityException}
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-02
    • 1970-01-01
    • 2013-03-12
    相关资源
    最近更新 更多