Backendless Support
 
Solved

Custom Business Logic invoke by iOS always fails

Hi,

today I was trying to port my services from Backendless 3 to Backendless 4. Unfortunately I cannot make them works when called by the iOS app.

When I try to call them through the debug console all work fine.

Here are the two services basic implementation in the Java code deployed into the BE:

  1. public String sayHello(String name) {
  2. return "Hello " + name;
  3. }

and the second one:

  1. public boolean addDiscoteca(Discoteca discoteca) {
  2. Discoteca discotecaFromDB = getDiscotecaWithFacebookId(discoteca.getFacebookId());
  3. if (discotecaFromDB == null) {
  4. Backendless.Persistence.of(Discoteca.class).save(discoteca);
  5. }
  6. return discotecaFromDB == null;
  7. }

And here's how I invoke these services in my app:

  1. let name: String = "Matteo"
  2. backendless?.customService.invoke("DiscotecaServices", serviceVersion: "0.0.0__debug", method: "sayHello", args: [name], response: { result in
  3. completion?(nil)
  4. }, error: { fault in
  5. completion?(fault)
  6. })

  1. let discoteca = Discoteca()
  2. discoteca.name = "Fabric"
  3. backendless?.customService.invoke("DiscotecaServices", serviceVersion: "0.0.0__debug", method: "addDiscoteca", args: [discoteca], response: { result in
  4. completion?(nil)
  5. }, error: { fault in
  6. completion?(fault)
  7. })

For the sayHello service I received this error message:

  1. \'Server.Processing\' [java.lang.ClassCastException@6afe0992] <java.lang.ClassCastException@6afe0992> )

For the addDiscoteca service I received this one:

  1. \'Server.Processing\' [java.lang.ClassCastException@5070840b] <java.lang.ClassCastException@5070840b>

For both the services CodeRunner doesn't starts because these exceptions are raised before the Java methods take place.

Where am I wrong?

Leave a Comment

Comments (9)

photo
1

Hi Matteo,

if a service is deployed to Backendless, then the version number of the service should not have the "__debug" notation. It is valid only for services which run in the debug mode on the developer's machine.

Or did you mean to say that the services are actually running in the debug mode?

Another question is are you using the 4.0 build of the iOS library?

And finally, does the invocation of the service work from a Java client?

Regards,

Mark

photo
1

Hi Mark,

yes, the two services at this moment run in the debug mode on my machine.

In my app I've included the last Backendless SDK version using Cocoapods (pod 'Backendless', '4.0b3').

And the the last point, sorry but I'm not able to test them with a Java client.

Thanks,

Matteo

photo
1

Matteo,

An engineer will verify it and report back.

For tracking purposes an internal ticket is BKNDLSS-14459

Regards,

Mark

photo
1

Thanks Mark, so I wait for the engineer report. The ticket status will be updated here?

photo
1

Hi,

I update the question with further details.

Today I get a successful response from the service using the REST APIs in my iOS App with this sample code:

  1. let url = "https://api.backendless.com/APP_ID/REST_API_KEY/services/DiscotecaServices/1.0.0/sayHello";
  2. let header = [ "Content-Type": "application/json",
  3. "Accept": "application/json"]
  4. let body = "\"Matteo\""
  5. let request = urlRequestWithRawBody(url, rawBody: body, header: header)
  6. Alamofire.request(request).validate(statusCode: 200..<600).responseJSON { (response) in
  7. switch response.result {
  8. case .success:
  9. if let JSON = response.result.value {
  10. print("JSON: \(JSON)")
  11. }
  12. case .failure( _):
  13. break
  14. }
  15. }

Instead, using directly the iOS SDK with the invoke method, it still not works.

Hope this will help your investigation.

Matteo

photo
1

Hi Matteo,

We identified a few problem areas in the code and fixed them in the upcoming release (4.0b8).

REST invocations do work though (as you have already determined).

Regards,

Mark

photo
1

This sounds great!

Thanks for your work!

Matteo

photo
photo
1

Hi Matteo,

Can you please try again now?

photo
1

HI Sergey,

I confirmed that now all works fine.

Thanks for the support, your service is awesome!

Matteo

photo