X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FSOAP.java;h=f3ce759de97ccb361e22425b6183af7c02293c23;hb=16c24a73c1c1b2955db0bbbaf5a940215329bca1;hp=113e01bb52cb06f6604eb396f52f4d1e941593a3;hpb=8c1756ef3fd42cc2f324baf47e13a83f51045efe;p=org.ibex.core.git diff --git a/src/org/xwt/SOAP.java b/src/org/xwt/SOAP.java index 113e01b..f3ce759 100644 --- a/src/org/xwt/SOAP.java +++ b/src/org/xwt/SOAP.java @@ -1,4 +1,4 @@ -// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] package org.xwt; import java.io.*; @@ -29,7 +29,7 @@ class SOAP extends XMLRPC { /** When you get a property from an SOAP, it just returns another SOAP with the property name tacked onto methodname. */ public Object get(String name) { - return new SOAP(url.toString(), (methodname.equals("") ? "" : methodname + ".") + name, http, action, nameSpace); + return new SOAP(url.toString(), (method.equals("") ? "" : method + ".") + name, http, action, nameSpace); } @@ -92,7 +92,7 @@ class SOAP extends XMLRPC { } else if (me instanceof byte[]) { objects.removeElementAt(objects.size() - 1); - objects.addElement(new Res.ByteArray(Base64.decode(new String(content.getBuf(), 0, content.size())), null)); + objects.addElement(new Stream.ByteArray(Base64.decode(new String(content.getBuf(), 0, content.size())), null)); content.reset(); } else if (me instanceof Integer) { @@ -153,14 +153,18 @@ class SOAP extends XMLRPC { } else if (parent != null && parent instanceof JS) { objects.removeElementAt(objects.size() - 1); - ((JS)parent).put(name, me); + try { + ((JS)parent).put(name, me); + } catch (JSExn e) { + throw new Error("this should never happen"); + } } } /** Appends the SOAP representation of o to sb */ - void appendObject(String name, Object o, StringBuffer sb) throws JS.Exn { + void appendObject(String name, Object o, StringBuffer sb) throws JSExn { if (o instanceof Number) { if ((double)((Number)o).intValue() == ((Number)o).doubleValue()) { sb.append(" <" + name + " xsi:type=\"xsd:int\">"); @@ -177,10 +181,10 @@ class SOAP extends XMLRPC { sb.append(((Boolean)o).booleanValue() ? "true" : "false"); sb.append("\r\n"); - } else if (o instanceof Res) { + } else if (o instanceof Stream) { try { sb.append(" <" + name + " xsi:type=\"SOAP-ENC:base64\">\r\n"); - InputStream is = ((Res)o).getInputStream(); + InputStream is = ((Stream)o).getInputStream(); byte[] buf = new byte[54]; while(true) { int numread = is.read(buf, 0, 54); @@ -197,9 +201,9 @@ class SOAP extends XMLRPC { sb.append(((Boolean)o).booleanValue() ? "1" : "0"); sb.append("\r\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 JS.Exn("caught IOException while attempting to send a ByteStream via SOAP"); + if (Log.on) Log.info(this, "caught IOException while attempting to send a ByteStream via SOAP"); + if (Log.on) Log.info(this, e); + throw new JSExn("caught IOException while attempting to send a ByteStream via SOAP"); } } else if (o instanceof String) { @@ -240,7 +244,7 @@ class SOAP extends XMLRPC { } } - protected String send(JSArray args, HTTP http) throws JS.Exn, IOException { + protected String buildRequest(JSArray args) throws JSExn, IOException { // build up the request StringBuffer content = new StringBuffer(); content.append("SOAPAction: " + action + "\r\n\r\n"); @@ -252,7 +256,7 @@ class SOAP extends XMLRPC { content.append(" xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\">\r\n"); content.append("\r\n"); content.append(" <"); - content.append(methodname); + content.append(method); content.append(nameSpace != null ? " xmlns=\"" + nameSpace + "\"" : ""); content.append(">\r\n"); if (args.length() > 0) { @@ -262,11 +266,13 @@ class SOAP extends XMLRPC { appendObject((String)key, ((JS)args.elementAt(0)).get(key), content); } } - content.append(" \r\n"); + content.append(" \r\n"); return content.toString(); } - SOAP(String url, String methodname, String action, String nameSpace) { this(url, methodname, new HTTP(url), action, nameSpace); } + SOAP(String url, String methodname, String action, String nameSpace) { + this(url, methodname, new HTTP(url), action, nameSpace); + } SOAP(String url, String methodname, HTTP http, String action, String nameSpace) { super(url, methodname, http); this.action = action;