Java Spring as a client for Akka based REST HTTP call

后端 未结 1 2053
無奈伤痛
無奈伤痛 2021-01-22 13:12

i have to call this REST service written in scala-akka project from java-spring.

my scala REST service is like

val route =
    post {         


        
相关标签:
1条回答
  • 2021-01-22 13:59

    U can call this via. Following Implementation :

    try {
    
                Client client = Client.create();
    
                WebResource webResource = client.resource(http://ipadress:port/notification/signUp);
    
                JSONObject formData=new JSONObject();
                formData.put("name", UserName);
                formData.put("email", EmailId);
                formData.put("password", Password);
                formData.put("urlHash",HashKey);
    
                ClientResponse response = webResource.header("App_Key",xxxxxxxxxxxxxxxxxxxxxxxxxx).type(MediaType.APPLICATION_JSON_TYPE).post(ClientResponse.class, formData);
    
            } catch (Exception e) {
    
                e.printStackTrace();
            }
    
    0 讨论(0)
提交回复
热议问题