cancel
Showing results for 
Search instead for 
Did you mean: 

Consume oData services via SUP for iOS application .

Former Member
0 Kudos

Hi All ,

We have SAP NW gateway setup at our end .We have cracked the part of consuming odata services exposed by GW directly in iOS app using sap nw dev tool for xcode .

we want to know how to consume these services via SUP.what is the configuration to be done at sup level ( project ) ,  changes to be done on front end side .Developer guide for odata sdk 2.1.2 gives you an overview of the configuration to be done .Methods are listed but there is no clarity what is to be done where .

It would be great to find in depth documentation with code sample ( tutorial ) .

Thanks ,

Amit Nalawade.

Accepted Solutions (1)

Accepted Solutions (1)

guy_soffer
Employee
Employee
0 Kudos

Hi Amit,

Regarding the generated proxy or starter kit that you got from the tool, the code already handles SUP connectivity for you. You need to add the respective iOS library that comes with SUP to your project and un-comment some code lines. Refer to the following sections in the documentation for more detailed steps:

  • Working with SUP Server Using Generated Proxy
  • Configuring a Starter Kit Application to Work with SUP

For SUP configuration, checkout this blog post under CONFIGURE SUP section. Basically you need to add a new application configuration, configure the URL to the Gateway service and attach a security configuration.

Thanks,

Guy

Former Member
0 Kudos

Hi Guy ,

Thanks for the information .

When going via SUP we do not have to do any configuration at workspace ( unwired platform ) level ?

Also as the document mentions configuration to be done on SCC , we have to register an application connection and enter app endpt gateway url in proxy settings .

What is the application id to be specified while registering , since we have not deployed anything to sup server .

guy_soffer
Employee
Employee
0 Kudos

Hi Amit,

I'm not aware of any workspace configurations you need to do. Basically you configure SCC and then use these settings in the generated app (App ID, Security Configuration, SUP Host/Port/Farm...).

When you register your application on SCC, you can set the App ID to any string you like.

Former Member
0 Kudos

Hi Guy ,

I have setup the generated project by nw tool to consume my service via sup as per the documentation shared by you .

I am trying to login with Gateway credentials / sup credentials but i am getting login failed error .

Exact error from console :-

With Gateway Credentials :-

MessagingClientException:/Location:-[LiteSUPUserManager registerUser:withSecurityConfig:withPassword:] + 349

2012-10-30 14:27:46.020 odatanew[38599:4c0b] MMS Authentication Failed

With Sup Credentials :-

2012-10-30 14:40:50.648 odatanew[38769:1d03] Error getting service document. Login failed.

Any idea on this front ?

Thanks ,

Amit .

Message was edited by: Amit Nalawade

guy_soffer
Employee
Employee
0 Kudos

Hi Amit,

The tool's generated code supports only auto-registration for SUP user. That means you shouldn't use a user which is already defined in SUP. When the code will execute, this user will be automatically created on SUP. On any code change which involves SUP, reset the simulator (Reset Content and Settings) cause the SUP code has persistence.

Try with a simple Security Configuration of type HttpAuthenticaionLoginModule and set there the URL to your Gateway service (same URL you used for the app definition in Proxy Settings). At runtime, use only the Gateway username and password.

Former Member
0 Kudos

Hi Guy ,

Thanks a lot for your support . I was able to sort out the issue

Just for information sake , what role does SUP play here :-

1. Does it persist data .

2. How does it handle request to and from gateway/device .

3. SUP Role in this architecture .

guy_soffer
Employee
Employee
0 Kudos

Hi Amit,

Nice to hear that it eventually worked for you!

Regarding your questions:

  1. SUP Server doesn't persist data.
  2. SUP has trusted connection with Gateway. The security mechanism can be configured per service or app. The request/response to and from Gateway are standard HTTP calls.
  3. The main features you get when you involve SUP for iOS apps in this architecture are:
    • Externally Exposing corporate internal business data (through Gateway) in a secured manner. That means that iPhones do not need to connect through corporate WiFi or VPN to get data.
    • Support for push notification.

Thanks,

Guy

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Guy ,

I am Working on CUD operations using oData-SAP NW Gateway .

I am adopting below style of coding from sample code to create records using my service .

Creating New Instance and setting params :-

Booking *newBooking = [[Booking alloc] init];

newBooking.carrid = @"<carrier_ID>";

newBooking.PASSNAME = @"<passenger_name>";

Flight *associatedFlight = [[Flight alloc] init];

associatedFlight.connid = @"<flight_number>";

