cancel
Showing results for 
Search instead for 
Did you mean: 

web services with ipad

Former Member
0 Kudos

Hi I'm new to iphone development, I'm working in at view based app for ipad in which I need to get information from a web service the problem is that I don't know how to consume the Web Service from the app ....

Plzz help me with it

Thanks in advance

vinit sharma

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

a very simple way is to use WSDL2ObjC to create object classes accessing your web service to be used within your app:

[http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/803ae155-d81b-2e10-5c99-86f57900b083|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/803ae155-d81b-2e10-5c99-86f57900b083]

Cheers,

Christian

Former Member
0 Kudos

Awesome I am going to be trying this tonight! This is just what I have been waiting for!

Thanks a lot!!

vineet sharma

Former Member
0 Kudos

Feel free to get back to me if you have any questions or problems when trying it out...

Cheers,

Christian

Former Member
0 Kudos

Christian,

yours is a very good document, but i'm afraid i need at least a pound of cocoa to make it work in my environment. is there one location on the web that u keep your notes in?

Former Member
0 Kudos

Greg,

yes, for sure - some cocoa / objective-c basics are fundamental to create your first native iPhone app. I started with reading a comprehensive book, but there's a variety of good places in the web to get quick "crash courses" regarding the basics.

Drop over at these sites:

http://cocoadevcentral.com/articles/000081.php

http://cocoadevcentral.com/d/learn_objectivec/

http://cocoadevcentral.com/d/learn_cocoa/

http://cocoadevcentral.com/d/learn_cocoa_two/

...and:

http://www.cimgf.com/2008/10/01/cocoa-touch-tutorial-iphone-application-example/

http://www.iphonesdkarticles.com/

A really good source to get a solid ramp-up are apples original developer videos available at iTunes U or at http://developer.apple.com

I think you'll need to spend some minutes in giving yourself a brief introduction to iOS application development. No way to realize any apps without that. Enjoy!

Cheers,

Christian

Former Member
0 Kudos

Hi Christian,

Sorry for delay.. thank you very much for the help .

I am new in objective c i read the documents on the links which you shared . may i get some more examples on it??

in my application i did same as you suggested in the pdf . i made one cocoa application in which i made one group as Webservice within it i added all the classes(12 classes ) . now i just build it with out any changes but i got 304 errors in auto generated code some of which are given below.

1> Expected ')' before 'xmlNodePtr'

2> 'xmlNodePtr' undeclared

3> #import <libxml/xmlstring.h> no such file or directory

any many more errors are there in auto generated code

is there any other methods(besides WSDL2Objc) to consume web services in ipad or iphone ??

Thanks and regards

vinit sharma

Former Member
0 Kudos

Hello Christian,

now i am making window based application and i added all the things as per the documents . The good thing is that all the error has gone but still i couldn't get the response .

can you please check the following code .

- (void)callSOAP

