I'm pulling my hair out over this.. We had a service in place when we were on Liferay 6.0 that read new entries from out HR database (new hires, terminations, changes, etc). It would then loop through and call the Liferay API using tunnel-web to call the functions to make changes (add user, update user, etc). When we upgraded to 6.2 it broke my custom service and after some trial and error I was able to get some methods working again using the jsonws api.
I worked out a few of them but I am having major problems with user/update-user. I am using VB.net to build a LiferayUser class, call get-user-by-screen-name, fill in values in new LiferayUser object, update values from HR database, convert object to json, call update-user and post the json object.
Right now all I get returned is {"exception":"java.lang.NullPointerException"}. This is also all that shows up in the server logs. I've tried both POST and GET methods, posting a json object. I even tried posting the form parameters to the /invoke method that is used on the api reference.
Has anyone come across this before and resolved it?
Related
I am total JS newbie working on a project build in Grail 2.4.4, a web-app. It's a working app, build by a developer whom is not available anymore.
To get it to work locally I had to upgrade it to Grails 3.2.0. I got it almost working in Netbeans. But I got stuck at getting the data from the MySQL database.
The Chrome inspector says:
angular.min.js GET http://localhost:8080/<app>/currency/allCurrencies 404 ()
The controllers are written in Restangular which call the above URL.
What am I missing?
Firstly, Restangular is an Angular library which simplifies and standardizes making calls to a REST backend (which in your case is a Grails app). So, Restangular does not directly retrieve data from your a database, it invokes a web service which (in some cases) may retrieve data from a database.
In your case, Restangular is attempting to retrieve data from the endpoint http://localhost:8080/<app>/currency/allCurrencies but you are getting a 404 response, indicating that there is no endpoint mapped to this URL.
HTTP REST helps you connect to the API easily. Restangular can handle that by sending standard methods [Get, Post, Delete, Put] to the api like what you see.
This mean StudentController > Get()
localhost:2045/api/student
This mean StudentController > Get(Guid id)
localhost:2045/api/student/8ae37cfa-905b-4c71-ad03-bf416d93bdf8
This mean StudentController > POST(Guid id) ... if you send Post method to the API, it will detect it, this work also on put method
localhost:2045/api/student
use this module to get easily rest api.
Http-Rest-Service
I am new to wso2 API Manager, trying to set it up expose my plain HTTP POST back end calls as a REST API. I am sure this is not a new pattern that I am trying to achieve here. The requirement is to convert the JSON data coming in (has array structures) into the HTTP URL query string parameters.
After some research through the documentation and other posts on this forum, decided to go with the script mediator that would parse the JSON data and convert it to a string that can be appended to the endpoint URL. Some how I am not able to achieve this.
I have followed the following post that seems to be very straight forward. As the original poster suggested, I am also not able to use getPayloadJSON() method. Even have trouble using the work around suggested there due to JSON.parse() not working.
Link
Also, this approach of editing the service bus configuration from source view does not sound like the correct option. Is there another elegant solution to achieve this? Thanks for the help in advance.
I was able to get both methods working by using an external script instead of the inline java script. Thanks
Ok, this is my Nth question regarding this topic, and I'm getting really frustrated with Grails. Please have a quick look on one of my earlier questions for more details.
Among other things, my problem is that sending JSON formatted data to the controller when testing doesn't seem to work. The controller doesn't get null object, but the argument passed is practically empty--the JSON properties don't get set.
Aside from the controller code from the link above, I also tried,
def save() {
def model = new MyModel(request.JSON)
model.save()
}
but it still fails to set properties.
From my Web searches, I read that in older versions, parseRequest must be set to true in UrlMapping.groovy so that request data formatted in XML, JSON, etc. would automatically be parsed and passed as controller method argument. I'm working on Grails 2.3.9, and I'm not sure if it's still necessary to do that.
The time I thought I'd save if I use Grails on this project is being spent on looking for an answer to this seemingly simple task of testing a RESTful Web service.
No since 2.3.0 the parseRequest option doesn't do anything. The request is parsed lazily only when request.XML or request.JSON is accessed or when binding to a command object.
I want to call the json web service of liferay that is dlapp/search,
the problem I am facing is what value to passed to searchContext object in json web service.
Each time I call the service using correct repository-id and correct lucene query in the parameters.
But I am confused which value should be provided to searchContext for correct service results.
Very new to WCF and almost got everything to work doing POST from JQuery to WCF. I thought?
The Jquery is processing a DynaTree and gets the latest dictionary which needs to be serialized in order to perform a successful post.
When I run Visual Studio, it works fine. When I access the site from my development machine - not in debug mode - it also works fine. But when accessing the site from any other machine siting on the same domain within the WLAN, it fails.
var dict = $("#tree").dynatree("getTree").toDict();
The line in particular that fails is JSON.stringify(dict);
The alerts shows an object coming through and hence toDict() works fine. However, when JSON tries to serialize it, fails.
This serialized data will be my post data to WCF handle. There is nothing wrong in WCF, the call to WCF is never made as the code fails one line above.
Need help.