<?xml:namespace prefix = soap />
<soap:Body>
<VERIFY xmlns="http://ormp.biz/webservices/">
<KEY>guid</KEY>
<IP>string</IP>
</VERIFY>
</soap:Body>
verify有 名为 xmlns属性的时候就会报错
附一个xml读写类
import org.dom4j.io.XMLWriter;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import java.io.FileWriter;
import org.dom4j.io.OutputFormat;
import java.io.File;
import org.dom4j.Document;
import org.dom4j.io.SAXReader;
public class XmlTool {
private String filename;
private SAXReader saxReader = null;
private Document document = null;
private Element cfgElement = null;
public XmlTool(String filename) {
this.filename = filename;
try {
saxReader = new SAXReader();
document = saxReader.read(new File(filename));
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void setValue(String key, String value) {
int returnValue = 0;
try {
((Element)( document.selectSingleNode(key))).setText(value);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public String getValue(String key) {
int returnValue = 0;
try {
return ((Element)( document.selectSingleNode(key))).getText();
} catch (Exception ex) {
ex.printStackTrace();
return "";
}
}
public int writeToFile() {
int returnValue = 0;
try {
XMLWriter writer = new XMLWriter(new FileWriter(new File(filename)));
writer.write(document);
writer.close();
returnValue = 1;
} catch (Exception ex) {
ex.printStackTrace();
}
return returnValue;
}
public int formatXMLFile(String filename) {
int returnValue = 0;
try {
SAXReader saxReader = new SAXReader();
Document document = saxReader.read(new File(filename));
XMLWriter output = null;
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("GBK");
output = new XMLWriter(new FileWriter(new File(filename)), format);
output.write(document);
output.close();
returnValue = 1;
} catch (Exception ex) {
ex.printStackTrace();
}
return returnValue;
}
}