我必须调用这个编写的 REST 服务斯卡拉阿卡项目来自java-spring.
我的 scala REST 服务就像
val route =
post {
path("notification" / "signUp"){
headerValueByName("App_Key") { app_key => {
handleWith {
requestParameters: RequestParameters =>
//application specific implementation
}
}
}
}
其中包含标头中的 App_Key 和 Content-Type and 请求参数json 格式。
请求参数如下:
case class RequestParameters (
var name: String,
var email: String,
var password: String,
var hashKey: String
)
所以我必须称之为REST服务来自java 弹簧。我打电话时很挣扎http://ipadress:port/notification/signUp
来自爪哇。
你可以通过以下方式调用它。以下实施:
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();
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)