{

Leave_rule_Binding *binding =[[Leave_rule_Binding alloc]initWithAddress:@"http://192.168.1.68:50000/Leave_rule_Service/Leave_rule_?wsdl"];

binding.logXMLInOut=YES;

Leave_rule_Service_GetApproverIds *request =[[Leave_rule_Service_GetApproverIds alloc]init];

request.designation=@"SE";

request.Department=@"NW";

request.MentorID=@"INC00199";

request.Team=@"Training";

Leave_rule_BindingResponse *response = [binding GetApproverIdsUsingParameters:request];

NSArray *responseBodyParts= response.bodyParts;

[binding release];

[request release];

for(id bodyPart in responseBodyParts)

{

if ([bodyPart isKindOfClass:[NSError class]]) {

// You can get the error like this:

NSLog(@"this is an error :%@",bodyPart);

continue;

}

if ([bodyPart isKindOfClass:[SOAPFault class]]) {

// You can get the error like this:

NSLog(@"this is a fault :%@",bodyPart);

continue;

}

if ([bodyPart isKindOfClass :[Leave_rule_Service_GetApproverIdsResponse Class]]) {

Leave_rule_Service_GetApproverIdsResponse *part=(Leave_rule_Service_GetApproverIdsResponse *)bodyPart;

NSLog(@" :%@",part.approver1EmailId); i am getting error like these fields are not in structure or in union

NSLog(@" :%@",part.approver1userid);

NSLog(@" :%@",part.approver2EmailId);

NSLog(@" :%@",part.approver2EmailId);

}

}

please suggest me what should i do

Thanks and Regards

vineet sharma

Former Member
0 Kudos

Hi,

please check if you don't have any namespace problems. Consider the log output in your console window. Do the element names match exatly to your object's attributes? If this is correct, XCode should provide code completion for the element names.

I'll try to help, but since objective-c is even hard to debug locally, it might get a bit tricky to solve such problems remote...

Let me know what your log output tells you...

Cheers,

Christian

Edited by: Christian Kloeppel on Feb 28, 2011 5:04 PM

Former Member
0 Kudos

Hi,

Thanks a lot for the reply

now i am getting the response from web service but still i have one problem that i am not able to pass parameter to the web service . my service is taking one string arguments like name (vineet) and the output is "the web service has consumed successfully by vineet". but here it is showing in the log "the web service has consumed successfully by null "

please check the following code .

#import "MywsdlAppDelegate.h"

#import "MyserviceWsdlService.h"

@implementation MywsdlAppDelegate

@synthesize window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Override point for customization after application launch

MyserviceWsdlBinding *bwsdl=[[MyserviceWsdlService MyserviceWsdlBinding]retain];

bwsdl.logXMLInOut=YES;

MyserviceWsdlService_wsdlOperation *WsdlRequest=[[MyserviceWsdlService_wsdlOperation new]autorelease];

WsdlRequest.name=@"vineet";

[bwsdl wsdlOperationAsyncUsingParameters:WsdlRequest delegate:self];

[window makeKeyAndVisible];

return YES;

}

- (void) operation:(MyserviceWsdlBindingOperation *)operation completedWithResponse:(MyserviceWsdlBindingResponse *)response

{

NSArray *responseBodyparts = response.bodyParts;

for(id bodyPart in responseBodyparts)

{

if([bodyPart isKindOfClass:[NSError class]]) {

NSLog(@"this is an error :%@", ((SOAPFault *)bodyPart).simpleFaultString);

return;

}

// Handle faults

if([bodyPart isKindOfClass:[SOAPFault class]]) {

NSLog(@"this is a fault :%@",((SOAPFault *)bodyPart).simpleFaultString);

return;

}

// Do something with the NSString* result

if ([bodyPart isKindOfClass: [MyserviceWsdlService_wsdlOperationResponse class]]) {

MyserviceWsdlService_wsdlOperationResponse body =(MyserviceWsdlService_wsdlOperationResponse)bodyPart;

NSLog(@"the return is :%@",body.return_);

}

}

}

- (void)dealloc {

[window release];

[super dealloc];

}

Output in the log file is given below

[Session started at 2011-02-28 23:31:45 -0800.]

2011-02-28 23:32:03.535 Mywsdl[1454:207] OutputHeaders:

{

"Content-Length" = 498;

"Content-Type" = "text/xml; charset=utf-8";

Host = "192.168.1.68";

Soapaction = "";

"User-Agent" = wsdl2objc;

}

2011-02-28 23:32:03.548 Mywsdl[1454:207] OutputBody:

<?xml version="1.0"?>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:MyserviceWsdlService="http://model/" xsl:version="1.0">

<soap:Body>

<MyserviceWsdlService:wsdlOperation>

<MyserviceWsdlService:name>vineet</MyserviceWsdlService:name>

</MyserviceWsdlService:wsdlOperation>

</soap:Body>

</soap:Envelope>

2011-02-28 23:32:06.666 Mywsdl[1454:207] ResponseStatus: 200

2011-02-28 23:32:06.671 Mywsdl[1454:207] ResponseHeaders:

{

"Content-Encoding" = gzip;

"Content-Type" = "text/xml; charset=utf-8";

Date = "Tue, 01 Mar 2011 13:34:26 GMT";

Server = "SAP NetWeaver Application Server 7.20 / AS Java 7.20";

"Set-Cookie" = "saplb_*=(J2EE2304020)2304050; Version=1; Path=/";

"Transfer-Encoding" = Identity;

}

