【发布时间】: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