Rest Webservices issue.

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Rest Webservices issue.

Postby ashutoslenka426 » Mon Mar 12, 2018 3:11 pm

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.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Rest Webservices issue.

Postby mboegem » Mon Mar 12, 2018 10:40 pm

let's start with checking the URL
What URL do you use to consume the web service?
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1742
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Rest Webservices issue.

Postby ashutoslenka426 » Tue Mar 13, 2018 1:52 am

Thanks for your reply . Please find the url - http://localhost:8080/servoy-service/re ... frm_owners
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Rest Webservices issue.

Postby ashutoslenka426 » Tue Mar 13, 2018 8:18 am

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;
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Rest Webservices issue.

Postby jdbruijn » Tue Mar 13, 2018 10:24 am

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?
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Rest Webservices issue.

Postby ashutoslenka426 » Tue Mar 13, 2018 12:23 pm

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.
Attachments
error.png
error.png (38.6 KiB) Viewed 7219 times
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Rest Webservices issue.

Postby jdbruijn » Tue Mar 13, 2018 12:34 pm

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)
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Rest Webservices issue.

Postby ashutoslenka426 » Tue Mar 13, 2018 1:57 pm

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.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Rest Webservices issue.

Postby jdbruijn » Tue Mar 13, 2018 3:03 pm

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?
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Rest Webservices issue.

Postby ashutoslenka426 » Tue Mar 13, 2018 3:42 pm

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.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Rest Webservices issue.

Postby jdbruijn » Tue Mar 13, 2018 3:59 pm

this is in a ws_read function?
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Rest Webservices issue.

Postby ashutoslenka426 » Tue Mar 13, 2018 4:00 pm

yes Joas
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Rest Webservices issue.

Postby jdbruijn » Tue Mar 13, 2018 4:18 pm

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
Attachments
sample_service.servoy
(4.73 KiB) Downloaded 261 times
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 5 guests