Javascript Client for Windows Azure Service Bus Relay service? - wcf

Is it possible to consume a WCF service via a Windows Azure Service Bus Relay in a JavaScript client?

You can setup a WebHttpRelay service that can be accessed via GET calls in JavaScript if you are using Node.
EDIT: This gives a good overview on how to setup a WCF service to support CORS. You need to enable it on your service to allow calls from a different host.

Related

Calling a net.tcp wcf service from Silverlight - in an external facing web site?

I have an external (public) website developed in Silverlight. The Silverlight app currently calls http based wcf services hosted in IIS.
I am now having to call a wcf service with net.tcp binding hosted in a different app server. I have the net.tcp wcf service hosted in a windows service on port range 4502-4530 and with an interface to expose clientaccesspolicy.xml file as part of the service. I am able to invoke this service from my Silverlight app in the web server. I want the SL app to make direct call to net.tcp, rather than routing the call to it from another http based service.
Question is will this work without any issues when exposed over internet.
Client browser --> IIS webserver with Silverlight website --> App Server with wcf service on net.tcp.
I am assuming in this case, from XAP SL would try to make direct call to the app server service using net.tcp ?
The communication between the web server and app server could be opened up for ports 4502-4535. But I am wondering what about the client. Does this setup require the ports to be available even in the clients machine (with browser)?
Any insight is much helpful.
Thanks.
Take a look at http://support.microsoft.com/kb/2425652; there is sample code included as well! If you setup clientaccesspolicy.xml correctly; it should work as long as clients can access your TCP server.
If your clients are behind some firewall which is blocking your server's ports; they may face connectivity issues!

Signalr as WCF Service for various clients

Need an advise on following.
What is the best option to host Signalr, could it be hosted as a WCF service?
This SignalR will be consumed by clients like web application (MVC4) and ios applications.
Thanks,
The answer is No as far as I know. You cannot host SignalR hubs as a WCF service. As alternative to hosting in a ASP.NET website, you can choose self hosting approach as explained here.
On the other hand, SignalR has client APIs for both ASP.NET and iOS/OSX. The easiest solution (and my recommendation) would be direct hub usage via the client API.
If you insist on to open a WCF endpoint to manage SignalR hubs, you can reach SignalR IHubContext from WCF by using GlobalHost.ConnectionManager.GetHubContext<YourHub>().
Only requirement here is that your WCF service must be hosted on the same web application with your SignalR hub. External WCF services from different service applications cannot reach your hubcontext.

Discover locally running WCF from WP7

I have a WCF service running inside Windows Service and it is located on my local network. What I want is to be able to discover WCF from my Silverlight app on my WP7 (on the same network).
I know there a Discovery feature in WCF, however it requires to UDP, which is not supported on WP7. So are there any other ways to discover local WCF?
I also do not know prior to launching WCF the IP address of the WCF service.
The solution I came up with, is to use Sockets as on WP7 they support multicast.
So set up would like this:
Desktop service - Windows Service hosting WCF and small Socket app
which listens on specific port.
WP7 client - before connecting to WCF
a broadcast would be sent using Sockets to find out an IP address of
the machine which runs WCF, when got a response connect to WCF.
For a WCF Service to be referenced in a WP7 project the WCF Service MUST be a BasicEndpoint
You could provide a basic endpoint that exposes a kind of catalog service. It doesn't have to implement UDDI but it could be a custom protocol to suit your needs and return addresses of web services.
This way you only need to know a single address. Of course you can cache returned addresses and query the catalog service only when you are not able to connect.

How to start/stop windows service from a remote machine through WCF service?

I have created a WCF service which is deployed on my local machine. This service exposes one method which start/stop a windows service on my local machine.
On the remote machine I have created a client that consumes the WCF service. When I try to invoke the method which start/stop service exposed from a WCF service , I get InvalidOperationException . I found that this is the Security issue.
Also when I do the same operation (start/stop windows service) on the local machine it works!!
The WCF service is hosted on IIS 7.0 which is using basichttpBinding. Also Anonnymous access is checked. I have also added <identity Impersonate = true > under the web section in the web config file but still no success.
Please help!!
You set impersonation for ASP.NET. Impersonation in WCF uses its own infrastructure. Moreover in WCF client has to allow service to impersonate his identity. Check this simple example.