2011-02-28 23:32:06.674 Mywsdl[1454:207] ResponseBody:

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><ns2:wsdlOperationResponse xmlns:ns2='http://model/'><return>Web service has successfully consumed by null</return></ns2:wsdlOperationResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

2011-02-28 23:32:06.677 Mywsdl[1454:207] the return is :Web service has successfully consumed by null

thanks and regards

vineet sharma

Former Member
0 Kudos

Hi Vineet,

since your name is placed correctly in the <MyserviceWsdlService:name>-element, i would assume that the problem is on side of your web service. Between sending the request (which seems to be correct) and getting the response - there's nothing that could go wrong in your app.

Maybe the element name <MyserviceWsdlService:name> is not what your web service expects. Try playing around with the namespace-prefix there (use just <name> instead), but usually - if this would be the problem - the SOAP service should give you an appropriate error code & feedback...

My tip: the problem is on the web service's side.

Cheers,

Christian

(Sorry for answering late, too much work...)

Former Member
0 Kudos

Hi Christian,

Sorry for disturb you again and i am really thankful for your help

i have checked my service in local server (in WSNAVIGATOR) where it is working fine. can you please tell me from where i have to taken WSDL ? because i think i might be wrong here.i open XML and save it as .wsdl or i have take it from /nwa/ ssadmin (from here i can download wsdl)

Thanks and Regards

vineet sharma

Former Member
0 Kudos

Hi Christian,

I have also used SOAPUI as you suggested in the document where i am getting required response but still in log file i am getting following response . I am not able to understand what should i do from now

output in log file is given below

[Session started at 2011-03-08 03:54:37 -0800.]

2011-03-08 03:55:10.623 BackEndCall[2102:207] OutputHeaders:

{

"Content-Length" = 498;

"Content-Type" = "text/xml; charset=utf-8";

Host = "192.168.1.68";

Soapaction = "";

"User-Agent" = wsdl2objc;

}

2011-03-08 03:55:10.634 BackEndCall[2102:207] OutputBody:

<?xml version="1.0"?>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:MyserviceWsdlService="http://model/" xsl:version="1.0">

<soap:Body>

<MyserviceWsdlService:wsdlOperation>

<MyserviceWsdlService:name>vineet</MyserviceWsdlService:name> (please check it i am passing a string as parameter to my service)

</MyserviceWsdlService:wsdlOperation>

</soap:Body>

</soap:Envelope>

2011-03-08 03:55:14.115 BackEndCall[2102:207] ResponseStatus: 200

2011-03-08 03:55:14.119 BackEndCall[2102:207] ResponseHeaders:

{

"Content-Encoding" = gzip;

"Content-Type" = "text/xml; charset=utf-8";

Date = "Tue, 08 Mar 2011 11:55:02 GMT";

Server = "SAP NetWeaver Application Server 7.20 / AS Java 7.20";

"Set-Cookie" = "saplb_*=(J2EE2304020)2304050; Version=1; Path=/";

"Transfer-Encoding" = Identity;

}

2011-03-08 03:55:14.123 BackEndCall[2102:207] ResponseBody:

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><ns2:wsdlOperationResponse xmlns:ns2='http://model/'><return>Web service has successfully consumed by null</return></ns2:wsdlOperationResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

2011-03-08 03:55:14.126 BackEndCall[2102:207] the return is :Web service has successfully consumed by null

But it should return as Web service has successfully consumed by vineet

Please help me

Thanks and Regards

vineet sharma

Manjunath
Product and Topic Expert
Product and Topic Expert
0 Kudos
Former Member
0 Kudos

Thanks manju

but i am not able to view both the links

what should i do??

again thanks a lot for sharing the links

vineet sharma

Edited by: vineet.sharma on Feb 23, 2011 12:52 PM

Manjunath
Product and Topic Expert
Product and Topic Expert
0 Kudos

Look at this thread https://cw.sdn.sap.com/cw/docs/DOC-120422

Thanks

Manju