从页面表单提交和配置文件中读取出参数,或用实体类接收的页面传来的参数。建立map对象,用put()方法把参数添加进去。然后遍历map,将map转换成xml。
[java] view plain copy
StringBuffer soapResultData = new StringBuffer();
//xml声明
soapResultDataappend("<xml version=\"10\" encoding=\"GBK\"><ROOT><MSG_HEAD>");
//请求头
soapResultDataappend(requesttoxml(msgHead));
soapResultDataappend("</MSG_HEAD><MSG_BODY>");
//请求体
soapResultDataappend(requesttoxml(resmap));
soapResultDataappend("</MSG_BODY></ROOT>");
[java] view plain copy
/
将map转化为XML格式的字符串
@param resmap
@return
/
ublic static String requesttoxml(Map<String, String> resmap){
StringBuffer soapResultData = new StringBuffer();
for(String key : resmapkeySet()){
soapResultDataappend("<");
soapResultDataappend(key);
soapResultDataappend(">");
soapResultDataappend(resmapget(key));
soapResultDataappend("</");
soapResultDataappend(key);
soapResultDataappend(">");
}
return soapResultDatatoString();
将接收到的xml格式报文,转换成实体类。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)