【发布时间】:2011-09-21 07:50:26
【问题描述】:
伙计们,
我有一个 asmx 网络服务,它是 IIS 7 中的热点,只启用了基本身份验证。
在处理 SSL 之前,我正在尝试在本地计算机上测试基本身份验证。
使用以下代码进行测试时...
[TestMethod]
public void TestMethod1()
{
MyCompanyExternalService.CClaim claim = new MyCompanyExternalService.CClaim();
claim.Airline = "AA";
claim.OrigCty = "MCO";
claim.PaxFN = "John";
claim.PaxLN = "Smith";
claim.FileRef = "DL123321";
claim.OrigDate = Convert.ToDateTime("1/1/2001");
claim.ClaimFor = MyCompanyExternalService.EReasonsForClaim.Pilferage;
claim.AirlineClaimStatus = "Open";
MyCompanyExternalService.wsMyCompanyImportSoapClient MyCompanyImportSoapClient
= new MyCompanyExternalService.wsMyCompanyImportSoapClient("wsMyCompanyImportSoap");
MyCompanyImportSoapClient.ClientCredentials.UserName.UserName = "My-PC\\chron";
MyCompanyImportSoapClient.ClientCredentials.UserName.Password = "********";
Assert.IsTrue(MyCompanyImportSoapClient.SubmitClaim(claim));
}
.. 我收到以下错误:
HTTP 请求未经授权 客户端身份验证方案“基本”。 收到的认证头 从服务器是'基本 领域=“本地主机”'。
innerexception:远程服务器 返回错误:(401) Unauthorized.
这是我的 app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="wsMyCompanyImportSoap" 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="Basic" realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/MyCompany/MyCompanyWebServiceApp/wsMyCompanyImport.asmx"
binding="basicHttpBinding" bindingConfiguration="wsMyCompanyImportSoap"
contract="MyCompanyExternalService.wsMyCompanyImportSoap"
name="wsMyCompanyImportSoap" />
</client>
</system.serviceModel>
</configuration>
谁能发现我的问题?
【问题讨论】:
标签: asp.net web-services basic-authentication