This tutorial was contributed by Dave (AKA Clarke76) on the Forums.
WebSite: http://viium.com
-Main project on site is eDuo. A .Net app that connects to OWA Exchange and forwards to IMAP account. Free program for those who can’t use Active Sync
Important Links:
[WebService] http://viium.com/WebService/HelloWorld.asmx
http://developer.apple.com/documentation/Cocoa/Conceptual/XMLParsing/XMLParsing.html
http://www.w3schools.com/soap/default.asp
-After creating our XML data / SOAP request, we create a URLRequest. We add HTTP Header values, those values you read from the WebService.
-We set the HTTP Method to POST
-We set out HTTP Body to the xml file we created
-We then create our connection, using the request we just setup.
-Once the connection is setup and delegate is set to self, we need to setup out connection delegate methods.
-The first method just makes sure it can make a connection. If it can, we make sure we have no data in our Data set so we clear it.
-Second method is called when re receive any data. If we do receive data, we just append it to our data set.
-Third Method handles any errors and releases our data and connection if an error occurs.
-Fourth Method: We take the data and create a string for Logging reasons, then release the string.
-We check to make sure an instance of xmlParser does not exist, if it does we release it.
-Create a new instance of xmlParser, set the delegate to self, want to resolve external entities, and start our parsing.
-release our connection and Data
Now we need to our our delegate methods for NSXMLParser
First method we are check the start of elements. If our element equals “HelloResult” we set our BOOL to true. Second method records any data between an element if our BOOL is set to true. Third method checks for our closing element. Once found sets our greeting, releases our MutableString, and set our BOOL back to false.
If you have any questions or comments, please leave them in the comments of this post. You can download the sample code here.






