/**
* body 拼接
*
* @param method 请求方法名
* @param params 参数
* @return
*/
public static String createWebServiceRequestBody(String method, Map<String, Object> params) {
StringBuffer body = new StringBuffer("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
body.append("<soap:Body>");
body.append("<" + method + " xmlns=\"http://tempuri.org/\">");
if (params != null) {
for (Map.Entry<String, Object> entry : params.entrySet()) {
body.append("<" + entry.getKey() + ">").append(changToXmlStr((String) entry.getValue()))
.append("</" + entry.getKey() + ">");
}
}
body.append("</" + method + "></soap:Body></soap:Envelope>");
return body.toString();
}
模拟http请求webService的body参数封装方法(SOAP请求)
最新推荐文章于 2022-10-12 23:41:15 发布