32601:找不到方法

时间:2017-02-09 18:43:45

标签: java http server client

我遇到的一个问题是我将电影打包并发送到服务器。服务器不喜欢它,并且在那里调试该服务器。我拿相同的字符串并解包它,它喜欢电影,但服务器没有

在add方法上,请求是:

收到请求:

{"method":"add","id":1,"jsonrpc":"2.0","params":"{\"Runtime\":\"120 min\",\"Released\":\"12 Dec 2015\",\"Rated\":\"PG\",\"Plot\":\"Dummy Plot\",\"FileName\":\"temp.mpg\",\"Title\":\"james\",\"Actors\":[\"Jane Doe\",\"Joe Smith\"],\"Genre\":[\"family\",\"Animation\"]}"}
Sending back response: HTTP/1.0 400
Content-Type: text/plain
Content-Length:85

但它说:

{"id":0,"jsonrpc":"2.0","error":"{\"code\":-32601,\"message\":\"Method Not Found\"}"}

发送"请求"从客户端到服务器有2个命令:

public abstract Object sendRequest(String string) throws JsonRpcException;
public synchronized Object callRPCMethod(String string, Object[] os) throws JsonRpcException 

对于我的所有要求,我使用的是sendRequest

此处定义了添加方法

public interface MovieCollection {
   public boolean saveToJsonFile() throws JsonRpcException;
   public boolean resetFromJsonFile() throws JsonRpcException;
   public boolean add(Movie aMovie) throws JsonRpcException;
   public boolean remove(String aName) throws JsonRpcException;
   public Movie get(String aName) throws JsonRpcException;
   public String[] getTitles() throws JsonRpcException;
}

public String packageCall(String operation, Movie movie) {
    JSONObject jsonObj = new JSONObject();
    jsonObj.put("jsonrpc", "2.0");
    jsonObj.put("method", operation);

    JSONObject object = movie.toJSONObject();
    String temp = object.toString();
    jsonObj.put("params", temp);
    jsonObj.put("id", ++id);

    String string = (String) object2.get("params");

    return ret;
}

0 个答案:

没有答案