84 Comments
It seems that the video isnt working? Is there something wrong on my end?
video needs Quick time player.
I have created some wrapper classes and an objective C .NET dataset object class to easily incorporate passing datasets to your iphone app check it out!
http://grabalife.com/2009/10/19/using-net-web-services-and-dataset-objects-in-your-iphone-app/
Really helpful to me.
This is what I was looking for..
Thanks a lot…
Now I am trying to put data in the tableview..
I’ve tried to put this example in a class to do a login via web service. I get my user id and password from the NSUserDefaults. I build the SOAP envelope and get my validated userId back in the web service…that works!!!
In the parser didEndElement method I have the value I want (userId) in soapResults and am setting it like this:
myUserId = [[NSString alloc] initWithString:soapResults];
I have this as a property in the class .h file as:
@property(nonatomic, retain) NSString *myUserId;
I’d like to be able access that value by my view controller class that creates the instance to use the web service as:
LoginWebService *loginWebService = [[LoginWebService alloc] init];
[loginWebService logUserIn];
Right now it returns void and I try to get the value from the myUserId property. This does not work.
I also tried returning a string from the logUserIn method where the SOAP message is defined…again no luck.
I apologize if I’m missing something obvious…I’m coming from the .Net world and trying to pick this stuff up.
Please provide some help or an example of wrapping your code into a class that can return a value as a result of the web service having been contacted, parsed and return a string to the instantiating class (in my case a userId). Any help would be appreciated, my head is a bloody stump from beating it against my Mac Book.
Thanks in advance.
my webservice is returning array and it shows #[] only if I am returning string from service it is shown properly. what needs to be done to get response array in client from server.
Hi John, Please could you provide the code, so access to access a login web service.
I am having a login web service, but still i did not get how to pass paramters like username and password to the web service.and also how to capture the results in the application.
Please help.. I am very new to iphone application development.
Hello thank you for taking the time to
create this tutorial it helped me alot.
I am having one problem, getting an
error when trying to access the webservice
asmx file through the internet. When I try and
access it via the internet I get an
xml parsing error. When I right click
the file and select view in browser it opens
fine on the server. When I try and
open the file on the server through
port 8000 the port I am using for incoming
internet connections I get the same error.
What am I doing wrong?
Nice tutorial. Thanks.
John,
Maybe I’m misreading your post, but I don’t see where you are making the value of “myUserID” externally visible. What does your “logUserIn” method look like? Are you synthesizing the getter/setter for “myUserID?”
Gr8 Tutorial
Thanks !!!!!!!
It is working gr8 for .asmx service BUT not working while dealing with WSDL web service.
I am getting following error …
Error Code: 407 Proxy Authentication Required. The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. (12209)
Plz Help
Excellent blog, i like it. I should just give up and take lessons from you
Thanks for the great tutorial.
When i create my simple helloworld web service hosted by IIS on a local machine, my response from my IMAC is ZERO bytes, may I know what is the problem?
Has it got to do with the hosting of the web service?
I am able to see the operations page on Safari from the IMAC, hence connection should be fine.
Thank you for any help.
Gr8 Tutorial
Thanks alot…
Can i expect any clue or tutorial to connect database related Webservice which returns Datatable/Dataset.
Thanks in Advance…
I used ur code pretty much exactly in my project,just with some minor modifications, i just want to know if i have to put a copyright notice u might have made before i submit the application?
good tutorial…thanks!
Great entry point into WS communication from iPhone! Works for WSDLs without any problems! Thanks a lot!
Thank you for the great tutorial. I have one question though. In the example given you pass a string value ‘nameInput.Text’ to the NSString. However, how would one go about adding a boolean value to the NSString? I need to tell the Web Service whether I want the result back compressed or not. And I would like to set it to false.
Thank’s so much!
I lately came across your blog and have been reading along. I thought I would leave my first remark. I don’t know what to say except that I have loved reading. Respectable blog. I will keep visiting this blog very often.
Hey, Good evening it´s just i do totally dig Your blog, I wuold enjoy to blog a teaser on your incredible wordpress blog on my silly Apple iPad Website http://www.soulcast.com/ipadnewssvcip/rss would you grant me permission? XoX, Hortensia Batterton
Just wanted to thank you for this amazing video, it’s just suddenly made everything crystal clear! Thank you so much for sharing your knowledge.
Hi All,
This is a fantastic article. Thank you so much!
I have a question: How would someone handle self signed or invalid SSL certificates in the context of this code?
I’ve seen some people use;
@implementation NSURLRequest(DataController)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
return YES; // Or whatever logic
}
@end
which is dangerous. I was wondering if there’s a way to pop up a accept or decline before posting? Right now, this code simply refuses the connection.
Thanks!
OK im using this parser to grab my data from the net but how would i go about implementing a thread to call these functions, ive created a thread but after i call the first portion of the code and it creates the soap message it never goes past this function, How should i go about this cause i need to run my parsing in the background instead of on the main thread.
hi,thanks for this great tutrorial..
i m just getting one prob
Fatal error: Out of memory (allocated 524288) (tried to allocate 393216 bytes) in D:\xampp\htdocs\realify\start.php on line 1025
and i dont know how to get rid of it.
can u suggest something to resolve this one
regards
bobby
solved…..
Hi,
Im having a little problem with the source code I downloaded from this site. This is the error message im seeing:
: error: CFBundleIdentifier ‘com.yourcompany.Hello_SOAP’ contains illegal character ‘_’
where do I find this CFBundleIdentifier?? And how do I solve this problem?
Many thanks!
I need a project realy run online sour its rource code! thanks
I need a project realy run online sour its rource code of example get data from wsdl on iphone! thanks!
Hey, This is a great tutorial.. Thanks so much. I was wondering if your webservice site for this tutorial is working or because i don’t the result when i run the application.
Hi,
Can any one help me how to write a soap request which returns the xml contains the data ?
Regards,
Abhilash
Hi,
Its really interesting information you have posted here I clear few doubts from this information thanks for sharing here
Thanks
Excellent, thank you for putting this walkthrough together.
Hi,
this was exactly what we needed for our iPad app.
Thanks a lot.
5 Trackbacks
[...] SOAP is niet meer dan een http post geformateerd in XML dus je kunt het gewoon doen met NSURLConnection. Nadeel is natuurlijk dat je geformateerde XML zelf moet maken ipv dat je deze uitleest uit de WSDL. Hier heb je een tutorial die voor mij werkte: iCodeBlog Blog Archive iPhone Programming Tutorial – Intro to SOAP Web Services [...]
[...] with the iPhone that I was at a total loss where to start. I began eyeing Dave’s tutorial on SOAP Web Services, but that just freaked me out a little too much. I needed something laid out simply first before I [...]
[...] iCodeBlog » Blog Archive » iPhone Programming Tutorial – Intro to … [...]
[...] the data on air, i totally got insane . If you want to know how bad is, try to visit these site : iPhone Programming Tutorial : Intro To Soap Web Services (or Turkish version : iPhone ile Web Service [...]
[...] te krijgen en dit weer te geven in een App. Hiervoor heb ik de volgende tutorial gebruikt: iPhone Programming Tutorial – Intro to SOAP Web Services | iCodeBlog en daar ergens wordt het opgeslagen vanuit een NSMutableString. Als ik hier NSMutableArray ofzo [...]