我試圖golang程序與JSON RPC Java程序連接,但遇到了一些麻煩。我使用golang本地程序包中的「net/rpc/jsonrpc」包,以及java中的「jsonrpc4j」。我使用流模式在java中創建服務器,因爲golang的jsonrpc只支持tcp invoke。但它仍然得到golang客戶端的錯誤響應:golang jsonrpc調用Java JSON RPC
err: invalid error map[code:-32602 message:Invalid method parameters]
同時Java服務器也遇到錯誤:
com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input at [Source: [email protected]; line: 1, column: 1] at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148) at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3747) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3687) at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:2202) at com.googlecode.jsonrpc4j.JsonRpcServer.handle(JsonRpcServer.java:224) at com.googlecode.jsonrpc4j.StreamServer$Server.run(StreamServer.java:214) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:744)
我不明白爲什麼它不工作,沒有任何紀律存在於jsonrpc協議中,golang不能調用java,或者我只是做不對嗎?
我在嘗試類似的東西,並且遇到了死衚衕。就我所知,Go rpc軟件包僅支持Go服務器和客戶端,而不支持用其他語言編寫的Go服務器和客戶端。以下是Golang-Nuts谷歌組的一個編號:https://groups.google.com/forum/#!topic/golang-nuts/F0cuNKsH7c4 – Snowman