Answered by:
"The request failed with HTTP status 401: Unauthorized." WCF

Question
-
Hi
I create a classic silverlight application (sampleSMS )
Add a wcf service Service1.svc (Silverlight-enabled WCF service) to the ASP.NET project(sampleSMS.Web )
This wcf service contains a web reference that allow to send sms in my cie.
(http://ilapp3/newsmsmessaging/smsmessage.asmx)
In the Silverlight application (sampleSMS ) I add Service1.svc as a service reference.
When the reference is as following all is working perfect
http://localhost:4525/Service1.svc
(my Web site is then configured as Use Visual Studio Development Server )
But when I reference it as following
http://laptop123/sampleSMS .Web /Service1.svc
(my Web site is then configured as Use Local IIS Web Server )
I also allow Anonymous access and enable Integrated Windows Authentication
I obtain this error
"The request failed with HTTP status 401: Unauthorized."
Any suggestions will be very appreciate....
FredTuesday, April 21, 2009 1:43 AM
Answers
-
Please check two things:
1.access http://laptop123/clientaccesspolicy.xml from your browser, if you can't get the xml, it means that clientaccesspolicy.xml is not in the right place.
2.set breakpoint at this line
client = new Service1Client(binding, address);
get the address uri string, and access from your browser, if return 404 error, then the address uri is not correct.
Monday, April 27, 2009 4:46 AM
All replies
-
You need a clientaccess policy file at the root of http://laptop123 so that you can access it on http://laptop123/clientaccesspolicy.xml.
Read this thread.
http://silverlight.net/forums/t/19021.aspx
Tuesday, April 21, 2009 2:18 AM -
Thanks a lot for your prompt response.
I try what you said and the thread but the problem persists.
I copy file clientaccesspolicy.xml on my web root D:\sts\caBuild\caBuild.Web
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>I modify my code as following
ServiceReference1.Service1Client client;
System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(new Uri(Application.Current.Host.Source, "../Service1.svc"));
client = new Service1Client(binding, address);or
Uri address = new Uri(Application.Current.Host.Source, "../Service1.svc");
client = new Service1Client("BasicHttpBinding_Service1", address.AbsoluteUri);
without success
any idea ?
Regards
Fred
Tuesday, April 21, 2009 7:13 AM -
Please check two things:
1.access http://laptop123/clientaccesspolicy.xml from your browser, if you can't get the xml, it means that clientaccesspolicy.xml is not in the right place.
2.set breakpoint at this line
client = new Service1Client(binding, address);
get the address uri string, and access from your browser, if return 404 error, then the address uri is not correct.
Monday, April 27, 2009 4:46 AM