我得到了一个 api,说明它需要:
URL http://server/a/messages.xml HTTP Method POST (even though the soapui example of this call uses PUT) Input XML <?xml version="1.0" encoding="UTF-8"?> <message> <content>Post message</content> <parent-id nil="true"></parent-id> </message>
现在我尝试使用以下代码(其中请求正文是 xml,如上所示,没有 \r\n )
PutMethod putMethod = null;
putMethod = new PutMethod(url);
putMethod.setQueryString(requestParams);
RequestEntity rEnt = new StringRequestEntity(requestBody,"text/xml",null);
putMethod.setRequestEntity(rEnt);
statusCode = client.executeMethod(putMethod);
我不断地从状态中恢复 500,我知道它就像soapui 示例(put)一样有效。
任何想法我错过了什么小东西。(我也要试试post)
谢谢