Why need Service Bus when you have WCF?

I'm reading into WCF and Service Bus topics, but I don't get the use of Service Bus in some topics. Check this image of the use of Service Bus:
http://ecn.channel9.msdn.com/o9/learn/Azure/Labs/IntroServiceBus/Lab.html/html/images/4a0aa8f8-f4d1-49b6-b950-cf954402c599.png
In above image Your Service is behind a firewall, and then you apparently need a Service Bus. But if you want to expose Your Service, isn't the solution to simply remove the firewall? And then every client can connect to Your Service.
I understand that you don't want to remove the firewall for your total network, but you can create a publicly visible webserver with IIS and run Your Service on that. Or am I missing something?
A service Bus helps you enhance your services architecture.
Many organizations have what is refereed to as point to point or spaghetti integration.
This is not good.
A service bus would help you have a single point of integration. e.g. in the image you linked (The Azure Service BUS architecture), by adding the service to the ESB you can unify service authentication using Access Control even if they sit behind a firewall instead of each service being responsible for authenticating itself. Further , even if the address of the service changed you would only have to change it in one place (the ESB) instead of all the applications that reference it.
A service bus can do many other things including validating services messages, enhancing them in case they don't meet your requirements, transforming them e.g from plain old XML to SOAP , routing messages, enhancing messages etc.
WCF is a way of setting up and managing communication interfaces. It cares not for the content of your messages.
A service bus, however, is different in that it's responsible for message routing.
You can build a service bus using WCF and other bits, but WCF in and of itself isn't a service bus.
Service Bus is a relay service so all clients will point in the cloud. Hackers will attack relay service in the cloud rather than your WCF service. All security aspects taken care by relay service.
To precisely answer your question, not all WCF services are hosted on service bus and your solution may be just sufficient. It depends on your need and existing infrastructure.
I highly recommend Juval Lowy's this article.
Excerpt from the article:
The relay service is a service residing in the cloud, whose job is to assist in the connectivity, relaying the client calls to the service. Such a relay solution does require both the client and the service intranets to allow connections to the cloud, but since the cloud constitutes neutral territory for both the client and the service, most environments allow calls out to the Internet. First, both the service and the client must establish connections and authenticate against the relay service. At this point, the relay also records where the service is and how to best call back to it. When the client calls the relay service, the relay service forwards the call (the client message) to the service. While the sequence seems straightforward, in practice it involves a considerable amount of intricate network programming, messaging and standards know-how, security expertise, and more. Such a solution is simply out of reach for the vast majority of applications. This is exactly the gap the Microsoft .NET Service Bus is designed to fill. It is a ready-made relay service, hosted and managed at a Microsoft data center. The .NET Service Bus acts as a perimeter network in the cloud, providing a single place to manage credentials of the client and services. The .NET Service Bus is the front end of the service; it encapsulates and isolates the service from malicious callers lurking on the Internet and is responsible for repelling various attacks from denial-of-service to replay attacks, while obscuring the identity and true location of the actual service.
The main difference between connecting to a regular Windows Communication Foundation (WCF) service and using the relay service revolves around hosting. In the relayed case, the service must connect to the .NET Service Bus, authenticate itself, and listen to calls from the relay service before the client sends its requests. This means that you either must launch the host explicitly or use an NT Service as a host, and that you cannot benefit from hosting in Windows Activation Service (WAS) (or IIS) since WAS will launch the host only after the first request comes in, and that will never happen because the host has not connected to the .NET Service Bus in the first place.
The .NET Service Bus supports a WCF-friendly programming model by offering a set of dedicated bindings and behaviors. By and large, except for a few slight twists to the programming model, working with the relay service is no different than working with any other WCF service. The .NET Service Bus supports the core WCF features of reliable messaging, message security, and transport security.