1 package Jt.axis; 2 import java.util.*; 3 import java.lang.reflect.*; 4 import java.beans.*; 5 import java.io.*; 6 import Jt.xml.*; 7 import Jt.*; 8 import org.apache.axis.*; 9 import org.apache.axis.session.*; 10 11 14 15 public class JtAxisService extends JtObject { 16 17 18 JtScriptInterpreter reader = null; 19 JtXMLHelper xmlHelper = null; 20 21 public JtAxisService() { 22 } 23 24 25 27 String convertToXML (Object scriptOutput) { 28 29 Exception ex; 30 JtMessage msg = new JtMessage (); 31 JtList lst; 32 33 ex = (Exception ) 34 getValue (reader, "objException"); 35 36 if (xmlHelper == null) 37 xmlHelper = new JtXMLHelper (); 38 39 if (ex == null) { 40 msg.setMsgId ("JtCONVERT_OBJECT_TO_XML"); 41 msg.setMsgContent (scriptOutput); 42 return ((String ) sendMessage (xmlHelper, msg)); 43 } 44 45 lst = new JtList (); 46 47 msg.setMsgId ("JtADD"); 48 if (scriptOutput != null) { 49 msg.setMsgContent (scriptOutput); 50 lst.processMessage (msg); 52 } 53 msg.setMsgContent (ex); 55 sendMessage (lst, msg); 56 57 msg.setMsgId ("JtCONVERT_OBJECT_TO_XML"); 58 msg.setMsgContent (lst); 59 return ((String ) sendMessage (xmlHelper, msg)); 60 61 } 62 63 64 70 71 72 public String processMessage (String xmlMessage) { 73 JtMessage msg; 74 Object scriptOutput = null; 75 MessageContext mc = MessageContext. 76 getCurrentContext(); 77 Session session = mc.getSession(); 78 String name = (String )session.get("name"); 79 80 if (xmlMessage == null) 81 return (null); 82 83 84 85 88 90 91 msg = new JtMessage ("JtPARSE"); 92 94 96 97 if (reader == null) { 98 reader = (JtScriptInterpreter) this.createObject ("Jt.xml.JtScriptInterpreter", 99 "root"); 100 setValue (reader, "remoteInvocation", "true"); 101 } 102 103 setValue (reader, "content", xmlMessage); 104 setValue (reader, "objException", null); 105 107 scriptOutput = sendMessage (reader, msg); 108 109 return (convertToXML (scriptOutput)); 110 111 112 } 113 114 115 118 119 120 public static void main(String [] args) { 121 122 JtObject main = new JtObject (); 123 JtMessage msg1, msg2; 124 Integer count; 125 JtXMLMsgReader reader; JtAxisService adapter; 127 String str; 128 129 132 133 if (args.length < 1) { 134 System.err.println ("Usage: java JtAxisService uri"); 135 System.exit (1); 136 } 137 138 msg1 = new JtMessage (); 139 msg2 = new JtMessage (); 140 141 142 main.createObject ("Jt.JtFile", "file"); 143 main.setValue ("file", "name", args[0]); 144 main.setValue (msg1, "msgId", "JtCONVERT_TO_STRING"); 145 146 str = (String ) main.sendMessage ("file", msg1); 147 148 msg1.setMsgId ("JtMessage1"); 149 msg2.setMsgId ("JtMessage2"); 150 151 152 154 155 adapter = (JtAxisService) main.createObject ("Jt.axis.JtAxisService", 156 "adapter"); 157 158 adapter.processMessage (str); 159 160 161 } 162 163 } 164 165 166 | Popular Tags |