what is the procedure of performing wsdl parsing in iphone? - iphone

i have performed like this Is there any thing wrong performed by me?
NSURL *url = [NSURL URLWithString:#"http://111.111.111.111/BattleEmpire.Service/ApplicationService.svc?wsdl"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest setHTTPMethod:#"GET"];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection)
{
webData = [[NSMutableData data] retain];
NSLog( #"connection established");
}
else {
NSLog(#"theConnection is NULL");
}

For the parsing of the WSDL web service Referrer this site:http://sudzc.com/Default.aspx
It also provides Video how to parse such kind of Web Service.It's really helpful and so simple to implement..

Related

How to create NameValuePair list in ios 6

I am new in ios. I am working in a application in which i need to post some data in nameValuepair so I used NSDictionary to crate a name value pair but with NSDictionary there is issue on server side to parse posted data. Is there any way to create NameValuePair in iOS 6 like in android there is a entity called BasicNameValuePair .
You can use this code,
NSURL *Url = [NSURL URLWithString:#"http://yourURLaddress"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:Url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
NSURLConnection *MyConnection= [[NSURLConnection alloc] initWithRequest:request
delegate:self];
[request setHTTPMethod:#"POST"];
NSString *postString = #"id=2315645&name=Ram&deviceId=3453564666643634";
[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
[MyConnection start];

Is it necessary to create soap message when using ASIFormDataRequest/ASIHTTPRequest?

I used NSURLConnection to communicate with Soap webservice and it worked fine.
Now I am using ASIFormDataRequest and I am not getting is it necessary to create soap message for that? and I am not aware what is SoapAction.
Here is the code I am using
NSURL *url = [NSURL URLWithString:#"http://SERVERNAME.com/WEBSERVICENAME"];
[self setFrmdataReq:[ASIFormDataRequest requestWithURL:url]];
[frmdataReq setRequestMethod:#"POST"];
[frmdataReq addRequestHeader:#"Content-Type" value:#"text/xml; charset=utf-8"];
[frmdataReq setPostValue:txtField.text forKey:#"city"];
[frmdataReq setDelegate:self];
[frmdataReq setDidFinishSelector:#selector(requestFinished:)];
[frmdataReq setDidFailSelector:#selector(requestFailed:)];
[frmdataReq startSynchronous];
UPDATE
Soap Message I used,
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
NSString *soapMessage = [NSString stringWithFormat:#"<?xml version=\"1.0\" encoding=\"utf-8\"?>\
<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">\
<soap12:Body>\
<getCityTime xmlns=\"http://www.Nanonull.com/TimeService/\">\
<city>%#</city>\
</getCityTime>\
</soap12:Body>\
</soap12:Envelope>",txtField.text];
NSString *msgLength = [NSString stringWithFormat:#"%d",[soapMessage length]];
[request addValue:#"text/xml" forHTTPHeaderField:#"Content-Type"];
[request addValue:msgLength forHTTPHeaderField:#"Content-Length"];
[request setHTTPMethod:#"POST"];
[request setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if(conn)
{
responseData = [[NSMutableData data]retain];
NSLog(#"connection successful");
}
else
NSLog(#"connection fail.");
I didn't defined SOAPAction as I don't know anything about that.
When using ASIHTTPRequest, you need to create the SOAP request in basically the same way as you do with NSURLConnection.
The setPostValue call in ASIHTTPRequest is for create HTTP POST requests in the same format use for POST <form> tags in HTML.
For comparing ASIHTTPRequest / NSURLConnection, see things like:
ASIHTTPRequest vs NSURLConnection
and "What is ASIHTTPRequest?" on:
http://allseeing-i.com/ASIHTTPRequest/

get image from https url+iphone

i want to get the image from https url in iphone:-
The url is like this:-
https://staging.api.botentekoop.nl/image.ashx?ID=804306&imagesize=Normal&imagetype=MainImage
i had done some google work and found the help from this link:-
http://www.iphonedevsdk.com/forum/iphone-sdk-development/5511-load-image-internet.html
http://www.iphonedevsdk.com/forum/iphone-sdk-development/80894-load-image-url.html
But there all example is shown for http not from https
CAn anyone help me.
please how to do this
The URL Loading System on iOS works the same for HTTP and HTTPS URLs. Any example you find that works for an HTTP URL should also work for HTTPS.
you can use ASIHTTPRequest framework
thanks for the reply......
i got the solution.
i had done in this way:-
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:strURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[[NSURL URLWithString:strURL] host]];
// [theRequest addValue:#"application/x-www-form-urlencoded" forHTTPHeaderField:#"Content-Type"];
// [theRequest setHTTPMethod:#"GET"];
NSURLConnection *theConnection = [[[NSURLConnection alloc] initWithRequest:theRequest delegate:self] autorelease];
if(theConnection) {
self.activeDownload = [[NSMutableData data] retain];
}
else {
NSLog(#"theConnection is NULL");
}

how to send a word/text to a php file from iphone application

I am trying to send a word/text from my iphone application to php page, any idea?
You might do it with an asynchronous call.
// Prepare the URL
NSString myWord = #"YOUR_WORD";
NSString *urlString = [NSString stringWithFormat:#"http://<YOUR_DOMAIN>/<YOUR_FILE>.php?word=%#", myWord];
NSURL *url = [NSURL URLWithString:urlString];
// Get the data from the URL
NSURLRequest *request = [[NSURLRequest alloc] initWithURL: url];
// If you want to get an answer from this call then send "self" as delegate
// (and implement few NSURLConnectionDelegate methods),
// otherwise send "nil".
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection release];
[request release];
You might also send the word synchronously:
// Prepare the URL
NSString myWord = #"YOUR_WORD";
NSString *urlString = [NSString stringWithFormat:#"http://<YOUR_DOMAIN>/<YOUR_FILE>.php?word=%#", myWord];
// Get the data from the URL
NSError *error;
NSData *aData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:urlString] options:2 error:&error];
You would just have to load the URL with the word / text as a parameter using NSURLConnection. See the following for help in using NSURLConnection:
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html#//apple_ref/doc/uid/20001836
And, some sample code:
// The word
NSString wrd = [NSString stringWithString:#"hello"];
// Create the request.
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://www.yourdomain.com/thepage.php?word=#%", wrd]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
// Create the NSMutableData to hold the received data.
// receivedData is an instance variable declared elsewhere.
receivedData = [[NSMutableData data] retain];
} else {
// Inform the user that the connection failed.
}

sending XML file from IPhone to a server using Post Method

I am trying to send the data to server from my Iphone client. It works fine for most values but when itry to send a string like "IPhone+Cocoa" the server shows the string as "IPhone Cocoa". I have tried to google it but without success is there any why of doing it.
Here is my code
-(void)sendRequest:(NSString *)aRequest
{
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:kURLRequest]];
NSString *httpBody = [NSString stringWithFormat:#"%#=%#",[requestString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[aRequest stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSData *aData = [httpBody dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:aData];
[request setHTTPMethod:#"POST"];
self.feedURLConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
}
Can anyone help me?
You do this for requestString and aRequest,but not after formatting together with your addition..
Try
httpBody = [httpBody stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
before
NSData *aData = [httpBody dataUsingEncoding:NSUTF8StringEncoding];