1 package test.RPCDispatch; 2 3 import org.apache.axis.Message; 4 import org.apache.axis.MessageContext; 5 import org.apache.axis.AxisFault; 6 import org.apache.axis.message.RPCElement; 7 import org.apache.axis.utils.DOM2Writer; 8 import org.w3c.dom.Node ; 9 import org.w3c.dom.NodeList ; 10 11 14 public class Service { 15 16 19 public String reverseString(String input) throws Exception { 20 String result = ""; 21 for (int i=input.length(); i>0; ) result+=input.charAt(--i); 22 return result; 23 } 24 25 29 public String concatenate(String a1, String a2) 30 { 31 return a1 + a2; 32 } 33 34 37 public Data reverseData(Data input) throws Exception { 38 Data result = new Data(); 39 result.setField1(input.getField3()); 40 result.setField2(reverseString(input.getField2())); 41 result.setField3(input.getField1()); 42 return result; 43 } 44 45 48 public String targetServiceImplicit() throws Exception { 49 return MessageContext.getCurrentContext().getTargetService(); 50 } 51 52 55 public String argAsDOM(Data input) throws Exception { 56 57 Message message = MessageContext.getCurrentContext().getRequestMessage(); 59 RPCElement body = (RPCElement)message.getSOAPEnvelope().getFirstBody(); 60 NodeList parms = body.getAsDOM().getChildNodes(); 61 Node parm1 = null; 62 for (int i=0; i<parms.getLength(); i++) { 63 parm1 = parms.item(i); 64 if (parm1.getNodeType() == Node.ELEMENT_NODE) break; 65 } 66 67 return DOM2Writer.nodeToString(parm1, true); 69 70 } 71 72 75 public Integer echoInt(Integer value) throws Exception { 76 return value; 77 } 78 79 82 public String overloaded(boolean b, String s) 83 { 84 return b + s; 85 } 86 87 90 public String overloaded(String s, boolean b) 91 { 92 return s + b; 93 } 94 95 98 public boolean overloaded(boolean b) 99 { 100 return b; 101 } 102 103 106 public Boolean testBoolean(Boolean b) 107 { 108 return b; 109 } 110 111 114 public Float testFloat(Float b) 115 { 116 return b; 117 } 118 119 122 public Double testDouble(Double b) 123 { 124 return b; 125 } 126 127 131 public int overloaded(int i) 132 { 133 return i; 134 } 135 136 139 public String overloaded(int i, String s) 140 { 141 return i + s; 142 } 143 144 148 public void arrayMethod(String [] arg) throws AxisFault { 149 throw new AxisFault("You shouldn't have called me!"); 150 } 151 152 155 class TestFault extends Exception { 156 TestFault(String msg) throws Exception { 157 super(msg); 158 if (msg == null) throw new Exception ("default value"); 159 } 160 } 161 162 165 public String simpleFault(String value) throws Exception { 166 TestFault fault = new TestFault(value); 167 throw fault; 168 } 169 170 171 } 172 | Popular Tags |