cancel
Showing results for 
Search instead for 
Did you mean: 

implementing Rest/JSON Webservice

tahir_z
Contributor
0 Kudos

Hello,

I'm developing an app in iphone and want to use JSON webservice. Can anyone please guide me how to use json format with abap webservices or any document suggesting?

Thanks in Advance

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi oztahir,

Please read my post on [SAPDEV|http://www.sapdev.nl] to see how I did it. I used ASIHTTPRequest for communication with the JSON web service and KissXML to pase the XML.

Cheers,

Raymond

tahir_z
Contributor
0 Kudos

Hi Raymond,

It is what i am looking for and excellent blog thank you, could you provide sample ?

Thanx in Advance

Tahir

Former Member
0 Kudos

Hi Tahir,

First create a web service in SAP. The blog by Uwe Kunath descibes this clearly. Then create an Xcode project and use the ASIHTTPRequest wrapper to connect to the web service. Parse the response with the KissXML parser. A more out of the box solution is NetWeaver Gateway. It also let you use SAP web services but it also generates iOs code for you. SAP just released a trial version in de download section.

Example of ASIHTTPRequest


- (void)getFlightData:(NSString *) selectedDate {
	
	NSURL *url = [NSURL URLWithString:@"http://abap.sapdev.nl:8000/sap/resources/flights/from/%/to/%/date/20110128?sap-client=001"];
	ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
	[request setUsername:@"BCUSER"];
	[request setPassword:@"minisap"];
	[request startSynchronous];
	NSError *error = [request error];
	if (!error) {
		NSString *response = [request responseString];
		[self parseXML:response];
	}
}

Example of KissXML


-(void)parseXML:(NSString*)source {
	
	NSError *error = nil;
	DDXMLDocument *theDocument = [[DDXMLDocument alloc] initWithXMLString:source options:0 error:&error];
	NSArray *results = [theDocument nodesForXPath:@"/asx:abap/asx:values/TAB/BAPISFLDAT" error:&error];
	
	for (DDXMLElement *flightdetail in results) {
		
		NSString *airlineid =   [[flightdetail elementForName:@"AIRLINEID"] stringValue];
		NSString *airline =     [[flightdetail elementForName:@"AIRLINE"] stringValue];

	}
}

tahir_z
Contributor
0 Kudos

Hi Raymond,

Thank you for your help.

Regards