Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. function testBodyJavaAdapter(){
  2.  
  3. alert("HI")
  4. var baseUrlJavaAdapter="/adapters/JavaAdapterTest/api/postHelloUserBody";
  5.  
  6.  
  7.  
  8. var req = new WLResourceRequest(baseUrlJavaAdapter, WLResourceRequest.POST);
  9.  
  10.  
  11. var json={
  12. first:"Nazmul",
  13. middle:"Hasan",
  14. last:"Prince"
  15.  
  16. }
  17. req.setHeader("Content-Type", "application/json");
  18. req.send(json).then(function(resp){
  19.  
  20. alert("Success");
  21. $("#showInfoDiv").html(resp.responseText);
  22. })
  23.  
  24. }
  25.  
  26. @Path("/api")
  27. @OAuthSecurity(enabled=false)
  28. public class JavaAdapterTestResource {
  29.  
  30. static Logger logger = Logger.getLogger(JavaAdapterTestResource.class.getName());
  31.  
  32. //Define the server api to be able to perform server operations
  33. WLServerAPI api = WLServerAPIProvider.getWLServerAPI();
  34.  
  35.  
  36. @POST
  37. @Consumes("application/json")
  38. @Path("/postHelloUserBody")
  39. public String postHelloUserBody(@HeaderParam("Content-Type") String type, JSONObject json) throws IOException{
  40. return "Hello " + json.get("first") + " " + json.get("middle") + " " + json.get("last");
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement