目前我有一个在tomcat中运行的Web服务(http:// localhost:8080/myApp/getUsers).我的Web服务将接受json字符串,然后进行相应的处理.我的网络服务代码如下:
@Path("/getUsers")
public class UsersWS
{
@POST
public Response post(String theRequestJSON)
{
try
{
JSONObject aJsonObj = new JSONObject(theRequestJSON);
String userID = aJsonObj.getString("userID");
System.out.println(userID);
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以,我的Web服务正在处理一个json字符串.所以现在,我需要从另一个JAVA类调用上面的Web服务(jsonObject在请求参数中具有userID).
怎么做?不久,我需要使用JSON对象作为请求参数从JAVA类进行Web服务调用.如何在请求调用中将json作为请求参数发送.
看看泽西岛:http://jersey.java.net
以下是关于如何使用客户端的好文章:http: //blogs.oracle.com/enterprisetechtips/entry/consuming_restful_web_services_with
| 归档时间: |
|
| 查看次数: |
14915 次 |
| 最近记录: |