xml|xml String字符串解析 map转xml
最近和其他系统调试接口,用的webServices 传参和返回类型要求都为String ,所以双方约定为xml格式的字符串,使用工具为dom4j具体代码如下所示:
package com.cee.tyrz.services.ldap;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.UnknownHostException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.naming.NamingException;
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.DirContext;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.rpc.ServiceException;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import org.jdom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import com.cee.common.CallBack;
import com.cee.common.CallService;
import com.cee.common.DESPlus;
import com.cee.common.MD5Code;
import com.cee.common.SpringContextHelper;
import com.cee.common.XmlUtils;
import com.cee.common.util.ConfigFactory;
import com.cee.common.util.LoadProperties;
import com.cee.components.ldap.LdapHelp;
import com.cee.sys.service.SysOrganizationsService;
import com.cee.sys.service.SysUsersService;
import com.cee.tyrz.services.ad.AdLdapContext;
import com.cee.tyrz.services.ad.AdService;
import com.cee.tyrz.services.ad.AdServiceImp;
import com.cee.tyrz.services.hrservice.HRService;
import com.cee.tyrz.services.hrservice.HRServiceImpl;
import com.cee.tyrz.services.ldap.support.PinyinHandler;
import com.cee.tyrz.warning.service.PushWarningService;
import com.cee.tyrz.yhfp.dao.SsoModelDAO;
import com.cee.tyrz.yhfp.domain.EipSsoModle;
import com.cee.tyrz.yhfp.service.CoremailService;
import com.cee.tyrz.yhfp.service.ISsoModelService;
import com.cee.tyrz.yhfp.service.yhfpManager;
import com.cee.tyrz.yhfp.service.impl.LoadUserService;
import com.sun.org.apache.bcel.internal.generic.LADD;
import com.sun.xml.messaging.saaj.util.JAXMStreamSource;
/**
* 具体实现ldap发布接口
*
* @author songyj
*
*/
public class LdapServiceExtendImp implements LdapServiceExtend {
static Properties ad = LoadProperties.loadProperties("/config/sysParameter.properties");
static Logger logger = Logger.getLogger(LdapServiceExtendImp.class.getName());
publicString getListByUserId(String userIdXml) {
List userIdList = readStringXml(userIdXml);
Map resultMap = new HashMap();
String resultXml = "";
ConfigFactory.loadAllConfigFile("");
int yyy = 0;
int nnn = 0;
for(String userIdStr : userIdList){
List
【xml|xml String字符串解析 map转xml】
推荐阅读
- mybatisplus如何在xml的连表查询中使用queryWrapper
- 一起来学习C语言的字符串转换函数
- 字符串拼接成段落,换行符(\n)如何只执行n-1次
- C语言的版本比较
- jvm关于String
- LeetCode(03)Longest|LeetCode(03)Longest Substring Without Repeating Characters
- 微信小程序基础知识
- JavaScript|JavaScript — call()和apply()、Date对象、Math、包装类、字符串的方法
- JS截取字符串的方法详解
- Python|Python 字符串 子串 回文串