×

First time here?

You are looking at the most recent posts. You may also want to check out older archives. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS or email. Thank you for visiting!

I’ve been getting a few notes on issues relating to people trying Silverlight beta 2 and WCF or other services.  The most common issue I’m seeing reported is “my exception is showing a 404-not found error message, but the service is there and works!”

Okay, there could be several things happening here, but let’s tackle the “make sure it is plugged in” type situations.  I don’t mean to make light of the error, because at first I, too, was banging my head against a wall.  Sometimes it helps to have a second set of eyes or a deeper understanding of the issue…or both.

First, the situation.  Most of the time you’ll see this exception when your Silverlight application is accessing a service not hosted on the same application domain.  This is considered cross-domain access and requires the service host to enable an opt-in policy file so rich client platforms are allowed to access the service.  In Silverlight we call that the clientaccesspolicy.xml file.  You can learn all about cross-domain policy files by viewing this video on the Silverlight community site (a great resource).  In beta 2, there was a subtle change to the policy file that is required.  I wrote about that here as well (and note the code download for the video has the updated policy file).

Ok, so under what conditions might you get the “(404) Not found” error message when accessing services?

No policy file at all

Silverlight will first check for clientaccesspolicy.xml first and then fallback and see if a supported crossdomain.xml file exists.  If neither exists at all, 404 baby.  Also remember Silverlight is looking for this file in the root of the requesting domain.  So if you have a file but it is in your app root…this could be the issue at all.

Incorrect, mail-formed, just plain wrong policy file

Silverlight will check for a clientaccesspolicy.xml file and if it finds one but it has an incorrect format or is mal-formed it will treat it as invalid and then look for crossdomain.xml…and if not found, boom: 404.  This is what most are running into in starting to use beta 2 with your policy files.  The missing http-request-headers attribute renders the file mal-formed.

HTML response

Most sites have custom error messages for page not found.  For example, when you visit google.com/timheuer you’ll get a less-than-helpful message, but custom nonetheless or as another example microsoft.com/timheuer you’ll get another custom response with a sitemap.  Both of these are essentially custom error messages that are returning valid HTML, but not a valid policy file.  In these instances, Silverlight sees the response, but sees it as invalid/mal-formed and treats it like it didn’t exist: 404.

These are the most common instances where a 404 would be generated and making you bang your head against the closest semi-hard surface.  How can you figure out what is going on?  Well first, make sure you do your best to ensure you meet all the requirements.  But also use some development helper tools.

Web Development Helper

For me, in service/remote/AJAX development there is a single indispensable tool that I can’t live without.  That is NikhilK’s Web Development Helper.  This tool is a plugin to Internet Explorer (yes I know there are others similar in nature for Firefox, etc. – but I LOVE this implementation and IE is fine by me) that provides in the browser HTTP-traffic sniffing.  No need for any funky port configuration or changing proxy server settings, etc.  Just enable it and it works.  I highly recommend you use this tool or something similar like it (Fiddler is another good one although requires some additional config steps usually when working with Visual Studio’s web development server).

Seriously, a tool like this will save you so much time in troubleshooting your service interactions with Silverlight, Flash, AJAX, whatever – it will help you immediately figure out where to start looking rather than grabbing your climbing gear and spelunking in unknown caverns.

So why a ‘404’ – what gives?

I’ve also heard people say “you need to make that exception be more descriptive, 404 is not accurate.”  I’m on the fence on this one.  As a .NET developer I can see where the concerns are coming from in having the most descriptive exception possible.  But one must realize what is happening under the hood.  The polciy file is being requested as a GET request, so basically an HttpWebRequest object is our object here.  Because of this, we return HTTP-specific errors.  There isn’t one for “Silverlight policy file found, but not correct” in the HTTP spec right now.  So because of this, we use a RESTful approach in providing a standard HTTP response.  In our case “404-not found” seems to be a valid response – indicating “The request for a valid policy file resulted in a valid policy file not being found.”  We make no distinction between partially valid or finding a specific typo, etc. – we simply indicate that a valid policy wasn’t found.  One could argue 406,409 or 417 might be other responses, but I’m not sure that would make anyone feel any better – we’re still going to use an HTTP response code.

Hope this helps!


This work is licensed under a Creative Commons Attribution By license.


6/18/2008 7:05 AM | # re: Silverlight cross domain services and a helpful tool
Hi Tim,

