Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Silverlight beta 2 WCF service 404 error
14 replies. Latest Post by sladapter on June 19, 2008.
(0)
geimas5
Member
60 points
30 Posts
06-17-2008 3:44 PM |
when I try to call a WCF service from my Silverlight application I get a 404 error. when I use "Web development helper" to view the request I see that it doesn't even hit the service, only the Clientaccesspolicy.xml file, and I see that the actual content of the file is returned through the response body. Any thoughts? Details: The service is hosted on a different machine, a windows 2003 server on the local network.I have no problem calling a asmx service on the same computer, in the same directory(same project actually).The Silverlight application is hosted in a web application on local IIS in http://localhost/AdministrationToolsWebI attempt to access the remote service using hostname(not ip): http://virwinserv01/...%5bPath%20here%5d.../IIsMan.svcFor my service i used the Silverlight WCF template.I have no problem accessing the web service in the browser.I have the same problem calling the authentication service after I have followed the instructions in this video: http://silverlight.net/learn/learnvideo.aspx?video=56228 My clientaccesspolicy.xml file:<?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> Exception details: System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (404) Not Found. at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result) at AdministrationTools.AuthenticationService.AuthenticationServiceClient.AuthenticationServiceClientChannel.EndLogin(IAsyncResult result) at AdministrationTools.AuthenticationService.AuthenticationServiceClient.AdministrationTools.AuthenticationService.AuthenticationService.EndLogin(IAsyncResult result) at AdministrationTools.AuthenticationService.AuthenticationServiceClient.OnEndLogin(IAsyncResult result) at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}
when I try to call a WCF service from my Silverlight application I get a 404 error. when I use "Web development helper" to view the request I see that it doesn't even hit the service, only the Clientaccesspolicy.xml file, and I see that the actual content of the file is returned through the response body.
Any thoughts?
Details:
The service is hosted on a different machine, a windows 2003 server on the local network.I have no problem calling a asmx service on the same computer, in the same directory(same project actually).The Silverlight application is hosted in a web application on local IIS in http://localhost/AdministrationToolsWebI attempt to access the remote service using hostname(not ip): http://virwinserv01/...%5bPath%20here%5d.../IIsMan.svcFor my service i used the Silverlight WCF template.I have no problem accessing the web service in the browser.I have the same problem calling the authentication service after I have followed the instructions in this video: http://silverlight.net/learn/learnvideo.aspx?video=56228
My clientaccesspolicy.xml file:<?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>
Exception details:
System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (404) Not Found. at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result) at AdministrationTools.AuthenticationService.AuthenticationServiceClient.AuthenticationServiceClientChannel.EndLogin(IAsyncResult result) at AdministrationTools.AuthenticationService.AuthenticationServiceClient.AdministrationTools.AuthenticationService.AuthenticationService.EndLogin(IAsyncResult result) at AdministrationTools.AuthenticationService.AuthenticationServiceClient.OnEndLogin(IAsyncResult result) at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}
06-17-2008 10:55 PM |
No one?
bartczer...
Contributor
4172 points
730 Posts
06-17-2008 11:50 PM |
If you are returning large amounts of data you need to set the appropriate settings inside your web.config for bindings:
<
</
...
Also make sure your ServiceReferences.config in the Silverlight project needs the appropriate buffer settings:
06-18-2008 12:13 AM |
the asmx version that returns pretty much the same data returns about 1000 bytes, so the size shouldn't be a problem.
doolittle
74 points
26 Posts
06-18-2008 9:37 AM |
Where is your WCF-service hosted?
Because it is very important that clientaccesspolicy.xml is in the root of your web-sit.
So for instance http://localhost/clientaccesspolicy.xml or http://virwinserv01/clientaccesspolicy.xml.
The tool 'fiddler' has helped me a lot to find the solution of such problems, maybe you should try finding the cause with that tool...
O, and do you have a crossdomain.xml? Because you need that aswell...
Hope you can find the solution.
06-18-2008 9:47 AM |
yes its hosted and is available at the root of the site with http://virwinserv01/clientaccesspolicy.xml.
No i do not have s crossdomain-xml, you do not need both. looking at the logs it dose not ask for one either.
WJamesLord
138 points
118 Posts
06-18-2008 1:23 PM |
Oddly, I've seen a 404 error returned if there is a bug in the web service.
sladapter
All-Star
17441 points
3,172 Posts
06-18-2008 1:38 PM |
Most 404 errors people have seen in beta 2 so far are related to the cross-domain issue. Some of them are related to data size issue (also a configuration change).
People have all different ways to host and call their web service. So there is no single solution to solve them all. Do a search on 404 error (after beta2 release date) you might find serveral threads people have discussed this issue. Most people found their solution at the end.
johnpapa
8 points
9 Posts
06-18-2008 3:09 PM |
When you say "when I use "Web development helper" to view the request I see that it doesn't even hit the service, only the Clientaccesspolicy.xml file," is WebDevHelper showing you the exact location of where it looks for the ClientAccessPolicy.xml file? Is that line yielding the 404? Make sure the file is in the location it is looking for it. It needs to be in the web root and not the web app root.
06-18-2008 7:52 PM |
johnpapa: When you say "when I use "Web development helper" to view the request I see that it doesn't even hit the service, only the Clientaccesspolicy.xml file," is WebDevHelper showing you the exact location of where it looks for the ClientAccessPolicy.xml file? Is that line yielding the 404? Make sure the file is in the location it is looking for it. It needs to be in the web root and not the web app root.
Yes using Web development helper, I see the exact location that it looks for the clientaccesspolicy.xml file. it returns a 200 and when I look at the response body I see the correct content(as pasted in my initial post). so this is not a custom error message issues. yes the clientaccesspolicy.xml file is located at my webroot: http://virwinserrv01/clientaccesspolicy.xml.
When I say that it doesn't hit the service i mean that it does not even try. after the clientaccesspolicy.xml file is returned from the server, not a single request is sendt from the Silverlight application.
@sladaper:I always google and experiment for hours before I try asking (finding the answer on my own is the best way to learn in my opinion). I only ask when I'm stuck and are not getting anywhere on my own. so yeah, I have already gone through all the posts on this forum (and many other sites I found googling) but to no avail.
@WJamesLord:Its quite possible that there is a bug somewhere, but I have tried using the video with the built-in authentication service with no luck. so I think the "bug" is a config issue. I was kind of expecting it to be something really easy that someone would quickly point out. I will post some related web.config, etc. in a few hours, maybe there is something there that I have missed.
06-18-2008 8:47 PM |
Geimas5,
Was this working in beta 1? Could you check the URL for your service endpoint on your ServiceReference.ClientConfig and what is it? Since this is WCF service, what binding you set on the Web.config on your Service Site?
06-18-2008 11:28 PM |
sladapter: Geimas5, Was this working in beta 1? Could you check the URL for your service endpoint on your ServiceReference.ClientConfig and what is it? Since this is WCF service, what binding you set on the Web.config on your Service Site?
This is a new beta 2 project.
Endpoint in ServiceReference.ClientConfig:
<endpoint address="http://virwinserv01/AdministrativeToolsService/AuthenticationService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_AuthenticationService" contract="AdministrationTools.AuthenticationService.AuthenticationService" name="BasicHttpBinding_AuthenticationService" />
Binding in web.config:
<basicHttpBinding> <binding name="userHttp"> <!-- this is for demo only. Https/Transport security is recommended --> <security mode="None"/> </binding> </basicHttpBinding>
Service in web.config: <!-- this enables the WCF AuthenticationService endpoint --> <service name="System.Web.ApplicationServices.AuthenticationService" behaviorConfiguration="AuthenticationServiceTypeBehaviors"> <endpoint contract="System.Web.ApplicationServices.AuthenticationService" binding="basicHttpBinding" bindingConfiguration="userHttp" bindingNamespace="http://asp.net/ApplicationServices/v200"/> </service>
And yes, i do have this part aswell:
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> </system.serviceModel> <system.web.extensions> <scripting> <webServices> <authenticationService enabled="true" requireSSL="false"/> </webServices> </scripting> </system.web.extensions>
the other wcf services im trying to set up is configured in about the same way.
06-18-2008 11:36 PM |
I would test to see if you can reference this WCF service from a standard WinForm client jsut as a test to see if its the service or the communicaiton with Silverlight that is off.
SteveWong
6343 points
1,281 Posts
06-19-2008 3:27 AM |
geimas5: This is a new beta 2 project. Endpoint in ServiceReference.ClientConfig: <endpoint address="http://virwinserv01/AdministrativeToolsService/AuthenticationService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_AuthenticationService" contract="AdministrationTools.AuthenticationService.AuthenticationService" name="BasicHttpBinding_AuthenticationService" /> Binding in web.config: <basicHttpBinding> <binding name="userHttp"> <!-- this is for demo only. Https/Transport security is recommended --> <security mode="None"/> </binding> </basicHttpBinding> Service in web.config: <!-- this enables the WCF AuthenticationService endpoint --> <service name="System.Web.ApplicationServices.AuthenticationService" behaviorConfiguration="AuthenticationServiceTypeBehaviors"> <endpoint contract="System.Web.ApplicationServices.AuthenticationService" binding="basicHttpBinding" bindingConfiguration="userHttp" bindingNamespace="http://asp.net/ApplicationServices/v200"/> </service> the other wcf services im trying to set up is configured in about the same way.
I think your ServiceReference.clientconfig should be like this
<configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_AuthenticationService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <security mode="None" /> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://virwinserv01/AdministrativeToolsService/AuthenticationService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_AuthenticationService" contract="AdministrationTools.AuthenticationService.AuthenticationService" name="BasicHttpBinding_AuthenticationService" /> </client> </system.serviceModel></configuration>
For your Service should also be like this
<basicHttpBinding> <binding name="userHttp" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> <security mode="None"/> </binding> </basicHttpBinding>
Try if it works, but I wonder there should be some problem of the service contract there
06-19-2008 9:47 AM |
geimas5,
The configuration file looks all right. And you said you already put the new clientaccesspolicy.xml file on your virwinserv01 server under inetput\wwwroot folder. I can't think of anything else.
Do you have a large data to send back on your service call? If not, the buffer size setting change in the binding won't help you. If you do send a relatively large data ( say size is > 18KB or string length > 8200 chars), then you need change the buffer size.
If you do need change the buffer size use WCF service configuration editor (under tools) to do these changes. Here is the steps for doing that just in case you want to try it.
Open the web.config of your Service Web using WCF Service Configuration Editor: