From 4f2bff2bf67aa6ab3f52ad3546eccdd31a8dc252 Mon Sep 17 00:00:00 2001 From: Seungkeun Lee <sglee0901@gmail.com> Date: Mon, 26 Feb 2007 14:43:17 +0000 Subject: [PATCH] --- SOAPClient.class | Bin 0 -> 2368 bytes SOAPClient.java | 107 +++++++++++++++++++++++++++++++++++++++++ SOAPClient.java.bak | 106 ++++++++++++++++++++++++++++++++++++++++ SOAPClient4XG.class | Bin 0 -> 1664 bytes SOAPClient4XG.java | 98 +++++++++++++++++++++++++++++++++++++ SOAPClient4XG.java.bak | 98 +++++++++++++++++++++++++++++++++++++ message.xml | 3 ++ soap-example.xml | 12 +++++ 8 files changed, 424 insertions(+) create mode 100644 SOAPClient.class create mode 100644 SOAPClient.java create mode 100644 SOAPClient.java.bak create mode 100644 SOAPClient4XG.class create mode 100644 SOAPClient4XG.java create mode 100644 SOAPClient4XG.java.bak create mode 100644 message.xml create mode 100644 soap-example.xml diff --git a/SOAPClient.class b/SOAPClient.class new file mode 100644 index 0000000000000000000000000000000000000000..8a8916404680f1c0eb3d5122d753913a363334cc GIT binary patch literal 2368 zcmZuyTW=Fb6#h1`y_?OFfJsO;+{~>wP8>IZQg8@q90C}eI3$5$QlJ}q>@2mt#$Jbn z-f#3muk=P+scNfAd4>lE)fH4ARcasl3;NtX^`-AEJ+qGOt%@w2@tkw!%s1cpX7-nV zzP|&YA7991hMVvNMkIt}jN-6_F`4E^BpelSOooIoH^)Vs5D}4~AS_~BMhk{zJc<eK ziSp^Bgp)F+FfF4QGZIcoI4$8x31_$?#?4u7X8Cqci8v=?3x*|}=i>z)d7A$t(+o|< z9OB$WMI^X~$=Hpgh?EQ;=DE?ip`9<{8J?IHkr9y<;5w*hb@PybMsN3N0gh24!34BM z^emewX69IaMw?5M$C1%=O5fm}ja<|gv_M+RrUKJuUeBfm`9gVYG0t+PZe$B049bri zxg`O8-b%V|1j5-|(WDhj%M8|>(V|)RcAplJqf*mGF&}3~biQxvbaZ5LG_A9&*~d3l zFn~Q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uAn>ET!t^EHm{&3sHjQ_y|Lh$pU^@z)itzy z`N5yu>#q}am6!!Oh_Fr~XCpRX6S}aKzO)`}r{6B@Ko52zK;PE`@Y1)r8%Jq&lDcu0 zXw``BBvG897yAkh(rY?|YdD1K7{(3C{t6+KaTxb7hM#c+zv4K4Lj-?d5`R&ZzcDQ| zU<UgMg@c-QfLcaxf2C#khI|r5#(c5ydp)s<d+P-JAO#&h-if|_&UR<R*KjSPwMTU{ zwo?}a%MX6{-(RLKx%~H4*WF(0zu0?U74P1(iuGAC>L=J-P7c~^h{hp|SYt&!KFH)d lPtgmsy@poAiJ}Bi!sz%(^dd!o=jm8_4fsI<&nq?H(7)Z|L#6-# literal 0 HcmV?d00001 diff --git a/SOAPClient.java b/SOAPClient.java new file mode 100644 index 00000000..5ce10b46 --- /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 00000000..10c86c19 --- /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..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rrd4_vD; zMxedMbX3u4DoPby9_>CuAZ60F=M>jtzB2?<rtcItVt&(KMQ<vm{)vuXaMM()Fi+n8 zE2Vu6d~@g`B)x>F9|i@}O$d8&kGL^}F;3hB?qd><Fh%d>ERFs=USNp^XBmQ?%ws&k zXXHVlI6tQ-?;vy$<<BIOQ7#UqR^JSz*4}h8{HDc}K?(MQ3186H@)P_g=o~VY)}XJ7 z4^Q6y6FEPD9`i@eP5<j*k5`A!P4)FF&)Eq57v#TT+*=jIFhlzpf+g2l!Uv%fzeW1n lbo~xGu}cB%Q9#cqpywDS_)~a^1$r3jz{6xaNLDQv`X6tSg;oFn literal 0 HcmV?d00001 diff --git a/SOAPClient4XG.java b/SOAPClient4XG.java new file mode 100644 index 00000000..ca0d38f4 --- /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 00000000..6e126141 --- /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 00000000..54ad9155 --- /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 00000000..ba46893b --- /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> -- GitLab