Folks,
I have an asmx web sevice being hotes in IIS 7 with only basic authentication enabled.
I am trying to test the basic authentication on my local machine before dealing with the SSL.
When testing using the following code…
[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));
}
.. I receive the following error:
The HTTP request is unauthorized with
client authentication scheme ‘Basic’.
The authentication header received
from the server was ‘Basic
realm=”localhost”‘.innerexception: The remote server
returned an error: (401) Unauthorized.
Here is my 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>
Can anyone spot my problem?
Please refer to following link. This might help you.
http://ozkary.blogspot.in/2011/05/http-request-is-unauthorized-with.html