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 .
No Servoy web service found for 'rest_ws'
It is existing . Please provide some suggestions.
let’s start with checking the URL
What URL do you use to consume the web service?
Please find the webservice
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;
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?
I tried the servoy sample rest services solution . I have created a new solution “servoy_test” and trying to launch headless client from it .
function onSolutionOpen(arg, queryParams) {
// TODO Auto-generated method stub
plugins.headlessclient.createClient('servoy_sample_rest_ws',null,null,null);
}
But I am getting error.
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)
Thanks . It worked fine using postman . it is working fine in sample solution .
But project solution is a different db .
<html>
<body>No Servoy web service found for 'rest_ws'</body>
</html>
Please provide some suggestions.
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?
Thanks for your reply . It is similar code .
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.
this is in a ws_read function?
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
sample_service.servoy (4.73 KB)