I'm getting a 404 error since beta 2 (in beta 1 everything worked perfect). I tried a HTTP sniffing tool (Firebug in Firfox) as you recommended. But in this trace is something I do not understand. The first http request is for the xap file, which returns with 200. The next request then is for the http://soap.amazon.com/clientaccesspolicy.xml (I'm using the Amazon Webservice) which returns 404 because it is not there. Now I do expect another request for crossdomain.xml (which exists for the Amazon Webservice), but the application throws the 404 exception before looking for this file!
6/18/2008 10:39 AM | # re: Silverlight cross domain services and a helpful tool
@Michael: adobe has recently changed their format as well which might be causing some of the issues -- they've implemented similar header changes in the crossdomain.xml file that we understand in SL2, but some sites have not implemented yet.
6/23/2008 1:23 PM | # re: Silverlight cross domain services and a helpful tool
Nice post. I am having a 404 issue, and was able to see exactly where/why it was messing up with "Web Development Helper".

Unfortunately I still can't figure out how to fix it.

My service is located at on my local intranet server at "http://ssisvr/ElmerService/ElmerService.asmx" Navigating to this URL shows the service and everything works fine.

My Silverlight project has a service reference with the endpoint address properly set to the service:

<endpoint address="http://ssisvr/ElmerService/ElmerService.asmx" ...

When I run the project out of the debugger, everything works fine - no 404, beautiful.

When I publish the application to the server however (http://ssisvr/Elmer/), things mess up. The page and silverlight app loads fine, but when I push the button to invoke the service I see this behavior in Web Development Helper:

..... <multiple status 200 requests from http://ssisvr/Elmer/...>
http://ssisvr/elmer/ClientBin/ElmerFudd.xap - 200

At this point the silverlight aplication is up and running just fine, then I hit the button to invoke the service:

http://localhost/clientaccesspolicy.xml - 404
http://localhost/crossdomain.xml - 404

I have no clue why the silverlight application is looking at "localhost" for these files. The words "localhost" do not even appear in either of my projects, anywhere - including in hidden text. I have also tried manually setting the endpoint for the service:

BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress ep = new EndpointAddress("http://ssisvr/ElmerService/ElmerService.asmx");
//client = new ElmerServiceSoapClient("ElmerServiceSoap");
client = new ElmerServiceSoapClient(binding, ep);

Yet invoking the service function still checks "localhost" for those files, and of course returns a 404.

It is driving me insane! Any ideas?



6/24/2008 10:49 AM | # re: Silverlight cross domain services and a helpful tool
I think it would make more sense to throw a silverlight specific exception and place the 404 in the inner exception.

Since the 404 is not in response to the resource that is being requested.

6/24/2008 12:11 PM | # re: Silverlight cross domain services and a helpful tool
@brian: in this regard we are limited to the information provided by the browser's networking stack. we don't get a ton of information. for example that is why SOAP faults return a 404 instead of a 500 or more-specific information -- we simply aren't getting detail from the browser stack.
7/25/2008 10:56 AM | # re: Silverlight cross domain services and a helpful tool
Watching the http traffic was helpful, but still not sure what my problem is. The silverlight app works fine querying the service from IE, I see the accesses to the clientaccesspolicy.xml file. However when i run the same silverlight app from the same URL as IE, I get the 404 error. The http sniffing doesn't show any attempt to access the clientaccesspolicy.xml, it stops after getting the xap.
7/25/2008 12:03 PM | # re: Silverlight cross domain services and a helpful tool
Jody: if you can send me a repro i can help troubleshoot.
7/29/2008 1:37 AM | # re: Silverlight cross domain services and a helpful tool
Your video and suggestions are clear and helpful. Thanks. Now I can run a WCF service from a Silverlight/WPF app using the VS Development Server.

However, it looks like I encoutered an issue in IIS 5.1 with Win XP. I created a new solution, in VS2008 + Silverlight Beta 2, used IIS option in the WCF service project's properties>Web tab, and pressed the Create Virtual Directory button. Then in a client, say WPF or Silverlight client, I did a Add Service Reference. In the Address field, I pressed the Discover button, the Address field showed http://localhost/WcfServcie1/Service1.svc (instead of http://localhost:9033/Service1.svc). Once I click on the service, the error is:

There was an error downloading 'http://localhost/WcfService1/Service1.svc'.
Metadata contains a reference that cannot be resolved: 'http://localhost/WcfService1/Service1.svc'.
The requested service, 'http://localhost/WcfService1/Service1.svc' could not be activated. See the server's diagnostic trace logs for more information.
If the service is defined in the current solution, try building the solution and adding the service reference again.


So I tried the IE browser by typing http://localhost/WcfService1/Service1.svc, it displayed Server Error in /WcfService1 Application with the error below:

Server Error in '/WcfService1' Application.

Exception Details: System.InvalidOperationException: Service 'WcfService1.Service1' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

...

Stack Trace:
[InvalidOperationException: Service 'WcfService1.Service1' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.]
System.ServiceModel.Description.DispatcherBuilder.EnsureThereAreNonMexEndpoints(ServiceDescription description) +259
System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +64
System.ServiceModel.ServiceHostBase.InitializeRuntime() +37
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +63
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +268
System.ServiceModel.Channels.CommunicationObject.Open() +30
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +104
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +498

I suspected it may be my IIS setup. So I ran "ServiceModelreg.exe /lv",
it shows my System.serviceModel is 3.0.0.0, same for system.servicemodel.activation and system.runtime.serialization, system.web etc. Do I need to see 3.5 in ServiceModelreg? Or some extra settings in the IIS virtual directory? Your pointer is very much appreciated. Thanks for reading.
7/30/2008 9:04 PM | # re: Silverlight cross domain services and a helpful tool
Thanks for reading my last long description. This has nothing to do with the policy file. I finally fixed the problem. I don't know the exact cause. I un-installed Silverlight Tool Beta 2, re-installed IIS, install the Silverlight Tool again, then somehow I added the .svc in the Application Mappings of IIS to point to aspnet_isapi.dll, then even did aspnet_iisreg.exe -i. Afterall, I think there could be due to a potential setup issue with the ASP.NET 2.0 setting in IIS in my SOE laptop.
8/8/2008 1:04 PM | # re: Silverlight cross domain services and a helpful tool
Hi,
I also have cross domain access problem. I found same problem on the forum http://silverlight.net/forums/p/16839/57457.aspx. Answer contains good example. But example does not work :(.
I ran this example and see in the Web Developer Helper:
http://localhost:50467/TestCalculatorWeb/TestCalculatorTestPage.html - status 200
http://localhost:50467/TestCalculatorWeb/ClientBin/TestCalculator.xap - status 200
http://localhost:7999/clientaccesspolicy.xml - status 200

But VS debugger returns "The remote server returned an unexpected response: (404) Not Found."
I enabled WCF server debugging. And looked logs of service. It does not contain any requests except clientaccesspolicy.xml

Can you help?
9/20/2008 7:17 AM | # re: Silverlight cross domain services and a helpful tool
Can you see http traffic with Web Development Helper using WFC?
9/20/2008 7:32 AM | # re: Silverlight cross domain services and a helpful tool
Tom: If by WFC you mean WCF-windows communication foundation, then yes.
10/16/2008 1:02 PM | # re: Silverlight cross domain services and a helpful tool
I had a Silverlight app consuming a webservice in beta 2 on windows 2003 that worked just fine (and still works fine when running in beta 2). When I upgraded to the release of Silverlight 2 (running on XP professional) the call to the service stopped working, the error was "The remote server returned an error: NotFound". I can see my webservice being called on the server, and Web Developer Helper shows that the response code is 200 and the response contains the data I expect. However, as I said, I still get the server not found error in Silverlight.

Any ideas on what might be the root of the problem. Could it be xp vs 2003, ie6 vs ie7, something different in the latest version of Silverlight.

Thanks,

Dave
10/25/2008 5:59 AM | # re: Silverlight cross domain services and a helpful tool
Hi Tim,

Like Dave in the previous comment I'm experiencing the exact same problem with a personal project.
I have a SL enabled WCF service with 4 methods in them. With 1 method I keep getting the "The remote server returned an error: NotFound" message. I totally stripped the service renamed it, created a new WCF service with the same methods, added a clientaccespolicy.xml file but nothing helped.
I used Nikhils toolbar to log the http requests, but it looks like the request never leaves the browser. At least it doesn't show up in the toolbar probably because SL crashes before it can update.
I haven't been able to solve it yet (been working on it for a number of hours already...).

If you want to, I can send you my project with a description of how to reproduce the error. Just drop me a message if you need it.

Rob
11/11/2008 10:55 AM | # Please Help: Silverlight cross domain services and a helpful tool
Hi,

I have been reading this very closely and really appreciate the effort on this important topic.

With Silverlight 2.0, I am trying to access a WCF Service hosted as a Console App. The error thrown at the Silverlight project(inside the generated proxy) clearly states that I might be missing the clientaccesspolicy.xml.

As soon as I launch the Silverlight website, I see that VS Development server kicks in (like http://localhost:8989). And I am hosting WCF on say http://localhost:9876.

Can guys please let me know what to do in this development scenario?

Where to place the cdomain policy file.

Thanks





11/11/2008 2:53 PM | # re: Silverlight cross domain services and a helpful tool
11/13/2008 6:18 AM | # re: Silverlight cross domain services and a helpful tool
When we tried to call a webservice from silverlight 2.0, we are getting the following error

The remote server returned an error: NotFound

System.Net.WebException: The remote server returned an error: NotFound ---> System.Net.WebException: The remote server returned an error: NotFound

at System.Net.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)

at System.Net.BrowserHttpWebRequest.<>c__DisplayClass5.b__4(Object sendState)

at System.Net.AsyncHelper.<>c__DisplayClass2.b__0(Object sendState)

--- End of inner exception stack trace ---

at System.Net.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)

