你好,我是新的Web服務。如何創建簡單的Web服務,將輸入作爲JSONObject在java中
我能夠創建簡單的Web服務,它接受輸入字符串並使用eclipse返回另一個字符串。
但是,當涉及到JSONObject
我面臨的問題,同時調用Web服務
public class HelloWorld {
private int rowNumber;
public byte[] readJSON(JSONObject jsonObject) throws Exception
{
rowNumber=0;
File excelFile = new File("Test2.xlsx");
OutputStream outStream = new FileOutputStream(excelFile);
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("TestSheet");
XSSFRow row ;
XSSFCell cell;
JSONArray msg = (JSONArray) jsonObject.get("messages");
Iterator<String> iterator = msg.iterator();
while (iterator.hasNext()) {
row = sheet.createRow(rowNumber);
cell= row.createCell(0);
cell.setCellValue(iterator.next());
rowNumber=rowNumber+1;
}
workbook.write(outStream);
outStream.close();
Path path = Paths.get("Test2.xlsx");
byte[] data = Files.readAllBytes(path);
return data;
}
public float addValue(float value) {
return (value + 10);
}
}
所以幫我使用的Web服務。
SimpleDeserializer在試圖反序列化的東西中遇到了一個不期望的子元素。當我嘗試調用客戶端時出現此錯誤。而另一個輸入參數爲JSONObject的參數是允許的嗎?
有什麼問題? – Asu
@Asu ** SimpleDeserializer在嘗試反序列化時遇到了不期望的子元素。**當我嘗試調用客戶端時,出現此錯誤。而另一個輸入參數爲JSONObject的參數是允許的嗎? – Saurabh
你應該編輯問題來添加這個,更好的答案會得到更多的upvotes並且更加明顯。 – Asu