WebService in Phone 7 - fundamental questions
Howdy, I would like to create a WebService for a Windows Phone 7 App. I develop with Visual Studio 2010 Professional. However I cannot find a suitable option on how to create a webservice ( I tried to use "WCF-Service" but once I am in my App I cannot call the basic functio开发者_JS百科ns of the webservice ( e.g. Hello World ).
Does anybody have a good fundamental tutorial on how to create a webservice with VS2010 which is used in a Phone 7 Application? I just need to know how to create the web service and then deploy it in Phone 7 :).
Thanks!
One of the basic things to remember regarding using Web Services with Silverlight for Windows Phone is that Silverlight currently only supports a subset of the WCF Bindings and in particular does not support WS-Trust, which implies that the default binding set up when creating new WCF Services (wsHttpBinding) yields service endpoints that do not work out-of-the-box with Silverlight - for Phone or otherwise (at least currently...Silverlight 5 promises changes in that area.) In Visual Studio, one option for creating a SL-friendly WCF service is to start with a standard WCF Service project, as you outlined above, and go back to add alternate endpoints or replace exiting ones with bindings that are friendly to SL (basicHttpBinding, or custom binding over Http with a binary encoder...there's also a duplex option). Alternatively (and much easier), you can create a new service that is already set up for SL by using the Silverlight-enabled WCF Service item in Visual Studio (In your web project, selct Add new item, select the Silverlight folder, and locate the item template named "Silverlight-enabled WCF Service.")
There's actually a 3rd option for web-services in general - create an old-style ASMX web service. As long as you do not use any WSE Extensions that make the binding non-interoperable with SL, those "classic" web services will work with SL or SL for Windows Phone.
精彩评论