iOS Call WebService Grooming

Source: Internet
Author: User

Data address: http://blog.sina.com.cn/s/blog_a30ee5f701016yn3.html

Learn the iphone development for some time, for me this novice, learning process, encountered a lot of problems, especially webservice call has been plagued for a long time, in the eve of the singles, talk about the personal problems encountered in WebService and solutions ~ ~ To share with you, For those who can skip over ~ ~

Also do not know this is the first few Singles Day in life, no sister, very tangled, did not meet the person, in the love of the waiting gradually moldy ~~~~~~~~

Here also wish single men silver, female silver, in Singles Day Off "light" ~ ~ ~ ~ ~ ~ Cut to the point

First, brief

What do you think of calling WebService?

(1) Write a class that calls WebService (can be self-written or download a third-party class library)

(2) XML parsing of WebService returns (XML parsing from iOS is really annoying)

I am on the net Niang net, are to see some people, or only provide WebService class, simple explanation, for the return of the data XML, a word not to mention ~ ~ ~ with their written class to, really smoke AH ~ ~ ~ ~ ~ ~ ~ ~, I find some answers online, I feel very strange, Daniel often write a dubious words, to write to write clearly, otherwise simply do not write ~ ~ ~ Let people hope and disappointment ~ ~ I do not think that there are more bull B ... Instead, I prefer to simplify complicated events.

I personally encountered several problems when calling WebService:

A.webservice namespace issues?

WebService the default namespace is:http://tempuri.org/

I just started to use well, and later reported SOAPAction do not recognize http://tempuri.org/~~~~ Day spent a morning to find out this mistake, originally someone changed the default namespace of WebService ~ ~ ~ I went to your uncle's, changed the namespace, do not inform me, It's killing me to be blind ~

B.xml How to resolve the problem?

originally want to use the class of iOS to parse XML, on-line check, see others wrote a big, forehead a sweat, full face Black ~ ~ ~ ~ ~ ~, later I use is Google write Gdataxml this class library, also good ~ ~ ~, but for those XML has namespace of how to read, All kinds of jars to ask questions, so far no one has answered me correctly ~ ~ is no one in Celestial kingdom know? I was so disappointed that I was still like a god-clairvoyant ~ ~ ~ ~ ~ It has been settled, Amen ~ ~ ~

C. A 400 error occurred while calling asynchronously?

This problem made me, the mind garbled, the nerves are also the eggplant, you guess what is the reason ~ ~ ~

The message that soap intended to convey was this:

<a>XXX</a><b>XXXX</b>

I've reversed it and turned it into this:

<b>XXX</b><a>XXX</a>

After discovering the problem, I laughed like a fool ~ ~ ~

Ii. brief description of the class

(1) WebService (a class that is written using nsurlconnection, and a WebService call class that ASIHTTPRequest writes)

A. Synchronous invocation

B. Asynchronous invocation

C. Processing of returned data

The data returned by the SOAP call is often placed in the following: <webservice method name Result>xxx</webservice method name Result>, I have been directly extracted in the WebService call, ~ ~ ~ Extract the content is still an XML, the processing of this content, I write in the XML parsing class alone

(2) XML parsing class

1. Read the contents of the < Method name result>xxx</method name result>

2. Iterate through all the contents of the XML to return an array

Third, the use of configuration

(1) WebService call class with Nsurlconnection write, class name: WebServices.h

The following files are included:

Configuration of the A.appconfigure.h file:

The B.google Gdataxml is configured as follows:

Step1. Add Libxml2.dylib class Library First, do not tell me this is not, pull to Wall ~ ~ ~

Step2. Operation as shown

(2) with the help of ASIHTTPRequest write WebService call class, class named: ServiceHelper.h

As with (1) configuration, this is no longer repeated, asihttprequest to add a few more class libraries, as shown in

Iv. File Download

(1) All files of the WebService call class written by the Nsurlconnection class are downloaded

http://dl.vmall.com/c0cld6ey99 [Note: Please download the latest version of the demo, there are adjustments]

(2) All files of the WebService call class written by the ASIHTTPRequest class are downloaded

Http://dl.vmall.com/c0gx4evjva [Note: Please download the latest version of the demo, there are adjustments]

Five, demo download

   

DemoHttp://dl.vmall.com/c016bva6awFinally wish everyone ~ ~ ~ Happy ~~~~~ try to strip ~~~~~~~~~~~~~~~~

iOS Call WebService Grooming

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.