1 55 56 package org.jboss.axis.providers.java; 57 58 import org.jboss.axis.AxisFault; 59 import org.jboss.axis.MessageContext; 60 import org.jboss.axis.description.OperationDesc; 61 import org.jboss.axis.i18n.Messages; 62 import org.jboss.axis.message.SOAPBodyElementAxisImpl; 63 import org.jboss.axis.message.SOAPEnvelopeAxisImpl; 64 import org.w3c.dom.Document ; 65 import org.w3c.dom.Element ; 66 67 import java.lang.reflect.Method ; 68 import java.util.Vector ; 69 70 86 public class MsgProvider extends JavaProvider 87 { 88 101 public void processMessage(MessageContext msgContext, 102 SOAPEnvelopeAxisImpl reqEnv, 103 SOAPEnvelopeAxisImpl resEnv, 104 Object obj) 105 throws Exception 106 { 107 OperationDesc operation = msgContext.getOperation(); 108 if (operation == null) 109 { 110 throw new AxisFault(Messages.getMessage("noOperationForQName", 111 reqEnv.getFirstBody(). 112 getQName().toString())); 113 } 114 115 Method method = operation.getMethod(); 116 117 int methodType = operation.getMessageOperationStyle(); 118 119 if (methodType != OperationDesc.MSG_METHOD_SOAPENVELOPE) 120 { 121 Vector bodies = reqEnv.getBodyElements(); 123 Object argObjects[] = new Object [1]; 124 125 switch (methodType) 126 { 127 case OperationDesc.MSG_METHOD_BODYARRAY: 129 SOAPBodyElementAxisImpl[] bodyElements = 130 new SOAPBodyElementAxisImpl[bodies.size()]; 131 bodies.toArray(bodyElements); 132 argObjects[0] = bodyElements; 133 SOAPBodyElementAxisImpl[] bodyResult = (SOAPBodyElementAxisImpl[])method.invoke(obj, argObjects); 134 if (bodyResult != null) 135 { 136 for (int i = 0; i < bodyResult.length; i++) 137 { 138 SOAPBodyElementAxisImpl bodyElement = bodyResult[i]; 139 resEnv.addBodyElement(bodyElement); 140 } 141 } 142 return; 143 144 case OperationDesc.MSG_METHOD_ELEMENTARRAY: 146 Element [] elements = new Element [bodies.size()]; 147 for (int i = 0; i < elements.length; i++) 148 { 149 SOAPBodyElementAxisImpl body = (SOAPBodyElementAxisImpl)bodies.get(i); 150 elements[i] = body.getAsDOM(); 151 } 152 argObjects[0] = elements; 153 Element [] elemResult = (Element [])method.invoke(obj, argObjects); 154 if (elemResult != null) 155 { 156 for (int i = 0; i < elemResult.length; i++) 157 { 158 if (elemResult[i] != null) 159 resEnv.addBodyElement(new SOAPBodyElementAxisImpl(elemResult[i])); 160 } 161 } 162 return; 163 164 case OperationDesc.MSG_METHOD_DOCUMENT: 166 Document doc = ((SOAPBodyElementAxisImpl)bodies.get(0)).getAsDocument(); 167 argObjects[0] = doc; 168 Document resultDoc = (Document )method.invoke(obj, argObjects); 169 if (resultDoc != null) 170 { 171 resEnv.addBodyElement(new SOAPBodyElementAxisImpl(resultDoc.getDocumentElement())); 172 } 173 return; 174 } 175 } 176 else 177 { 178 Object argObjects[] = new Object [2]; 179 180 argObjects[0] = reqEnv; 182 argObjects[1] = resEnv; 183 method.invoke(obj, argObjects); 184 return; 185 } 186 187 throw new AxisFault(Messages.getMessage("badMsgMethodStyle")); 189 } 190 } 191 192 ; 193 | Popular Tags |