Page 1 of 1

Rest Webservices issue.

PostPosted: Mon Mar 12, 2018 3:11 pm
by ashutoslenka426
Hi All ,

I have created a solution for webservices . I have attached it as module to the main solution . I have kept webservices here . I am launching the module solution as headless client . But still restful webservices not working .

Code: Select all
No Servoy web service found for 'rest_ws'


It is existing . Please provide some suggestions.

Re: Rest Webservices issue.

PostPosted: Mon Mar 12, 2018 10:40 pm
by mboegem
let's start with checking the URL
What URL do you use to consume the web service?

Re: Rest Webservices issue.

PostPosted: Tue Mar 13, 2018 1:52 am
by ashutoslenka426
Thanks for your reply . Please find the url - http://localhost:8080/servoy-service/re ... frm_owners

Re: Rest Webservices issue.

PostPosted: Tue Mar 13, 2018 8:18 am
by ashutoslenka426
Please find the webservice

Code: Select all
if (id)
   {
      // read 1 employee
      if (foundset.find())
      {
         foundset.owner_id = id
         if (foundset.search() == 1)
         {
            var owner = new Object()
            owner.id = foundset.owner_id
            owner.ownerName = foundset.owner_name
            owner.ownerEmail = foundset.owner_email
            return owner // response body
         }
      }
   }
   else
   {
      // list owner ids
      foundset.sort("owner_id asc")
      if (foundset.loadAllRecords())
      {
         var ownerids = new Array()
         for (var i = 1; i <= foundset.getSize(); i++)
         {
            ownerids[i] = foundset.getRecord(i).owner_id;
         }
         return ownerids // response body
      }
   }   
   

   // not found or cannot search
   return null;

Re: Rest Webservices issue.

PostPosted: Tue Mar 13, 2018 10:24 am
by jdbruijn
Your URL looks good to me (i am using something similar)
Did you try the servoy sample solution (servoy_sample_rest_ws.servoy)?
And also how do you test your webservice?

Re: Rest Webservices issue.

PostPosted: Tue Mar 13, 2018 12:23 pm
by ashutoslenka426
I tried the servoy sample rest services solution . I have created a new solution "servoy_test" and trying to launch headless client from it .

Code: Select all
function onSolutionOpen(arg, queryParams) {
   // TODO Auto-generated method stub
   plugins.headlessclient.createClient('servoy_sample_rest_ws',null,null,null);
}


But I am getting error.

Re: Rest Webservices issue.

PostPosted: Tue Mar 13, 2018 12:34 pm
by jdbruijn
You do not need to start the headless client. Servoy will take care of it.
Just make sure the webservice solution is the main solution, or at the mimimun included in the module list of the current solution.
Next use a tool to consume the webservice. I use Postman for this, but you could also use cURL or a simple webpage (PHP or angular)

Re: Rest Webservices issue.

PostPosted: Tue Mar 13, 2018 1:57 pm
by ashutoslenka426
Thanks . It worked fine using postman . it is working fine in sample solution .

But project solution is a different db .

Code: Select all
<html>
    <body>No Servoy web service found for 'rest_ws'</body>
</html>


Please provide some suggestions.

Re: Rest Webservices issue.

PostPosted: Tue Mar 13, 2018 3:03 pm
by jdbruijn
You mean your main solution is using db_A, and your webservice is using db_B?
That should not be an issue as long as both databases are active in your developer. And you have added the webservice as a module to your main solution.

But maybe you can tell a bit more about your use-case. What is your webservice supposed to do?

Re: Rest Webservices issue.

PostPosted: Tue Mar 13, 2018 3:42 pm
by ashutoslenka426
Thanks for your reply . It is similar code .

Code: Select all
if (id)
   {
      // read 1 owner
      if (foundset.find())
      {
         foundset.owner_id = id
         if (foundset.search() == 1)
         {
            var owner = new Object()
            owner.id = foundset.owner_id
            owner.ownerName = foundset.owner_name
            owner.ownerEmail = foundset.owner_email
            return owner // response body
         }
      }
   }
   else
   {
      // list owner ids
      foundset.sort("owner_id asc")
      if (foundset.loadAllRecords())
      {
         var ownerids = new Array()
         for (var i = 1; i <= foundset.getSize(); i++)
         {
            ownerids[i] = foundset.getRecord(i).owner_id;
         }
         return ownerids // response body
      }
   }   
   

   // not found or cannot search
   return null;


Please provide your suggestion . Database is running.

Re: Rest Webservices issue.

PostPosted: Tue Mar 13, 2018 3:59 pm
by jdbruijn
this is in a ws_read function?

Re: Rest Webservices issue.

PostPosted: Tue Mar 13, 2018 4:00 pm
by ashutoslenka426
yes Joas

Re: Rest Webservices issue.

PostPosted: Tue Mar 13, 2018 4:18 pm
by jdbruijn
Assuming that you are using svy_framework as the database, I have created a small sample solution that does what you want.
I've tested it with postman:
http://localhost:8081/servoy-service/re ... frm_owners