Silverlight Accessing WCF and CrossDomainAccessPolicy without IIS - c#

I have a Windows Service that exposes a WCF service and so I'm not using IIS. I'm suddenly getting the famous SecurityException that mentions using a cross-domain policy when I try to access the service from a Silverlight app. However, since I'm not using IIS, does that mean I need to have a web server on the same port as my WCF service just to serve this file? Is there a better way to do it?

You can add another service with webHttpBinding (REST) that serves out ClientAccessPolicy.xml file. Then in your Windows Service, you can start that endpoint along with the other one so that Silverlight clients can get the cross-domain policy file. You can find more information in below links:
Step By Step - Using Silverlight to Access a WCF Service Hosted In a Console Application
Self hosted WCF service and enabling cross domain calls

Related

Can you add a web service to an existing Windows Service project (.NET)?

I already have a Windows Service project that runs scheduled tasks as part of a larger application. I want to add some Web Services to it (i.e. SOAP), so that some .NET clients can connect and request services (this is all on a LAN, not over the internet). The server application is a Service Project with references to some class library projects.
Is this something that can be done, or does the web service require that I create an ASP.NET project? Sorry for the very basic question, but I'm not sure where to start.
You can create a new WCF service without creating an APS.NET webservice and you can use SOAP to communicate with it.
Maybe this MSDN link can help you more.
The answer is that a Windows Service can "self host" WCF WebServices using the ServiceHost class.
Relevant article: Hosting and Consuming WCF Services.
Specific section: Hosting in Windows Services.

Hosting a WCF webservice and WCF Net.Tcp service in the same IIS container?

I'm trying to build a system which consists of:
A centralized IIS component
A Client application written in .Net
A Third party application.
The .Net Client should on startup connect to a WCF Net.Tcp Binding on the IIS application and register it's self as a consumer of requests (Callbacks).
The Third party application will then make Web Service calls to the IIS server which will farm out the request to the .Net Clients.
How do I host mutliple WCF services IIS? Is this possible?
I assume that I'd have to instantiate the services in the web.config as endpoints but I'm not sure how to do this.
You could use multiple SVC files hosted within the same application or you could use MVC-style Routing to establish the multiple ServiceHosts.
Here is an MSDN example on hosting WCF within IIS using web.config and SVC files.

c# rest webservice without IIS

Is there a good example/tutorial on how to create and run WCF REST webservice without IIS ?
I want to have a console application that'll run the webservice and not host it in IIS.
Just self host your service with System.ServiceModel.Web.WebServiceHost in your console application. It will wire up the appropriate endpoint behavior / binding.

WCF Service Hosted in Windows Service over net tcp

In my project I have one WCF Service which is hosted in a Windows Service. I hosted the WCF Service in Windows Service over netTCPBinding and Installed Windows Service. To access WCF service in my silverlight project I have added service reference of wcf.
But, when I am calling a method in WCF Service am getting the following error :
Could not connect to
net.tcp://localhost:8732/WCFHost/.
The connection attempt lasted for a time
span of 00:00:03.2951885.
TCP error code 10013: An attempt was made to
access a socket in a way forbidden by
its access permissions..
This could be
due to attempting to access a service
in a cross-domain way while the
service is not configured for
cross-domain access. You may need to
contact the owner of the service to
expose a sockets cross-domain policy
over HTTP and host the service in the
allowed sockets port range 4502-4534.
Please help me out.
For same-machine connections rather make use of Named Pipe bindings.
It might help if you showed us your service and client side endpoint configurations.
EDIT: After reading up a bit on the error you're getting (here among other sites), try changing the port number from 8732 to something between 4502-4534 as the error message suggests.
Keep same protocols at both the server and client end. May be your are calling the service with different protocols. Also check if your are using nettcp, your are having access to the machine where service is hosted.
use basicHttpBinding instead of netTCPBinding

How to assess a Windows Service hosted WCF service from another WCF service hosted in IIS7?

I have done a work which contains two parts
WCF service which is hosted in Windows Service
WCF service project hosted in IIS7
I have done both comfortably,But i got a problem?
I want to call a method from WCF service hosted in WS from the 2nd WCF service hosted in IIS, but i was unable to do that? Can anybody help in this?
You should be able to configure a client endpoint in the service being hosted in IIS to the service being hosted as a Windows service, and make your call through a proxy just as you would normally make a call to a WCF service.
Well, if your service hosted in IIS7 wants to call the other service, it needs to become a client of that other service.
So basically, in Visual Studio or on the command line, you need to create a service reference to your second service, so that you'll get a client-side proxy class, which you can then use to call the second service. Also, you will need to add some configuration settings to your web.config for the service hosted in IIS7 in order for it to be able to call the other service (in a Windows service).
So where exactly are you stuck??

Categories