cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with odata consumption in MDK application 'could not find the service provider'

d_weinberg
Participant
0 Kudos

Hi experts,

I am fairly new to the topic of SAP MDK. Here ist what I am trying to achieve, what I tried so far and where I am stuck. I hope one of you could guide to the right direction.

Goal: I want to create a simple List-Details App showing me a list of objects retrieved via an OData service provided by SAP BusinessByDesign. The user should be able to select on of the objects (lets call those entity A) from the list and get to a details page from where he can press a button to create an instance of another entity (lets call this entity B). This is also to be done by an OData service provided by SAP Business ByDesign.

What I did so far:

  1. I testet that the OData services are fully functional. I am able to retrieve and create the respective entities. I verified this using Postman.
  2. I set up two mobile destinations (one for each odata service) in mobile service. Ping is working find and I can find live data using the test tool.
  3. I generated a new MDK application from a template in the SAP Business Application Studio. Retrieving data for entity A and navigating to the details (all generated) is working perfectly fine.
  4. I the added a second service to the application using 'MDK: New Service' and selected the mobile destination from step 2 for entity B. I enhance the app with a button on the details page of entity A, which navigates to page to enter some data, the user can now click on a button, which would trigger an OData action of type 'Create Entity' where I selected the EntitySet for entity B of the newly added service.

Issue:

Whenever I press the button that calls the OData action I get the error 'could not find the service provider'. Unfortunately, I am not able to find any help regardings this issue on the web. I also tried to add entity B to the same service as for entity A so I have only one mobile sevice destination and on service in my app, but then I am getting another error.

Just to be sure I am basically following the right path I did the same to create a new instance of entity A instead of and this work just fine.

Any help would be appreciated.

Thanks,

Daniel

Accepted Solutions (1)

Accepted Solutions (1)

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert

weinberg01

Assuming you are using both the services without offline (in .service, you have not enabled offline option)

When you deploy your metadata definitions(or any subsequent changes in your project) to mobile services, it gets deploy as a bundle to mobile services app update. When MDK client finds that there is a new metadata definitions available, then OnWillUpdate event is executed prompting user that a new version is found and ask if you want to apply it now or later. When you click "Now" (as per template generated project) in your MDK client, new metadata definitions are loaded and OnDidUpdate event is executed allowing the application to initialize (in your case - triggering InitializeOffline.action only)

OnLaunch event - is triggered when app is launched (when you provide your metadata as built-in your branded client) or when app is re-launched (swipe close the app and open it again).

If you have just accepted the new metadata definitions via OnDidUpdate, then your second service has not initialized yet because OnDidUpdate is not aware of it (assuming you didn't chain your InitializeServiceRequestService.action on success of InitializeOffline.action).

You can try either of below options:

  1. Swipe close your app/kill the app running in background and re-open it. This way, OnLaunch event will get triggered and your second service will be initialized. You should be able to make transaction against your second service OR
  2. Chain your InitializeServiceRequestService.action to success of InitializeOffline.action. Re-deploy and test it again.

d_weinberg
Participant
0 Kudos

Thank you for your help. This did the trick.

Answers (1)

Answers (1)

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

weinberg01

Error 'could not find the service provider' appears in the client because you have not initialized your 2nd service.

Similar to what is available for first service in your MDK metadata project in terms of OData initialize action for the service and how you are initialize it , you need to do the same for second service.

  • create an OData action of type Initialize (Action.Type.ODataService.Initialize) bind it to your second service
  • you may call this action at the success of OData Initialize action of your first service.

Regarding " also tried to add entity B to the same service as for entity A so I have only one mobile sevice destination and on service in my app, but then I am getting another error." , I am not sure what error you are seeing. If you can share more details that would be helpful to understand the problem.
I am assuming you did change in your backend adding entity B after creating an MDK project connecting to your service when entity B was not initially there. If so, you need to make sure to update the changes in your project (right click .service file > MDK: Sync service) so this way you'll have access to entity B via Object browser when binding to a target or control. You will also need to update defining request in Offline Initialization and Download actions (of course, if you have enabled offline in your service).

d_weinberg
Participant
0 Kudos

Hey Jitendra,

thanks for your help. Unfortunately, this does not help. I added an Initalize action and called it on App Launch. I still retrieve the same message.

What I understood from the documentation is that this is only required for offline usage. In deed I would be happy if it already works only online. Thus, I also tried to removed the services offline properpty without success.

Regarding your assumption, the service was already there but I synced it anyways, also without any positive impact.