aufruf eines soap requests mit java über HTTP Post
try {
URL url = new URL(SERVER);
URLConnection urlc = url.openConnection();
HttpURLConnection connection = (HttpURLConnection) urlc;
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestMethod(“POST”);
connection.setRequestProperty(“Content-Type”, “text/xml; charset=utf-8”);
connection.setRequestProperty(“SOAPAction”, SOAP_ACTION);
OutputStream out = connection.getOutputStream();
Writer writeout = new OutputStreamWriter(out);
writeout.write(“<?xml version=’1.0′ encoding=’UTF-8′?>\r\n”);
writeout.write(“<SOAP-ENV:Envelope “);
writeout.write(“xmlns:xsi=’http://www.w3.org/1999/XMLSchema-instance’\r\n”);
writeout.write(“xmlns:SOAP-ENC=’http://schemas.xmlsoap.org/soap/encoding/’\r\n”);
writeout.write(“xmlns:SOAP-ENV=’http://schemas.xmlsoap.org/soap/envelope/’\r\n”);
writeout.write(“xmlns:xsd=’http://www.w3.org/1999/XMLSchema’\r\n”);
writeout.write(“SOAP-ENV:encodingStyle=’http://schemas.xmlsoap.org/soap/encoding/’>\r\n”);
writeout.write(” <SOAP-ENV:Body>”);
writeout.write(” <a>”);
writeout.write(” <b>”);
writeout.write(” </b>”);
writeout.write(” </a>”);
writeout.write(” </SOAP-ENV:Body>”);
writeout.write(“</SOAP-ENV:Envelope>”);
writeout.flush();
writeout.close();
InputStream in = connection.getInputStream();
int c;
while ((c = in.read()) != -1) System.out.write((char)c);
in.close();
}
catch (IOException e) {
e.printStackTrace();
}
wieder mal gebraucht, wieder mal nicht in altem sourcecode gefunden, deswegen jetzt hier drin
Ich denke so – zu fuss – war das nie wirklich geplant ;-)