at System.Net.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)

Thanks

11/13/2008 8:11 AM | # re: Silverlight cross domain services and a helpful tool
Rakesh: have you looked at the traffic to see what is failing and any particular errors in the response content?
11/17/2008 3:32 AM | # re: Silverlight cross domain services and a helpful tool
Hi timheuer,
We tried with Web development helper tool and the status shown in 200 and the response content contains result from XML also. This error is coming only in one or two systems and only in IE. FireFox it is working fine.

Thanks

11/17/2008 5:46 AM | # re: Silverlight cross domain services and a helpful tool
Rakesh: Is this a service that I could look at? Also are the problematic machines IE6?
11/17/2008 9:30 PM | # re: Silverlight cross domain services and a helpful tool
Hi timheuer,

Sorry we cannot give the link without client's permission.
we are getting this in 2 machines. one use IE6(in XP) and other one IE7(in Vista).This error comming only in client's server not in our server an localhost.

Thanks
11/18/2008 2:17 AM | # re: Silverlight cross domain services and a helpful tool
Rakesh: it will be hard for me to be definitive without being able to troubleshoot unfortunately.
12/19/2008 5:34 AM | # re: Silverlight cross domain services and a helpful tool
hi tim, actually i am not able to get teh data from wcf service in silverlight 2, i have debug with firebug and i am getting the error 500 on accessing the service like http://localhost/LeaveBusinessLayer/service.svc, the page is getting clientproxy file properly, problem is occuring in next step when it tries to access the service, service is working well for other non silverlight pages(asp.net).
my clientproxy file is this:













and by this code i am accessing it :
public Page()
{

InitializeComponent();
svc.GetQuartersCompleted += new EventHandler(svc_GetQuartersCompleted);
svc.GetQuartersAsync();
}


web.config desc:





maxReceivedMessageSize="2147483647">





http://localhost/LeaveBusinessLayer/Service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="BusinessLayer.IService" name="BasicHttpBinding_IService" />


12/19/2008 5:49 AM | # getting 500 response on valid wcf service
hi tim, actually i am not able to get teh data from wcf service in silverlight 2, i have debug with firebug and i am getting the error 500 on accessing the service like http://localhost/LeaveBusinessLayer/service.svc, the page is getting clientproxy file properly, problem is occuring in next step when it tries to access the service, service is working well for other non silverlight pages(asp.net).
my clientproxy file is this:
"










"
and by this code i am accessing it :
public Page()
{

InitializeComponent();
svc.GetQuartersCompleted += new EventHandler(svc_GetQuartersCompleted);
svc.GetQuartersAsync();
}


web.config desc:


maxReceivedMessageSize="2147483647">
http://localhost/LeaveBusinessLayer/Service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="BusinessLayer.IService" name="BasicHttpBinding_IService" />
12/19/2008 7:24 AM | # re: Silverlight cross domain services and a helpful tool
Saif: if you are getting a 500 error, then something is occuring on the server. Examine the response data and see what the error is...it is something in the service that is erroring out.
1/11/2009 9:00 AM | # re: Silverlight cross domain services and a helpful tool
Saif,

