I've found nothing about wcf support on monotouch. I need to create web service for iphone with user authentication. I'd like to use wshttpbinding.
Does monotouch support w开发者_Go百科cf wshttpbinding? If not, how can I create web service on with authentication, server side on widows (C#), client side on iphone (monotouch)
Many thanks
Mono does not currently support WSHttpBinding, it is a work in progress, and the support is very spotty.
You can use plain SOAP over HTTPS (the web services stack from .NET 1.0 and .NET 2.0).
But since you are just getting started, you might as well use REST services with JSon or XML return values. Many folks are now using Json as the lingua-franca for this kind of connections, as it has the added advantage that you can use the same bridge to create HTML based apps as the Json output can be fed directly into your javascript on browsers.
For the server, you can use something like ServiceStack:
http://www.servicestack.net
For the client, you can either parse the Json manually using System.Json which is a very low-level and barebones stack, or you can use something like Newtonsoft's Json parser that comes with a full deserializer and object mapper.
In the newest build of Monotouch it does work. You need to generate a WCF class using the Silverlight 4.0 SDK which will be on your Windows PC if you have Visual Studio.
Here's what I use to generate my TimeSheet class (run in CMD shell in Windows):
slsvcutil.exe http://localhost/QQQQQ/Timesheet.svc?wsdl /namespace:"*,General" /d:z:\desktop /noConfig /ser:DataContractSerializer
Then copy this to your Monotouch project and call it like this:
BasicHttpBinding binding = new BasicHttpBinding (settings.WCFBasicHttpSecurityMode ());
var svc = new TimesheetServiceClient (binding, new EndpointAddress (settings.AddressServiceUrl ()));
Note that all the service calls are Async only. You need to subscribe to their event call backs like this:
svc.GetTimesheetsCompleted += GetTimeSheetsComplete;
I'm trying to implement WCF into MonoDroid, too. I think there's no big difference between it and MonoTouch. And after researching, I counldn't find the supoort for anyother WCF binding mode except BasicHttpBinding.
Honestly I'm not good that WCF at all, so I just tried ways randomly. I can get messages from server with string and byte[] and so on, but when i wanted to upload large data eg. image or audio, the uploaded message which includes big byte[] must be limited under 8192bytes. That causes my uploading into failure.
Now I must think other way to solve large file uploading from mobile phone.
And it's really a big pity and problem not to make all actions achieved totally inside WCF coding.
Hope Mono improve it. and if any help welcome and appreciated.
I suggest to create your web services with asp mvc and give as ouptut an XML file that you can parse with monotouch. you can atttack your webService created from the scratch using ASP ang get a stream XML
精彩评论