How to communicate with clients' WCF services (behind firewall) from internet asp.net mvc app? - wcf

Can an internet Asp.net MVC app communicate with client companies' WCF services (hosted on their IIS behind firewall) using SignalR? Otherwise what other .Net technology would help here? Or any third party solutions exists?

There's shouldn't be any problem with communicating a server behind firewalls, as long as the appropriate rules are allowed. Just becareful when applying rules as SignalR has multiple fallback mechanism to support different browsers.

Related

Asp web api vs wcf for point of sales application

I'm planning to develop a pos application for restaurant. Client will be using pc and mobile. Application will be used in local area connection. I'm still considering whether to go with wcf or web api. What are the advantages of using wcf/web api for the type of application i'm building?
Use WCF to create reliable, secure web services that accessible over a variety of transports.
Use ASP.NET Web API to create HTTP-based services that are accessible from a wide variety of clients.
Use ASP.NET Web API if you are creating and designing new REST-style services. Although WCF provides some support for writing REST-style services, the support for REST in ASP.NET Web API is more complete and all future REST feature improvements will be made in ASP.NET Web API.
If you have an existing WCF service and you want to expose additional REST endpoints, use WCF and the WebHttpBinding.
from the official Microsoft Documentation.
Essentially, my take on this is that WCF is much more difficult to work with, and not completely compatible out of the box with many mobile clients, so only use it if you know that it's something you need.

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.

Comparing Self Hosting: WCF vs HttpListener

I've been looking into the possibility of using ASP.NET Web API and SignalR in a self-hosted application, and I noticed that the ASP.NET Web API self-hosted implementation uses WCF, and the SignalR self-hosted implementation uses System.Net.HttpListener. This makes it a little harder to come up with a combined self-hosting solution, but it does get me wondering why the different project teams would use different approaches.
What are the advantages and disadvantages of each approach? Is there any particular reason why SignalR could not use WCF self-hosting, or Web API could not use HttpListener?
EDIT: I understand that Web API self-hosting provides a more complete stack than SignalR, my question is more about why you would choose a WCF implementation over System.Net.HttpListener when implementing your own self-hosting solution.
Web API self host provides entire HTTP stack so it's much much richer than System.Net.HttpListener.
SignalR uses that to purely open a communication window for its own purposes.
So yeah for now, you need to run them in parallel on different ports.
In the future, with OWIN, you will have everything under one roof.
EDIT: there was actually an issue similar to yours raised on SignalR github, and the answer was pretty much what I just said - https://github.com/SignalR/SignalR/issues/277
Just so we are on the same page, The WCF Self-host that Web API Self host uses, does use HttpListener under the covers. However, I think I may have found a major downside to the WCF Self-host.
I have not confirmed this yet, but it seems that when you use Web API Self Host, the base address you provide is not translated directly into a HttpListener prefix. It seems like WCF translates the base address and wildcards the host.
This means that the WCF self-host will respond to any host on the specified port. This means that you cannot run a Web API Self hosted service side by side with IIS on the same port using a different host name.
This might be the reason that SignalR decided to scrap the WCF Self-Host and use HTTPListener directly.
While you can use the WCF stack to host the services yourself, you may want to consider the "IIS 7.0 Hostable Web Core". It has the benefit of running IIS in your user process. Using this approach, you can have several applications running on the same port, irrespective of the technologies.
If you are interested, you can look at:
Host your own Web Server in your application using IIS 7.0 Hostable Web Core
Creating Hosted Web Core Applications
This all assumes you are running Vista or later...

What are the differences between WCF and traditional ASP.NET Web

I am new to WCF and Web Services in general. What are the improvements that WCF brings to the table? Can anyone give a side-by-side example of a traditional web service and the same one written using WCF and point out the differences and advantages?
Duplicate question Moving ASP.net webservices to WCF
EDIT: Think i found the answer you where looking for a side-by-side code based comparison and even better it's from MSDN: Comparing ASP.NET Web Services to WCF Based on Development
There are several related questions:
Difference between aspnet web method and wcf webservice
Benfits of using WCF
Moving aspnet web services to wcf
However you asked for a side by side comparison in which case i think Sam's Wcf vs ASMX blog article is more what you are looking for.
Quoting ad-verbatim (let me know if i should just leave it as a link):
WCF vs. ASMX
Protocols Support
WCF
HTTP
TCP
Named pipes
MSMQ
Custom
UDP
ASMX
HTTP only
Hosting
ASMX
Can be hosted only with HttpRuntime on IIS.
WCF
A WCF component can be hosted in any kind of environment in .NET 3.0, such as a console application, Windows application, or IIS.
WCF services are known as 'services' as opposed to web services because you can host services without a web server.
Self-hosting the services gives you the flexibility to use transports other than HTTP.
WCF Backwards Compatibility
The purpose of WCF is to provide a unified programming model for distributed applications.
Backwards compatibility
WCF takes all the capabilities of the existing technology stacks while not relying upon any of them.
Applications built with these earlier technologies will continue to work unchanged on systems with WCF installed.
Existing applications are able to upgrade with WCF
New WCF transacted application will work with existing transaction application built on System.Transactions
WCF & ASMX Integration
WCF can use WS-* or HTTP bindings to communicate with ASMX pages
Limitations of ASMX:
An ASMX page doesn’t tell you how to deliver it over the transports and to use a specific type of security. This is something that WCF enhances quite significantly.
ASMX has a tight coupling with the HTTP runtime and the dependence on IIS to host it. WCF can be hosted by any Windows process that is able to host the .NET Framework 3.0.
ASMX service is instantiated on a per-call basis, while WCF gives you flexibility by providing various instancing options such as Singleton, private session, per call.
ASMX provides the way for interoperability but it does not provide or guarantee end-to-end security or reliable communication.
WCF is far wider in scope than ASP.Net webservices.
WCF can run in any application. APS.Net webservices only run in IIS.
WCF supports models like ReST, Remoting, SOAP, MSMQ etc. ASP.Net only supports SOAP
WCF is more configurable.
WCF supports a more declarative way of programming. You can get more done with less code.
ASP.NET Web Services are pretty much just that. Web Services. They're SOAP/WSDL based and provide their services only to the web.
WCF Services offer a much more flexible framework. For instance, depending on how the service is defined, it can be a Web Service hosted in IIS which serialized its data via XML and uses the REST model...or it can be a Remote Windows Service that is hosted in it's own process and serializes its data via binary. All of this is achieved using the different Service/Data contracts in WCF.
In short...you can make a WCF service look almost identical to a .NET 2.0 Web Service fairly easily but, with a little work, you can do a WHOLE LOT MORE.