I had same problem. In my case, it was my dbml file and his property "Serialisation mode" in fault. I just put it on "Unidirectional" value, and it works. My wcf service method return a list of customer and customer type was defined in dbml file.
1/25/2009 5:56 AM | # re: Silverlight cross domain services and a helpful tool

Tim, Hello
I have tried to have both the crossdomain.xml and client file. and i an still getting the File NotFound error. i am actually using you Adventure Work Silverlight app.

please help if you can!
1/25/2009 10:03 AM | # re: Silverlight cross domain services and a helpful tool
Paa when you look at the traffic, what does it show you? When you launch the application, what is the URL in the address bar? does it start with HTTP?
4/21/2009 8:24 AM | # re: Silverlight cross domain services and a helpful tool
This is my physical structure:

Server Test

C:
IntePub
wwwroot
Services
User (Folder)

Usuario.svc
+ Project files

Person (Folder)

Pessoa.svc
+ Project files

Phone (Folder)

Telefone.svc
+ Project files

DataAccess

Silverlight Application
+ Archives ....


In IIS the structure is as follows:


Computer
Web Sites
Default Web Site (using SSL) - Pointing to wwwroot
Services (using SSL) - Pointing to the services folder
DataAccess (using SSL) - Pointing to the folder DataAccess


Steps

I published the services from my development station to a Test Server. The machines are in the same network.

The addresses to access the services

https://External IP/Services/Usuario/Usuario.svc
https://External IP/Services/Perfil/Perfil.svc
https://External IP/Services/Direito/Direito.svc
External IP/Services/GrupoDireito/GrupoDireito.svc
https://External IP/Services/Pessoa/Pessoa.svc
https://External IP/Services/Telefone/Telefone.svc

After I developed a Silverlight Application and make a service reference for each service mentioned above. Everything working at now.

Then I published the silverlight application in the same server, in another virual directory


https://External IP/DataAccess


I put the clientaccesspolicy.xml in wwwroot.

I opened the browser and tried to access the https://External IP/DataAccess and when the application try to execute the method of the service. The follow error appear:

The remote server returned an error: Not found

Here is the clientaccesspolicy files that I tried to use:

<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="http://*" />
<domain uri="https://*" />
</allow-from>
<grant-to>
<resource include-subpaths="true" path="/Services/"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>


<?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 include-subpaths="true" path="/"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>

Did you see something wrong in the configurations? The folder that I copied the file is correct in this case? There is some different procedure because of the https? Please, help me! I don't know if this will help, but I'm using Silverlight 3, because I need of the mode TransportWithMessageCredential that don't exists in Silverlight 2.


4/21/2009 7:30 PM | # re: Silverlight cross domain services and a helpful tool
Rodrigo, it is likely because your references are still toward your other endpoint. Look at the traffic to see where it is requesting and what the actual responses are.
6/19/2009 12:46 PM | # re: Silverlight cross domain services and a helpful tool
hey tim.. gr8 video.. i've never worked with web services before, i'm using it for the first time to create a mail service, using a silverlight form control to type in. All the service files are in the same directory, and i've also placed the said xml file at the root of my website, but i am unable to get thru to smtp.gmail.com, however wen i use the webservice by itself, i recieve a message in the inbox, wat could have possibly gone wrong?

The error on debugging the SL app, is as follows:

