soap request via http post

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&#8217;\r\n”);
writeout.write(“xmlns:SOAP-ENC=’http://schemas.xmlsoap.org/soap/encoding/&#8217;\r\n”);
writeout.write(“xmlns:SOAP-ENV=’http://schemas.xmlsoap.org/soap/envelope/&#8217;\r\n”);
writeout.write(“xmlns:xsd=’http://www.w3.org/1999/XMLSchema&#8217;\r\n”);
writeout.write(“SOAP-ENV:encodingStyle=’http://schemas.xmlsoap.org/soap/encoding/’&gt;\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

Advertisements
This entry was posted in howtos. Bookmark the permalink.

One Response to soap request via http post

  1. Gerhard Poul (anonym) says:

    Ich denke so – zu fuss – war das nie wirklich geplant ;-)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s