Java调用基于SOAP的webservice 下载本文

java调用基于SOAP的webservice

发送请求内容;

public static String TargetNamspace = \

public String UserName; public String Password;

public String toXmlString() { }

StringBuilder _xmlstr = new StringBuilder();

_xmlstr.append(\

_xmlstr.append(\_xmlstr.append(\_xmlstr.append(\

return _xmlstr.toString();

public String toSoapString() { //

StringBuilder _xmlstr = new StringBuilder();

_xmlstr.append(\

// _xmlstr.append(\

xmlns:xsi=\\\xmlns:xsd=\\\

xmlns:soap=\\\// //

_xmlstr.append(\_xmlstr.append(toXmlString());

// //

_xmlstr.append(\_xmlstr.append(\

_xmlstr.append(\

_xmlstr.append(\

xmlns:xsi=\\\xmlns:xsd=\\\

xmlns:soap12=\\\

解析返回内容格式:

}

_xmlstr.append(\_xmlstr.append(toXmlString()); _xmlstr.append(\_xmlstr.append(\

return _xmlstr.toString();

public static String TargetNamspace = \

public LoginResult loginResult;

public static LoginResponse parseSoap(String soapXml) {

LoginResponse _LoginResponse = null;

Element _node; try {

/soap12:Envelope

_node = DocumentHelper.parseText(soapXml).getRootElement(); //

//System.out.println(_node.getPath());

_node = (Element)_node.elements().get(0); // /soap12:Envelope/soap12:Body

//System.out.println(_node.getPath());

_node = (Element)_node.elements().get(0); // /soap12:Envelope/soap12:Body/*[name()='LoginResponse']

public static LoginResponse parse(Element node) {

}

//System.out.println(_node.getPath()); //_node = (Element)_node.elements().get(0); _LoginResponse = parse(_node); /*

String XPath = \java.util.List _node_v = _node.selectNodes(XPath); if (_node_v != null && _node_v.size() != 0) { } */

_node = (Element) _node_v.get(0); _Login = parse(_node);

} catch (DocumentException e) { }

return _LoginResponse;

e.printStackTrace();

{

if (node == null) { }

//System.out.println(\Element _node;

LoginResponse _LoginResponse = new LoginResponse();

if (node.elements() != null) for (int i = 0; i < node.elements().size(); i++) {

_node = (Element) node.elements().get(i); try {

if (\

return null;

}

}

}

_LoginResponse.loginResult = LoginResult.parse(_node);

} catch(java.lang.NumberFormatException e) { }

e.printStackTrace();

return _LoginResponse;

public static class LoginResult implements java.io.Serializable{

private static final long serialVersionUID = 1L; public String areaOID;