1 package org.apache.soap.server; 2 3 import java.io.*; 4 import java.util.*; 5 import java.lang.reflect.*; 6 import org.w3c.dom.*; 7 import org.apache.soap.util.Bean; 8 import org.apache.soap.util.MethodUtils; 9 import org.apache.soap.util.IOUtils; 10 import org.apache.soap.*; 11 import org.apache.soap.rpc.*; 12 13 20 public class MessageRouter { 21 24 public static boolean validMessage (DeploymentDescriptor dd, 25 String messageName) { 26 String [] pubMessages = dd.getMethods (); 27 for (int i = 0; i < pubMessages.length; i++) { 28 if (messageName.equals (pubMessages[i])) { 29 return true; 30 } 31 } 32 return false; 33 } 34 35 39 40 public static void invoke (DeploymentDescriptor dd, Envelope env, 41 Object targetObject, String messageName, 42 SOAPContext reqCtx, SOAPContext resCtx) 43 throws SOAPException { 44 byte providerType = dd.getProviderType (); 45 46 try { 47 Class [] argTypes = new Class [] { Envelope.class, SOAPContext.class, 50 SOAPContext.class }; 51 Object [] args = new Object [] { env, reqCtx, resCtx }; 52 53 if (providerType == DeploymentDescriptor.PROVIDER_JAVA) { 54 Method m = MethodUtils.getMethod (targetObject, messageName, 55 argTypes); 56 Object resObj = m.invoke (targetObject, args); 57 } else { 58 Class bc = Class.forName ("org.apache.soap.server.InvokeBSF"); 61 62 Class [] sig = {DeploymentDescriptor.class, 64 Object .class, 65 String .class, 66 Object [].class}; 67 Method m = MethodUtils.getMethod (bc, "service", sig, true); 68 m.invoke (null, new Object [] {dd, targetObject, messageName, args}); 69 } 70 } catch (InvocationTargetException e) { 71 Throwable t = e.getTargetException(); 72 73 if (t instanceof SOAPException) { 74 throw (SOAPException)t; 75 } else { 76 throw new SOAPException(Constants.FAULT_CODE_SERVER, 77 "Exception from service object: " + 78 t.getMessage (), t); 79 } 80 } catch (ClassNotFoundException e) { 81 throw new SOAPException (Constants.FAULT_CODE_SERVER, 82 "Unable to load BSF: script services " + 83 "unsupported without BSF", e); 84 } catch (Throwable t) { 85 throw new SOAPException (Constants.FAULT_CODE_SERVER, 86 "Exception while handling service request: " + 87 t.getMessage(), t); 88 } 89 } 90 } 91 | Popular Tags |