java - Hitting non-GWT servlet from GWT client-side -
let's there 3rd party restful web service exposing endpoint at:
http://someservice.com/api/askanyquestion and want nail service, placing question on query string:
http://someservice.com/api/askanyquestion&q=does%20my%20dog%20know%20about%20math%3f how nail service client-side gwt application? i've been reading requestfactory tutorials, rf seems providing info access layer (dal) , crudding entities, , i'm not exclusively sure if it's appropriate utilize case.
extra super bonus points if can provide code sample, , not link gwt tutorials, have read, or googler's blog, have read ;-).
i had same problem few days ago , tried implement requestbuilder. receive cross-domain scripting issue.
https://developers.google.com/web-toolkit/doc/1.6/faq_server#how_can_i_dynamically_fetch_json_feeds_from_other_web_domains?
i did handle rpc request server, , there server-side http request cross-domain url.
https://developers.google.com/web-toolkit/doc/latest/tutorial/xsite
public static void sendrequest(string method, string notifications) { string url = service_base_url + method; jsonobject requestobject = new jsonobject(); jsonarray notificationsarray =null; jsonobject mainrequest = new jsonobject(); seek { notificationsarray = new jsonarray(notifications); requestobject.put("notifications", notificationsarray); mainrequest.put("request", requestobject); } grab (jsonexception e1) { // todo auto-generated grab block e1.printstacktrace(); } httpurlconnection connection = null; seek { url server = new url(url); connection = (httpurlconnection) server.openconnection(); connection.setrequestmethod("post"); connection.setrequestproperty("content-type", "application/json"); connection.setdoinput(true); connection.setdooutput(true); dataoutputstream author = new dataoutputstream(connection.getoutputstream()); writer.writebytes(mainrequest.tostring()); writer.flush(); writer.close(); parseresponse(connection); } grab (exception e) { system.out.println("an error occurred: " + e.getmessage()); } { if (connection != null) { connection.disconnect(); } } } java web-services rest gwt requestfactory
No comments:
Post a Comment