associatedFlight.carrid = @"<carrier_ID>";

newBooking.bookedFlight = [NSMutableArray arrayWithObject:associatedFlight];

Fetching CSRF cookie :-

NSError *error = nil;

NSString *xml = [service getXMLForCreateRequest:newBooking error:&error];

CSRFData *csrf = [connectivityHelper getCSRFDataForServiceQuery:service.serviceDocumentQuery];

if (csrf) {

id<SDMRequesting> request = [connectivityHelper executeCreateSyncRequestWithQuery:

service.bookingCollectionQuery andBody:xml andCSRFData:csrf];

newBooking = [Booking parseBookingEntryWithData:request.responseData error:&error];

}

I am able to fetch csrf cookie and there are no errors thrown during execution of above code for my service , but i cannot see any records getting created .

What am i missing here , does the order in which we set params matter ?

Thanks ,

Amit Nalawade.

guy_soffer
Employee
Employee
0 Kudos

Hi Amit,

The sample code you've included is an example of Deep Insert. This means that you create Booking and Flight items in one call. This functionality should be supported by your service, else it won't work. So first check that.

When you're saying that you can't see any records created, do you mean that you checked them on the backend system? I'm asking in order to understand whether it's a client issue and not server.

 

Try to debug the code and check what do you get in request.responseData. Note that some services do not return the newly created item when you execute create operation but the record is created on the backend system.

 

In addition, try to test the service using a REST client and mimic your call (you would need to set the CSRF token and the XML itself).

Thanks,

Guy

Former Member
0 Kudos

Thanks Guy for quick reply .

I was able to get through create part .

While updating an existing entry i am getting below messages in the logs .

ERROR :: 405:Method Not Allowed/Location:-[SUPRequest startSynchronous]

ERROR: Exception during parsing response data. Error: The document is not a valid data document File .

The specified HTTP method is not allowed for the resource identified by the Data Service Request

Do we have to call a read explicitly before updating any entry .

Thanks ,

Amit Nalawade.

guy_soffer
Employee
Employee
0 Kudos

Hi Amit,

405 is a server error. Try to check the logs on the Gateway system to understand why your request was rejected.

Former Member
0 Kudos

hello guy..

I am able to consume OData services without SUP.Now i am trying to consume OData via SUP, I followed all the above suggestion and done the required configuration in SCC.I can see my device registered in the SCC. But I am facing the following error after login in.

2012-12-10 15:03:06.756 profitabilityanalysis[77425:1e03] ERROR :: 71002:*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array/Location:-[SUPRequest startSynchronous] + 1222

2012-12-10 15:03:06.762 profitabilityanalysis[77425:1e03] Error getting service document. Login failed.

Former Member
0 Kudos

Reset your simulator and try again.Should Work .

Former Member
0 Kudos

Thanks Amit for your response

I have done that yet no success.

guy_soffer
Employee
Employee
0 Kudos

Hi,

Are there any additional iOS logs? You can also check the logs on SCC. Try first to reset content of the simulator and test again. Did you configure basic authentication as the security configuration? Are you using the same username/password for GW and SUP?

Thanks,

Guy

Former Member
0 Kudos

Hi,

I am facing the same issue. I have an app which works correctly using the SAP Net weaver Gateway and now i am trying to get the app to work through SUP.

I followed the blog http://scn.sap.com/community/icc/blog/2012/01/16/developing-mobile-apps-with-sybase-unwired-platform... but was no success.

I am curious about how the SUP server authenticates to Gateway System.

Here are the couple of lines of the log i get in xcode. "Man" is my security configuration and it seems like the username and password was not propagated.

2013-02-28 15:36:45.761 testingsup[6683:1d603] ERROR :: 1053:Error: 401 Message: MessageChannel error [Login Failed: user '(null)@Man']/Location:-[SUPRequest startSynchronous] + 1085

2013-02-28 15:36:45.761 testingsup[6683:1d603] Error getting service document. Login failed.

I used the  HTTPAuthenticationLoginModule but it doesn't have an option to pass the username and password to SAP gateway. ( I did try the NoSecLoginModule and it didnt work as well)

Then i navigated to the connections in SCC and when i try to ping to my service doc url i get an Endpoint test result: Unauthorized. I put the a valid pair of username and password and tried again and it was the same which is quite strange.

Any help would be greatly appreciated.

Thanks,

Yohan

Former Member
0 Kudos

Hi Yohan

Did you get any information on it?

Regards

Pankaj Gupta