diff --git a/SOAPClient.class b/SOAPClient.class new file mode 100644 index 0000000000000000000000000000000000000000..8a8916404680f1c0eb3d5122d753913a363334cc Binary files /dev/null and b/SOAPClient.class differ diff --git a/SOAPClient.java b/SOAPClient.java new file mode 100644 index 0000000000000000000000000000000000000000..5ce10b46e292cc0c392bcddac04bdaa7c59d7bc2 --- /dev/null +++ b/SOAPClient.java @@ -0,0 +1,107 @@ +/** + * SOAPClient4XG. Read the SOAP envelope file passed as the second + * parameter, pass it to the SOAP endpoint passed as the first parameter, and + * print out the SOAP envelope passed as a response. with help from Michael + * Brennan 03/09/01 + * + * java SOAPClient4XG http://services.xmethods.net:80/soap/servlet/rpcrouter weatherreq.xml + * + * @author Bob DuCharme + * @version 1.1 + * @param SOAPUrl URL of SOAP Endpoint to send request. + * @param xmlFile2Send A file with an XML document of the request. + * + * 5/23/01 revision: SOAPAction added +*/ + +import java.io.*; +import java.net.*; + +public class SOAPClient { + public static void main(String[] args) throws Exception { + + if (args.length < 2) { + System.err.println("Usage: java SOAPClient4XG " + + "http://soapURL soapEnvelopefile.xml" + + " [SOAPAction]"); + System.err.println("SOAPAction is optional."); + System.exit(1); + } + + String SOAPUrl = args[0]; + String xmlFile2Send = args[1]; + + String SOAPAction = ""; + if (args.length > 2) + SOAPAction = args[2]; + + // Create the connection where we're going to send the file. + URL url = new URL(SOAPUrl); + URLConnection connection = url.openConnection(); + HttpURLConnection httpConn = (HttpURLConnection) connection; + + // Open the input file. After we copy it to a byte array, we can see + // how big it is so that we can set the HTTP Cotent-Length + // property. (See complete e-mail below for more on this.) + + FileInputStream fin = new FileInputStream(xmlFile2Send); + + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + + // Copy the SOAP file to the open connection. + copy(fin,bout); + fin.close(); + + byte[] b = bout.toByteArray(); + + // Set the appropriate HTTP parameters. + httpConn.setRequestProperty( "Content-Length", + String.valueOf( b.length ) ); + httpConn.setRequestProperty("Content-Type","text/xml; charset=utf-8"); + httpConn.setRequestProperty("SOAPAction",SOAPAction); + httpConn.setRequestMethod( "POST" ); + httpConn.setDoOutput(true); + httpConn.setDoInput(true); + + System.out.println("test111"+httpConn.toString()); + // Everything's set up; send the XML that was read in to b. + OutputStream out = httpConn.getOutputStream(); + out.write( b ); + out.close(); + + // Read the response and write it to standard out. + + InputStreamReader isr = + new InputStreamReader(httpConn.getInputStream()); + BufferedReader in = new BufferedReader(isr); + + String inputLine; + + while ((inputLine = in.readLine()) != null) + System.out.println(inputLine); + + in.close(); + } + + // copy method from From E.R. Harold's book "Java I/O" + public static void copy(InputStream in, OutputStream out) + throws IOException { + + // do not allow other threads to read from the + // input or write to the output while copying is + // taking place + + synchronized (in) { + synchronized (out) { + + byte[] buffer = new byte[256]; + while (true) { + int bytesRead = in.read(buffer); + if (bytesRead == -1) break; + out.write(buffer, 0, bytesRead); + } + } + } + } +} + diff --git a/SOAPClient.java.bak b/SOAPClient.java.bak new file mode 100644 index 0000000000000000000000000000000000000000..10c86c1983614222d85e72d277fc19c8b4937af9 --- /dev/null +++ b/SOAPClient.java.bak @@ -0,0 +1,106 @@ +/** + * SOAPClient4XG. Read the SOAP envelope file passed as the second + * parameter, pass it to the SOAP endpoint passed as the first parameter, and + * print out the SOAP envelope passed as a response. with help from Michael + * Brennan 03/09/01 + * + * java SOAPClient4XG http://services.xmethods.net:80/soap/servlet/rpcrouter weatherreq.xml + * + * @author Bob DuCharme + * @version 1.1 + * @param SOAPUrl URL of SOAP Endpoint to send request. + * @param xmlFile2Send A file with an XML document of the request. + * + * 5/23/01 revision: SOAPAction added +*/ + +import java.io.*; +import java.net.*; + +public class SOAPClient { + public static void main(String[] args) throws Exception { + + if (args.length < 2) { + System.err.println("Usage: java SOAPClient4XG " + + "http://soapURL soapEnvelopefile.xml" + + " [SOAPAction]"); + System.err.println("SOAPAction is optional."); + System.exit(1); + } + + String SOAPUrl = args[0]; + String xmlFile2Send = args[1]; + + String SOAPAction = ""; + if (args.length > 2) + SOAPAction = args[2]; + + // Create the connection where we're going to send the file. + URL url = new URL(SOAPUrl); + URLConnection connection = url.openConnection(); + HttpURLConnection httpConn = (HttpURLConnection) connection; + + // Open the input file. After we copy it to a byte array, we can see + // how big it is so that we can set the HTTP Cotent-Length + // property. (See complete e-mail below for more on this.) + + FileInputStream fin = new FileInputStream(xmlFile2Send); + + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + + // Copy the SOAP file to the open connection. + copy(fin,bout); + fin.close(); + + byte[] b = bout.toByteArray(); + + // Set the appropriate HTTP parameters. + httpConn.setRequestProperty( "Content-Length", + String.valueOf( b.length ) ); + httpConn.setRequestProperty("Content-Type","text/xml; charset=utf-8"); + httpConn.setRequestProperty("SOAPAction",SOAPAction); + httpConn.setRequestMethod( "POST" ); + httpConn.setDoOutput(true); + httpConn.setDoInput(true); + + // Everything's set up; send the XML that was read in to b. + OutputStream out = httpConn.getOutputStream(); + out.write( b ); + out.close(); + + // Read the response and write it to standard out. + + InputStreamReader isr = + new InputStreamReader(httpConn.getInputStream()); + BufferedReader in = new BufferedReader(isr); + + String inputLine; + + while ((inputLine = in.readLine()) != null) + System.out.println(inputLine); + + in.close(); + } + + // copy method from From E.R. Harold's book "Java I/O" + public static void copy(InputStream in, OutputStream out) + throws IOException { + + // do not allow other threads to read from the + // input or write to the output while copying is + // taking place + + synchronized (in) { + synchronized (out) { + + byte[] buffer = new byte[256]; + while (true) { + int bytesRead = in.read(buffer); + if (bytesRead == -1) break; + out.write(buffer, 0, bytesRead); + } + } + } + } +} + diff --git a/SOAPClient4XG.class b/SOAPClient4XG.class new file mode 100644 index 0000000000000000000000000000000000000000..a96b5ea6f55912f162f5cf3a201770773aec8b62 Binary files /dev/null and b/SOAPClient4XG.class differ diff --git a/SOAPClient4XG.java b/SOAPClient4XG.java new file mode 100644 index 0000000000000000000000000000000000000000..ca0d38f4bdd4c464050f349effab2f9e7ada785c --- /dev/null +++ b/SOAPClient4XG.java @@ -0,0 +1,98 @@ +/** + * SOAPClient4XG. Read the SOAP envelope file passed as the second + * parameter, pass it to the SOAP endpoint passed as the first parameter, and + * print out the SOAP envelope passed as a response. with help from Michael + * Brennan 03/09/01 + * + * java SOAPClient4XG http://services.xmethods.net:80/soap/servlet/rpcrouter weatherreq.xml + * + * @author Bob DuCharme + * @version 1.1 + * @param SOAPUrl URL of SOAP Endpoint to send request. + * @param xmlFile2Send A file with an XML document of the request. + * + * 5/23/01 revision: SOAPAction added +*/ +import java.net.*; +import java.io.*; + +public class SOAPClient4XG { + + + public static void main(String[] args) throws Exception { + String SOAPUrl = "http://localhost:7777/"; +// String xmlFile2Send = args[1]; + +// String SOAPAction = ""; +// if (args.length > 2) +// SOAPAction = args[2]; +// + // Create the connection where we're going to send the file. + URL url = new URL(SOAPUrl); + URLConnection connection = url.openConnection(); + HttpURLConnection httpConn = (HttpURLConnection) connection; + + // Open the input file. After we copy it to a byte array, we can see + // how big it is so that we can set the HTTP Cotent-Length + // property. (See complete e-mail below for more on this.) + + // FileInputStream fin = new FileInputStream(xmlFile2Send); + + // ByteArrayOutputStream bout = new ByteArrayOutputStream(); + + // Copy the SOAP file to the open connection. +// copy(fin,bout); +// fin.close(); + +// byte[] b = bout.toByteArray(); + + // Set the appropriate HTTP parameters. + httpConn.setRequestProperty( "Content-Length", + "10" ); + httpConn.setRequestProperty("Content-Type","text/xml; charset=utf-8"); + httpConn.setRequestProperty("SOAPAction","listalignment"); + httpConn.setRequestMethod( "POST" ); + httpConn.setDoOutput(true); + httpConn.setDoInput(true); + + // Everything's set up; send the XML that was read in to b. +// OutputStream out = httpConn.getOutputStream(); + // out.write( b ); + // out.close(); + + // Read the response and write it to standard out. + + InputStreamReader isr = + new InputStreamReader(httpConn.getInputStream()); + BufferedReader in = new BufferedReader(isr); + + String inputLine; + + while ((inputLine = in.readLine()) != null) + System.out.println(inputLine); + + in.close(); + } + + // copy method from From E.R. Harold's book "Java I/O" + public static void copy(InputStream in, OutputStream out) + throws IOException { + + // do not allow other threads to read from the + // input or write to the output while copying is + // taking place + + synchronized (in) { + synchronized (out) { + + byte[] buffer = new byte[256]; + while (true) { + int bytesRead = in.read(buffer); + if (bytesRead == -1) break; + out.write(buffer, 0, bytesRead); + } + } + } + } +} + diff --git a/SOAPClient4XG.java.bak b/SOAPClient4XG.java.bak new file mode 100644 index 0000000000000000000000000000000000000000..6e12614132cb785440f60a939a9d36726f7f51ba --- /dev/null +++ b/SOAPClient4XG.java.bak @@ -0,0 +1,98 @@ +/** + * SOAPClient4XG. Read the SOAP envelope file passed as the second + * parameter, pass it to the SOAP endpoint passed as the first parameter, and + * print out the SOAP envelope passed as a response. with help from Michael + * Brennan 03/09/01 + * + * java SOAPClient4XG http://services.xmethods.net:80/soap/servlet/rpcrouter weatherreq.xml + * + * @author Bob DuCharme + * @version 1.1 + * @param SOAPUrl URL of SOAP Endpoint to send request. + * @param xmlFile2Send A file with an XML document of the request. + * + * 5/23/01 revision: SOAPAction added +*/ +import java.net.*; +import java.io.*; + +public class SOAPClient4XG { + + + public static void main(String[] args) throws Exception { + String SOAPUrl = "http://localhost:7777/"; +// String xmlFile2Send = args[1]; + +// String SOAPAction = ""; +// if (args.length > 2) +// SOAPAction = args[2]; +// + // Create the connection where we're going to send the file. + URL url = new URL(SOAPUrl); + URLConnection connection = url.openConnection(); + HttpURLConnection httpConn = (HttpURLConnection) connection; + + // Open the input file. After we copy it to a byte array, we can see + // how big it is so that we can set the HTTP Cotent-Length + // property. (See complete e-mail below for more on this.) + + // FileInputStream fin = new FileInputStream(xmlFile2Send); + + // ByteArrayOutputStream bout = new ByteArrayOutputStream(); + + // Copy the SOAP file to the open connection. +// copy(fin,bout); +// fin.close(); + +// byte[] b = bout.toByteArray(); + + // Set the appropriate HTTP parameters. + httpConn.setRequestProperty( "Content-Length", + "10" ); + httpConn.setRequestProperty("Content-Type","text/xml; charset=utf-8"); + httpConn.setRequestProperty("SOAPAction","listalignment"); + httpConn.setRequestMethod( "POST" ); + httpConn.setDoOutput(true); + httpConn.setDoInput(true); + + // Everything's set up; send the XML that was read in to b. +// OutputStream out = httpConn.getOutputStream(); + // out.write( b ); + // out.close(); + + // Read the response and write it to standard out. + + InputStreamReader isr = + new InputStreamReader(httpConn.getInputStream()); + BufferedReader in = new BufferedReader(isr); + + String inputLine; + + while ((inputLine = in.readLine()) != null) + System.out.println(inputLine); + + in.close(); + } + + // copy method from From E.R. Harold's book "Java I/O" + public static void copy(InputStream in, OutputStream out) + throws IOException { + + // do not allow other threads to read from the + // input or write to the output while copying is + // taking place + + synchronized (in) { + synchronized (out) { + + byte[] buffer = new byte[256]; + while (true) { + int bytesRead = in.read(buffer); + if (bytesRead == -1) break; + out.write(buffer, 0, bytesRead); + } + } + } + } +} + diff --git a/message.xml b/message.xml new file mode 100644 index 0000000000000000000000000000000000000000..54ad9155f9c14607158c2b04287fc9273cd16a6e --- /dev/null +++ b/message.xml @@ -0,0 +1,3 @@ +<SOAP> +test +</SOAP> \ No newline at end of file diff --git a/soap-example.xml b/soap-example.xml new file mode 100644 index 0000000000000000000000000000000000000000..ba46893bfe78e60c98e38f3fa0792c4f528fec59 --- /dev/null +++ b/soap-example.xml @@ -0,0 +1,12 @@ +<SOAP-ENV:Envelope + xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" + xmlns:xsd="http://www.w3.org/1999/XMLSchema" +> + <SOAP-ENV:Body> + <ns1:getTemp xmlns:ns1="urn:xmethods-Temperature" + SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> + <zipcode xsi:type="xsd:string">11217</zipcode> + </ns1:getTemp> + </SOAP-ENV:Body> +</SOAP-ENV:Envelope>