X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FSOAP.java;h=a36e9a986538153d5a1f1a93d50008d4253fae48;hb=1296555e827bcd7606b7d82b6c1f2a875ff22e2c;hp=ade85e5e0c6f86f578e489ef0462afc3be20a329;hpb=fa18ff2c6785c96c00d19092338f404ad7f6240c;p=org.ibex.core.git
diff --git a/src/org/xwt/SOAP.java b/src/org/xwt/SOAP.java
index ade85e5..a36e9a9 100644
--- a/src/org/xwt/SOAP.java
+++ b/src/org/xwt/SOAP.java
@@ -37,6 +37,7 @@ class SOAP extends XMLRPC {
public void startElement(String name, String[] keys, Object[] vals, int line, int col) {
+ content.reset();
if (name.equals("SOAP-ENV:Envelope")) return;
if (name.equals("SOAP-ENV:Body")) return;
if (name.equals("SOAP-ENV:Fault")) fault = true;
@@ -91,7 +92,7 @@ class SOAP extends XMLRPC {
} else if (me instanceof byte[]) {
objects.removeElementAt(objects.size() - 1);
- objects.addElement(new String(Base64.decode(new String(content.getBuf(), 0, content.size()))));
+ objects.addElement(new ByteStream(Base64.decode(new String(content.getBuf(), 0, content.size()))));
content.reset();
} else if (me instanceof Integer) {
@@ -159,7 +160,7 @@ class SOAP extends XMLRPC {
}
/** Appends the SOAP representation of o
to sb
*/
- void appendObject(String name, Object o, StringBuffer sb) {
+ void appendObject(String name, Object o, StringBuffer sb) throws JavaScriptException {
if (o instanceof Number) {
if ((double)((Number)o).intValue() == ((Number)o).doubleValue()) {
sb.append(" <" + name + " xsi:type=\"xsd:int\">");
@@ -176,6 +177,31 @@ class SOAP extends XMLRPC {
sb.append(((Boolean)o).booleanValue() ? "true" : "false");
sb.append("" + name + ">\n");
+ } else if (o instanceof ByteStream) {
+ try {
+ sb.append(" <" + name + " xsi:type=\"SOAP-ENC:base64\">\n");
+ InputStream is = ((ByteStream)o).getInputStream();
+ byte[] buf = new byte[54];
+ while(true) {
+ int numread = is.read(buf, 0, 54);
+ if (numread == -1) break;
+ byte[] writebuf = buf;
+ if (numread < buf.length) {
+ writebuf = new byte[numread];
+ System.arraycopy(buf, 0, writebuf, 0, numread);
+ }
+ sb.append(" ");
+ sb.append(new String(Base64.encode(writebuf)));
+ sb.append("\n");
+ }
+ sb.append(((Boolean)o).booleanValue() ? "1" : "0");
+ sb.append("" + name + ">\n");
+ } catch (IOException e) {
+ if (Log.on) Log.log(this, "caught IOException while attempting to send a ByteStream via SOAP");
+ if (Log.on) Log.log(this, e);
+ throw new JavaScriptException("caught IOException while attempting to send a ByteStream via SOAP");
+ }
+
} else if (o instanceof String) {
sb.append(" <" + name + " xsi:type=\"xsd:string\">");
String s = (String)o;