| 2017.10.11 | jaxws |
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Iterator;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class TestWs {
public static void main(String[] args) throws Exception {
test();
}
/**
* @param args
*/
public static void test() throws Exception {
URL wsUrl = new URL("http://192.168.1.120:8080/project_name/SingleSignOn");
HttpURLConnection conn = (HttpURLConnection) wsUrl.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
OutputStream os = conn.getOutputStream();
String soap = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:sso=\"http://sso.ws.eppenpf.com/\">"
+ "<soapenv:Body> <sso:signOn> <args0>system</args0> <args1>?</args1> <args2>?</args2> </sso:signOn> </soapenv:Body> </soapenv:Envelope>";
os.write(soap.getBytes());
InputStream is = conn.getInputStream();
/*byte[] b = new byte[1024];
int len = 0;
String s = "";
while ((len = is.read(b)) != -1) {
String ss = new String(b, 0, len, "UTF-8");
s += ss;
}
System.out.println(s);*/
Document document = Jsoup.parse(is, "gbk", "");
Elements links = document.getElementsByTag("returnresult");
for (Iterator<Element> it = links.iterator(); it.hasNext();) {
Element e = (Element) it.next();
System.out.println(e.text());
}
System.err.println(document);
is.close();
os.close();
conn.disconnect();
}
}
更新列表:
*
参考文章: