Silverlight WCF calls work in IE but not in FF - wcf

I'm having a WCF service deployed on one of my servers, and my Silverlight app on the other server. The problem I'm having is running it in Firefox 3.5. Opening in IE 6/7 works great, but when I open it in Firefox it loads the app, but on calling WCF service i get this:
An error occurred while trying to make a request to URI 'http://10.1.1.20:87/MyService.svc'. 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.
(The connection works over VPN so don't worry about the IP address)

I have encountered a similar problem and after a lot of research I found that adding the following line of code into the constructor of my UserControl solved the problem:
bool registerResult = WebRequest.RegisterPrefix("http://", WebRequestCreator.BrowserHttp);
More information about the WebRequest member can be found here.

Related

WCF CORS issue - WPF application successfully connects but Angular App throws 405

I have a question about enabling cross-domain calls.
I have a WCF Rest service that is hosted in xyz domain. I am able to test these REST APIs from Advanced Rest Client, Postman and Fiddler. I also have a WPF application that actively calls these API which is hosted in a different domain (say abc domain) which works fine in getting responses.
However, when I created a new Angular web application and a Windows Service (deployed on abc domain), and tried calling the APIs from these two components, I am getting a 405 error.
Can someone explain:
How REST clients always are able to successfully establish a connection?
How does my WPF successfully connects to the WCF service even though
its on a different domain?
Why is my Windows Service/Web App not able to talk to WCF?
I assume that the issue here is caused by the preflight request. The browser issues this OPTIONS verb request to ask the server if the origin is allowed to call the API in a non-safe manner.
If your WCF REST service does not deal with this request, the WCF runtime will try to dispatch the request to your service implementation.
However, if the runtime does not find a method to call for this verb, it will return a 405 Method Not Allowed response.
I've dealt with this in the past by using an IOperationInvoker implementation, installed via an IOperationBehavior. This article describes a slightly different way of doing basically the same.

"An unsecured or incorrectly secured fault was received from the other party."

I am trying to implement the same functionalities of one WCF web service (which is working of course) to another WCF web service, but I encounter an exception: {"An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail."}
and {"The message could not be processed because the action 'http://tempuri.org/IBlueWebService/GetDataSourceList' is invalid or unrecognized."}
I copied exactly same codes and same configuration and I use my client tool to call the new web service (I only changed the web service url to the new one), but it throws the exception.
Some forums told me to set the establishSecurityContext but it doesn't work also.
Please can somebody tell me what I am missing?
Solution
I tried to compare the wsdl files and I remarked that the new wcf web service had different action url from the old one, but I tried to use the same config file in client application (which is obviously looking for old wcf web service action url).
So in every operationcontract of new web service, I specified the action url and replyaction url for every operation and it works for me now.

How do I access a workflow service in silverlight?

I have one worflow service named GetDataWorkflowService.xamlx that I want to use in Silverlight.
When I add a service reference to my application, it gives a message 'This Operation is not supported for the relative URI.' It still adds the reference, however.
When I use the referece:
Servicelient proxy=new ServiceClient();
proxy.GetDataCompleted += (o, a) => Debug.WriteLine("Result is " + a.Result);
proxy.GetDataAsync(123);
I get the following error:
An error occurred while trying to make a request to URI 'http://localhost:1234/GetDataWorkflowService.xamlx'. 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. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.
I don't understand what's happening.
A few things:
What happens if you use the WCF Test Client to call GetData()? Do you get an error or does that work just fine. If you get an error here concentrate on the server parts.
What happens if you set a service reference from a console application and call your workflow service. Same error or does that work?
Is the workflow service hosted in the same web site as the Silverlight client? If not do you have the cross domain policy files setup correctly.
Assuming the WCF Test Client works. Open up fiddler and compare the request from your Silverlight client with that from the WCF Test Client. What is different?
Enable tracing on the server to see if there are any exceptions or warnings that might provide more insight to what is wrong.
Check your startup project to be sure you are starting a web project and not the Silverlight project. For more details see Troubleshooting Workflow Services / Silverlight on my blog

Getting a MethodAccessException(in event log of server) and HTTP Error 401 Unauthorized(at client side) in WCF Rest Service in IIS6.0 Win2K3 enviorn

I wrote a WCF REST based service that uses webHttpBinding and uses JSON to post data.This service works fine in all of our internal environments. But in one of our environment which is exact replica of Production. It is not working. If I inspect in Firebug, I see "HTTP Error 401 Unauthorized" and in server I See following in the event log.
System.MethodAccessException
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous
MethodAccessException: System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(System.Web.HttpApplication, Boolean) at System.ServiceModel.Activation.HttpHandler.ProcessRequest(HttpContext context)
I haven't pasted the whole event log. But,afore are the key parts of it.
I am not able to figure out what is happening, we are using custom httpmodule for authentication.
Need urgent help on this
Thanks in advance
From MSDN, a MethodAccessException occurs when you try to call a private/protected method from somewhere that you aren't allowed. This is thrown during reflection, which is more than likely what WCF is doing under the covers.
My bet is that one of your service methods is marked as private or protected.
This would work in your local environment because it's under Full Trust. Your production environment is most likely running in Medium Trust. (Under Medium Trust, you aren't allowed to bypass the accessibility modifiers.)
-- Tatham

Self hosted cross domain WCF service called from silverlight hosted in sharepoint

as the title already states I am trying to call a self hosted WCF service (hosted in a windows service) from a silverlight 4.0 application which is hosted in sharepoint 2010. I use the basicHttpBinding and I already tried a lot of things as suggested here:
http://www.dotnetfunda.com/articles/article416.aspx
or here
http://blogs.msdn.com/b/carlosfigueira/archive/2008/03/07/enabling-cross-domain-calls-for-silverlight-apps-on-self-hosted-web-services.aspx
but none of them worked I still get the error:
An error occurred while trying to make a request to URI 'serviceuri'. 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.
The inner exception states:
when deploying an Office solution, check to make sure you have fullfilled all security requirements.
The two files clientaccesspolicy.xml and crossdomain.xml are accessible on http://myserver/clientaccesspolicy.xml and http://myserver/crossdomain.xml
Does anybody have an idea on how to solve this?
All these things helped me out. But the biggest thing for me was turning on Fiddler and tracing the request/responses from Sharepoint + Silverlight. I was getting a 502 error back for some reason. I noticed that my Url in my code was "http://localhost:", however the request from silverlight was "http://[servername]:" you would think that this should work, however it didn't.
I remembered I had run into issues before where "localhost" was giving me problems, thus what I did was to edit my Host file from /windows/system32/drivers/etc and simply add the line::
127.0.0.1 [servername]
I did a iisreset, I left fiddler running and I unchecked the Enable IPv6 option (Tools->Fiddler Options) and everything started working. The Clientaccesspolicy.xml could be accessed, and sharepoint + silverlight could call out into the wcf world :)!!!
There was one major issues however, when you turn Fiddler off, it stopped working... Now I have to figure this one out...
I hope this hellps you.