X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FSOAP.java;h=2771304bc23bd81eb7815dddd566675e9a03cd59;hb=8235361e8601ae7b36ab707058de3b52225d15a2;hp=3c3ed7d62fe39015c01711efcbebf2008c3ade42;hpb=332e36ef93698b95c1f109dc236d6e53c201dd0f;p=org.ibex.core.git diff --git a/src/org/xwt/SOAP.java b/src/org/xwt/SOAP.java index 3c3ed7d..2771304 100644 --- a/src/org/xwt/SOAP.java +++ b/src/org/xwt/SOAP.java @@ -1,10 +1,10 @@ -// Copyright 2002 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] package org.xwt; import java.io.*; import java.net.*; import java.util.*; -import org.mozilla.javascript.*; +import org.xwt.js.*; import org.xwt.util.*; import org.bouncycastle.util.encoders.Base64; @@ -28,7 +28,7 @@ class SOAP extends XMLRPC { String nameSpace = null; /** 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, Scriptable start) { + public Object get(String name) { return new SOAP(url.toString(), (methodname.equals("") ? "" : methodname + ".") + name, http, action, nameSpace); } @@ -41,9 +41,9 @@ class SOAP extends XMLRPC { if (name.equals("SOAP-ENV:Envelope")) return; if (name.equals("SOAP-ENV:Body")) return; if (name.equals("SOAP-ENV:Fault")) fault = true; - + // add a generic struct; we'll change this if our type is different - objects.addElement(new JSObject(false)); + objects.addElement(new JS.Obj()); for(int i=0; io to sb */ - void appendObject(String name, Object o, StringBuffer sb) throws JavaScriptException { + void appendObject(String name, Object o, StringBuffer sb) throws JS.Exn { if (o instanceof Number) { if ((double)((Number)o).intValue() == ((Number)o).doubleValue()) { sb.append(" <" + name + " xsi:type=\"xsd:int\">"); sb.append(((Number)o).intValue()); - sb.append("\n"); + sb.append("\r\n"); } else { sb.append(" <" + name + " xsi:type=\"xsd:double\">"); sb.append(o); - sb.append("\n"); + sb.append("\r\n"); } } else if (o instanceof Boolean) { sb.append(" <" + name + " xsi:type=\"xsd:boolean\">"); sb.append(((Boolean)o).booleanValue() ? "true" : "false"); - sb.append("\n"); + sb.append("\r\n"); - } else if (o instanceof ByteStream) { + } else if (o instanceof Res) { try { - sb.append(" <" + name + " xsi:type=\"SOAP-ENC:base64\">\n"); - InputStream is = ((ByteStream)o).getInputStream(); + sb.append(" <" + name + " xsi:type=\"SOAP-ENC:base64\">\r\n"); + InputStream is = ((Res)o).getInputStream(); byte[] buf = new byte[54]; while(true) { int numread = is.read(buf, 0, 54); @@ -192,14 +192,14 @@ class SOAP extends XMLRPC { } sb.append(" "); sb.append(new String(Base64.encode(writebuf))); - sb.append("\n"); + sb.append("\r\n"); } sb.append(((Boolean)o).booleanValue() ? "1" : "0"); - sb.append("\n"); + 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 JavaScriptException("caught IOException while attempting to send a ByteStream via SOAP"); + throw new JS.Exn("caught IOException while attempting to send a ByteStream via SOAP"); } } else if (o instanceof String) { @@ -219,46 +219,44 @@ class SOAP extends XMLRPC { i = oldi = i + 1; } } - sb.append("\n"); + sb.append("\r\n"); - } else if (o instanceof NativeArray) { - NativeArray na = (NativeArray)o; - sb.append(" <" + name + " SOAP-ENC:arrayType=\"xsd:ur-type[" + na.jsGet_length() + "]\">"); - for(int i=0; i\n"); + } else if (o instanceof JS.Array) { + JS.Array a = (JS.Array)o; + sb.append(" <" + name + " SOAP-ENC:arrayType=\"xsd:ur-type[" + a.length() + "]\">"); + for(int i=0; i\r\n"); - } else if (o instanceof Scriptable && !(o instanceof Undefined)) { - Scriptable s = (Scriptable)o; + } else if (o instanceof JS) { + JS j = (JS)o; sb.append(" <" + name + ">"); - Object[] ids = s.getIds(); - for(int i=0; i\n"); + Object[] ids = j.keys(); + for(int i=0; i\r\n"); } } - protected String send(Object[] args, HTTP http) throws JavaScriptException, IOException { + protected String send(JS.Array args, HTTP http) throws JS.Exn, IOException { // build up the request StringBuffer content = new StringBuffer(); content.append("SOAPAction: " + action + "\r\n\r\n"); - content.append("\n"); - content.append("\n"); - content.append("\n"); + content.append("\r\n"); + content.append("\r\n"); + content.append("\r\n"); content.append(" <"); content.append(methodname); content.append(nameSpace != null ? " xmlns=\"" + nameSpace + "\"" : ""); - content.append(">\n"); - if (args.length > 0) { - Object[] o = ((Scriptable)args[0]).getIds(); + content.append(">\r\n"); + if (args.length() > 0) { + Object[] o = ((JS)args.elementAt(0)).keys(); for(int i=0; i"); + content.append(" \r\n"); return content.toString(); }