System.ServiceModel.CommunicationException was unhandled by user code
Message="An error occurred while trying to make a request to URI 'http://localhost/Proj0.1.Web/MailService.asmx'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. Please see the inner exception for more details."
StackTrace:
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 ContactApp.MailReference.MailServiceSoapClient.MailServiceSoapClientChannel.Endsendmail(IAsyncResult result)
at ContactApp.MailReference.MailServiceSoapClient.ContactApp.MailReference.MailServiceSoap.Endsendmail(IAsyncResult result)
at ContactApp.MailReference.MailServiceSoapClient.Endsendmail(IAsyncResult result)
at ContactApp.MailReference.MailServiceSoapClient.OnEndsendmail(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
InnerException: System.Security.SecurityException
Message=""
StackTrace:
at System.Net.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
InnerException: System.Security.SecurityException
Message="Security error."
StackTrace:
at System.Net.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
at System.Net.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
InnerException:
6/19/2009 1:01 PM | # re: Silverlight cross domain services and a helpful tool
gr8auror: use a tool like fiddler to see what's going on -- best to look at the traffic itself.
6/19/2009 1:58 PM | # re: Silverlight cross domain services and a helpful tool
theres a 404 error, im using web developer helper..
6/19/2009 2:08 PM | # re: Silverlight cross domain services and a helpful tool
gr8auror -- so within the response text of the 404 error, look at what it actually says. and look at the network traffic before -- is it calling the service as you expected, etc.
6/19/2009 4:42 PM | # re: Silverlight cross domain services and a helpful tool
Hi Tim,
Great Post as all your post I've been reading.
I have exactly the same problem as Shaun so I'm copying and pasting some of his comment:
When I publish the application to the server however (http://ssisvr/Elmer/), things mess up. The page and silverlight app loads fine, but when I push the button to invoke the service I see this behavior in Web Development Helper:

..... <multiple status 200 requests from http://ssisvr/Elmer/...>
http://ssisvr/elmer/ClientBin/ElmerFudd.xap - 200

At this point the silverlight aplication is up and running just fine, then I hit the button to invoke the service:

http://localhost/clientaccesspolicy.xml - 404
http://localhost/crossdomain.xml - 404

I have no clue why the silverlight application is looking at "localhost" for these files. The words "localhost" do not even appear in either of my projects, anywhere

Help Will be appreciated
Thanks
Moctar
6/20/2009 12:11 AM | # re: Silverlight cross domain services and a helpful tool
tim, it is calling the service, the network traffic shows the same behaviour as it does in ur video, i've tried pasting a copy of ClientAccessPolicy.xml at wwwroot, and another copy at the solution root.. can't seem to debud it.. please help!!
6/22/2009 11:00 AM | # re: Silverlight cross domain services and a helpful tool
oh, it is finally working, dunno wat the problem was, but i decided to go on and add a handler from the IIS Manager for the calls made to the xml file.. i sure will put it in the root of the solution wen i dont host it on my local machine, thanks!
6/25/2009 11:30 AM | # re: Silverlight cross domain services and a helpful tool
hector -- that seems odd with a wide open policy file. perhaps try scoping your policy file to those domains to see if that works okay. Is the service hosted in SSL?
9/23/2009 5:30 PM | # re: Silverlight cross domain services and a helpful tool
Solution 404 for Silverlight with clientaccesspolicy.xml & crossdomain.xml on RemoteIntranteServer

1. Search file.xap
2. Rename file.zip
3. Extract
4. Edit ServiceReferences.ClientConfig
line
<endpoint address="RemoteIntranteServer/.../MyService.svc"

where RemoteIntranteServer is real remote server!
5. Pack file.zip
6. Rename file.xap
7. Copy to real server!

PS: WTF Microsoft!!!
I'm Sorry below comment for russian ppl/
Блять 3 ночи не спал до 5,6 утра сидел, надо было же такой дебелизм в Silverlight сделать! Когда проект публикуешь на своем компе в том числе и на IIS проблем никаких нет! Но, если вам необходимо разместить этот проект на удаленом боевом сервере, у которого нет ни FrontPage, ни возможности обратится к вам из закрытой зоны начинается веселье! Я не могу это проект из VS поместить сразу на IIS удаленого, там не работает FronPage и мне нельзя там его поднимать, помешает другим. Вот приходится сервис и Silverlight проект готовить у себя, а потом извратом вытаскивать файл с архива, чтобы пробить там хост, который нельзя пробить в самой среде VS(возникает ошибка).
11/27/2009 10:20 AM | # re: Silverlight cross domain services and a helpful tool
Hi Tim,

Thanks for your post on this subject (and all your others which are often helpful!). I'm still scratching my head with this issue though.

The SOAP service I am connecting to is provided over HTTPS. When using ClientHttp to access the service (which I need to do in order to process SOAP faults and manage cookies), I can see with Fiddler that Silverlight is successfully fetching the clientaccespolicy.xml file via HTTPS. It then establishes a second HTTPS connection before giving EndpointNotFoundException with InnerException:

System.Net.WebException: The remote server returned an error: NotFound

It does not appear to have attempted to invoke any service request at this point - just opened the connection.

However, if I revert to using the browser's own HTTP stack, everything works fine. I've also established that (at least using a different host machine) it will attempt to call the service using ClientHttp if the service is non-secured.

What do I need to do with ClientHttp to make this work for secure services?

Here's the code I'm using to create my proxy from a generated service reference:


bool registerResult = WebRequest.RegisterPrefix("https://", WebRequestCreator.ClientHttp);

...

const int MaxHTTPBufferSize = 10240000;

String address = "https://" + host + ":8443/wcpserver/app";

BasicHttpBinding bind = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
bind.MaxBufferSize = MaxHTTPBufferSize;
bind.MaxReceivedMessageSize = MaxHTTPBufferSize;
bind.EnableHttpCookieContainer = true;

EndpointAddress endpoint = new EndpointAddress(address);
proxy = new MyAPIClient(bind, endpoint);

Here's my clientaccesspolicy.xml file:

<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="http://*"/>
<domain uri="https://*"/>
</allow-from>
<grant-to>
<resource include-subpaths="true" path="/"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>

Any thoughts greatfully accepted!

Regards,
John
11/27/2009 11:23 AM | # re: Silverlight cross domain services and a helpful tool
Hey, Tim! I have to know, where did you get the black "404 Not Found" T-Shirt? (Please?) :)
11/27/2009 12:27 PM | # re: Silverlight cross domain services and a helpful tool
By the way, the servers I'm working with only have self-signed certs. I found that when using the browser HTTP stack for the secure web service calls, this would only succeed if I had previously fetched a page from the server and forced the browser to accept the certificate.

Perhaps I somehow need to force ClientHttp to accept these certificates to make my calls succeed? How do I do that?!?

Regards,
John
11/28/2009 3:40 PM | # re: Silverlight cross domain services and a helpful tool
Amy - thinkgeek.com
1/26/2010 4:33 AM | # nice t-shirt you got
nice t-shirt you got
5/18/2010 2:59 PM | # re: Silverlight cross domain services and a helpful tool
Hey all, if this happens when you're in the debugger, it means the ports for the app and the web service have become different. Look at the port when your app runs. Compare that to the port in the message telling you about cross domain. If they're different, you can do a global search and replace of one for the other. Build all, then update the service reference and voila!
Gravatar
11/8/2010 12:47 AM | # re: Silverlight cross domain services and a helpful tool
Hi John! Were you able to resolve your issue with clientHTTP failing before making a service call? I am having the same issue. clientHTTP works fine in IE but fails in Firefox and Chrome. The server hosting the web service uses self-signed certificate.
1/7/2011 12:02 PM | # re: Silverlight cross domain services and a helpful tool
This seems to be an old thread, but relavant to my problem. I have a WCF service being consumed by a Silverlight 3 app. Everything works great, even when the service is deployed and consumed cross-domain. I've now added methods to the service that accept an ObservableCollection in order to do some 'bulk' processing. When I run the entire project locally (in VS2008), these methods are invoked and work flawlessly. When I deploy the service to a test server (cross-domain), these methods, and only these methods fail with, in essence ' System.Net.WebException: The remote server returned an error: NotFound'. I've tried all manner of solution, change to List<>, an array[], etc. Same thing. The strange part is like I said, other methods that don't take collection parameters work fine, so it's not a cross-domain policy, security, etc. issue. Any ideas?
Thanks
Jeff
1/10/2011 7:34 AM | # re: Silverlight cross domain services and a helpful tool
More info on the previous post. I also have methods in the service that RETURN lists, arrays, collections, etc., that work just fine. The issue is in passing such to a method in the service. Another interesting finding is that when I set the address of the service to be //localhost/xxxx/xxx/svc and run the entire project from my development server, the methods in question work fine. It's when I change the address to call the service on the server that it fails. I even went the extra distance and installed VS2008 on the server, remoted it, and ran the project using localhost from there, THAT also works. So the issue isn't something 'missing' on the server, it seems to be isolated to that fact that it is calling it in a cross-domain manner (even though the web and the service are served from the same location. Using silverlight 3, so there is no relative addressing.
4/26/2012 2:13 PM | # re: Silverlight cross domain services and a helpful tool
That was the right thing mentioned concerning the security issues for this software. The next step may be to correct it by using qualified methods such as the alarm setup technique. This has been shown to generate a good success rate overall. It has been a pleasure reading your guides, I've found them extremely helpful and sensible. Maybe you'll be able to offer some pointers which can be implemented on some of my sites. All the best. home security

 
Please add 3 and 8 and type the answer here:

DISCLAIMER:

The opinions/content expressed on this blog are provided "ASIS" with no warranties and are my own personal opinions/content (unless otherwise noted) and do not represent my employer's view in any way.