Silverlight + smart client operations in one service? - wcf

For my project's web services I want to support desktop clients and silverlight clients. Should I write a separate web service for each or put all the operations in one service? If I put them all in one, I have to go with basicHttpBinding. The winforms app uses wsHttpBinding now, what do I lose going with basicHttpBinding?

I very strongly recommend you read this thoroughly:
"Silverlight and WCF Feature Comparison"
http://msdn.microsoft.com/en-us/library/cc896571(VS.95).aspx
There are quite a few gotchas when developing a web service for silverlight usage, especially if you already have a wsHttpBinding solution. Good luck!
EDIT: also I found this article useful:
WCF : BasicHttpBinding compared to WSHttpBinding at SOAP packet level
http://geekswithblogs.net/claeyskurt/archive/2008/04/22/121508.aspx

Use one web service with two endpoints, that would allow you to support basicHttpBinding as well as wsHttpBinding.
The difference between the two bindings is that basic is Soap 1.1 whereas ws is Soap 1.2 and WS-Addressing Specifications, in addition wsHttpBinding offers more security options

Related

I'm learning WCF and I'm stumped; why would I use this over a regular web service?

What benefits does WCF bring to the table and why should I use this new technology over good old ASP.Net web services?
Maybe you don't need to transition to WCF if regular Web-Service will work for you,
however WCF encompasses more than just Web-Services.
With WCF you can utilize different communication channels (such as Web-Services, MSMQ, named pipes...) utilizing the same end-point service handler code.
WCF also has different built-in security mechanisms, allows you to utilize different serialization mechanisms (if something other than Soap is needed like raw JSON), hosting of services without the requirement of needing a web project etc...
As such WCF is more a general service hosting framework that can replace regular ASMX web services
Here is a good article from msdn that talks about the differences between ASMX and WCF
A few key areas
Serialization - Asmx uses XmlSerializer while WCF uses the DataContractSerializer. The Datacontract serializer is about 10% faster (source along with other information)
Differences Between ASMX and WCF Services
Greater protocol support (HTTP, TCP, ICP, MSMQ for WCF), ASMX only supports HTTP

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.

netTcpBinding or wsHttpBinding

I have a WCF Service hosted as Windows Service and client is an ASP.Net application consuming WCF Service methods.
In process of implementing security, I am confused over which among netTcpBinding/wsHttpBinding will be suitable for my case.
Most likely all the applications in scene (WCF Service, Windows Service, ASP.Net Website) will be sitting on different servers in our office, thus in an Intranet. ASP.Net website will be accessed by users over Internet.
Though, I can always use wsHttpBinding here, will it be suitable to set the service endpoint using netTcpBinding in my case?
Check this out for a comparison of all the different built in bindings:
Configuring System-Provided Bindings - MSDN
As for your case, as long as it's the web server contacting the WCF service and you don't need to provide an endpoint for any external consumers of the service...netTcpBinding should be up to the job.
You can expose your service over more than one binding if you wish, so you could actually use both.
However, if you control both client and service and they both use WCF, netTcpBinding is much faster. Unless you have a firewall between those two, I would choose that.
Use netTcpBinding instead wsHttpBinding if you are willing to trade interoperability for performance knowing that you can easily cancel the trade if you are not satisfied with the results (it's a matter of changing config values).
Since your WCF Services will be accessed by applications sitting in your office (INTRANET), I would go with netTcpBinding.
In an intranet scenario, it is recommended that you use netTcpBinding unless you have a specific requirement to use other bindings such as wsHttpBinding. By default, netTcpBinding uses binary encoding and transport security, which delivers better performance.
Following URLS will help to get more information
http://msdn.microsoft.com/en-us/library/cc949026.aspx
http://msdn.microsoft.com/en-us/library/ms730879.aspx
Since your WCF service is a windows service +1 for netTcpBinding. Hosting netTcpBinding on IIS is difficult.

Why only basicHttpBinding with silverlight and wcf?

Exact duplicate:
Why does Silverlight 2 only support WCF basicHTTP binding?
Why only basicHttpBinding with silverlight and wcf? Perhaps you have a link that covers this, you don't have to do a bunch of typing :+>
A couple of answers: (1) Silverlight 4 now makes the Net.TCP binding available, which is darned handy when it's not blocked, since it's dramatically faster (see here for details). So clearly there's nothing inherent in the Silverlight architecture which prevents it from using other bindings.
(2) As for why Silverlight doesn't make use of the other WS* Http-based bindings, it's just a guess, but I wouldn't be surprised if those bindings made use of the HTTP protocol in ways that Silverlight's limited HTTP stack won't support, probably for security reasons. For instance, I know that Silverlight limits the content headers that you can place on an HTTP request, and if any of the WS-* protocols require custom headers, or headers that might represent a security risk, MS would want to prevent that.
(3) Of course, it's also possible that MS just hasn't gotten around to it yet. They've done a lot with Silverlight in the last couple years -- but presumably they have to prioritize their features.
Hm, I am pretty sure this is duplicate, but can't find it. I think the short answer is that BasicHttpBinding is the only binding that works in Partial Trust.
(EDIT: found the dup, linked in question now)
I found several links for this but no definitive answer. Smells like Silverlight was designed against ASMX web services for Web service style communication and the way to get WCF to play with older clients expecting an ASMX web service is to use the basicHttp binding.
This link gives you a fully worked example (using Beta2 of Silverlight).
http://msdn.microsoft.com/en-us/magazine/cc794260.aspx
A standard WCF service can be invoked by a Silverlight app as long as the Silverlight app has a binding of type basicHttpBinding. You must either make sure you change the default binding of the WCF service from wsHttpBinding to basic­HttpBinding or create a new binding of type basicHttpBinding
This Reference says the same thing but again offers no explanation.
http://timheuer.com/blog/archive/2008/03/14/calling-web-services-with-silverlight-2.aspx
Silverlight communicates using the BasicHttpBinding for WCF

Why does Silverlight 2 only support WCF basicHTTP binding?

I am confused... How can MS release two versions of Silverlight without having proper support for WCF bindings? Should they not support wsHTTP binding at least? So the service can have proper Message-level security? (i.e. certificates etc...)
With a basicHTTP binding, looks like the only two options to secure the service are...
HTTPS (but that does not cover authentication)
Custom-implemented WS-Security on top of basicHTTP binding
Am I missing something?
Silverlight is a UI technology and it is normal for a Silverlight page to talk back to a single server that contains all the middle tier logic. Therefore I consider it reasonable that WCF is limited to basicHTTP binding over HTTPS. As I understand it, the more complex WCF bindings were designed to be used between servers in data centres.
Normally I would expect both the backend and the front-end of a Silverlight page to be designed and coded together. I would expect 3rd party systems to be access by the middle tier logic rather then the Silverlight page directly. Afterall Silverlight did start out as a “better HTML then HTML”.
These days Silverlight applications are starting to look more like thick client applications, so the limitations on WCF binding may no longer be as reasonable as they use to be.
Ok so a Microsoft boffin has answered this here. looks like a 'talk to the hand' to me
http://silverlight.net/forums/p/20844/78325.aspx#78325
For Silverlight V2.0 final release, the answer is no. We only support BasicHttpBinding and PollingDuplexHttpBinding.
(please "mark as answer" if this post answered your question. Thank you!)
Jeff Cao
I think BasicHttpBinding is the only binding that's yet been enabled for Partial Trust (APTCA).