I am curious and interested in the mobile platform, and recently started to develop and learn iPhone. The learning path is from objective-C to cococa. The method is to read two English documents for getting started, and to learn about the apple SDK. The basic idea of the product is to use. net on the server and iPhone on the mobile client.
Some complex logic processing is implemented on the server. The client interacts with the server through XML and parses XML on the iPhone client to display data through cocoa. Because iPhone and donet are two completely different platforms. The iPhone depends on the Mac system platform and donet depends on the Windows system platform. In this article, I will use a hello World Program to describe cross-platform calls from Mac to Windows through WCF.
1. Create a simple WCF Service
The Service Contract Code is as follows:
The implementation is as follows:
2. call WCF in iPhone
Unlike how donet calls the WCF Service, nsurlconnection is used to obtain data from the WCF server. The Code is as follows:
Nsurlconnection delegation method:
The delegate Method for parsing Hello world in XML. For Objective-C parsing XML, you can view my previous blog:
Run:
Summary:This article uses a simple example to illustrate how the iPhone calls WCF. It is quite easy to implement cross-platform with WCF!
Code:
WCF code: http://files.cnblogs.com/zhuqil/WcfService1.rar
Cocoa code: http://files.cnblogs.com/zhuqil/wcf2.zip