1 55 56 package org.jboss.axis.client; 57 58 import org.jboss.axis.AxisEngine; 59 import org.jboss.axis.AxisFault; 60 import org.jboss.axis.Constants; 61 import org.jboss.axis.EngineConfiguration; 62 import org.jboss.axis.Handler; 63 import org.jboss.axis.MessageContext; 64 import org.jboss.axis.configuration.EngineConfigurationFactoryFinder; 65 import org.jboss.axis.handlers.HandlerChainImpl; 66 import org.jboss.axis.handlers.HandlerInfoChainFactory; 67 import org.jboss.axis.handlers.soap.SOAPService; 68 import org.jboss.axis.utils.Messages; 69 import org.jboss.logging.Logger; 70 71 import javax.xml.namespace.QName ; 72 73 82 public class AxisClient extends AxisEngine 83 { 84 private static Logger log = Logger.getLogger(AxisClient.class.getName()); 85 86 public AxisClient(EngineConfiguration config) 87 { 88 super(config); 89 } 90 91 public AxisClient() 92 { 93 this(EngineConfigurationFactoryFinder.newFactory().getClientEngineConfig()); 94 } 95 96 99 public AxisEngine getClientEngine() 100 { 101 return this; 102 } 103 104 108 public void invoke(MessageContext msgContext) throws AxisFault 109 { 110 if (log.isDebugEnabled()) 111 { 112 log.debug("Enter: AxisClient::invoke"); 113 } 114 115 String hName = null; 116 Handler h = null; 117 118 MessageContext previousContext = getCurrentMessageContext(); 120 121 try 122 { 123 setCurrentMessageContext(msgContext); 125 126 hName = msgContext.getStrProp(MessageContext.ENGINE_HANDLER); 127 if (log.isDebugEnabled()) 128 { 129 log.debug("EngineHandler: " + hName); 130 } 131 132 if (hName != null) 133 { 134 h = getHandler(hName); 135 if (h != null) 136 h.invoke(msgContext); 137 else 138 throw new AxisFault("Client.error", 139 Messages.getMessage("noHandler00", hName), 140 null, null); 141 } 142 else 143 { 144 147 148 149 150 151 152 153 154 155 156 157 158 160 SOAPService service = null; 161 msgContext.setPastPivot(false); 162 163 164 165 service = msgContext.getService(); 166 if (service != null) 167 { 168 h = service.getRequestHandler(); 169 if (h != null) 170 h.invoke(msgContext); 171 } 172 173 174 175 if ((h = getGlobalRequest()) != null) 176 h.invoke(msgContext); 177 178 179 invokeJAXRPCHandlers(msgContext); 180 181 187 hName = msgContext.getTransportName(); 188 if (hName != null && (h = getTransport(hName)) != null) 189 { 190 h.invoke(msgContext); 191 } 192 else 193 { 194 throw new AxisFault(Messages.getMessage("noTransport00", hName)); 195 } 196 197 198 invokeJAXRPCHandlers(msgContext); 199 200 201 202 if ((h = getGlobalResponse()) != null) 203 { 204 h.invoke(msgContext); 205 } 206 207 if (service != null) 208 { 209 h = service.getResponseHandler(); 210 if (h != null) 211 { 212 h.invoke(msgContext); 213 } 214 } 215 216 } 219 220 } 221 catch (Exception e) 222 { 223 log.debug(Messages.getMessage("exception00"), e); 225 throw AxisFault.makeFault(e); 226 227 } 228 finally 229 { 230 setCurrentMessageContext(previousContext); 232 } 233 234 if (log.isDebugEnabled()) 235 { 236 log.debug("Exit: AxisClient::invoke"); 237 } 238 } 239 240 protected void invokeJAXRPCHandlers(MessageContext context) 241 { 242 java.util.List chain = null; 243 HandlerInfoChainFactory hiChainFactory = null; 244 boolean clientSpecified = false; 245 246 Service service 247 = (Service)context.getProperty(Call.WSDL_SERVICE); 248 if (service == null) 249 { 250 return; 251 } 252 253 QName portName = (QName )context.getProperty(Call.WSDL_PORT_NAME); 254 if (portName == null) 255 { 256 return; 257 } 258 259 javax.xml.rpc.handler.HandlerRegistry registry; 260 registry = service.getHandlerRegistry(); 261 if (registry != null) 262 { 263 chain = registry.getHandlerChain(portName); 264 if ((chain != null) && (!chain.isEmpty())) 265 { 266 hiChainFactory = new HandlerInfoChainFactory(chain); 267 clientSpecified = true; 268 } 269 } 270 271 if (!clientSpecified) 273 { 274 SOAPService soapService = context.getService(); 275 if (soapService != null) 276 { 277 hiChainFactory = (HandlerInfoChainFactory) 280 soapService.getOption(Constants.ATTR_HANDLERINFOCHAIN); 281 } 282 } 283 284 if (hiChainFactory == null) 285 { 286 return; 287 } 288 HandlerChainImpl impl = (HandlerChainImpl)hiChainFactory.createHandlerChain(); 289 290 if (!context.getPastPivot()) 291 { 292 impl.handleRequest(context); 293 } 294 else 295 { 296 impl.handleResponse(context); 297 } 298 impl.destroy(); 299 } 300 } 301 302 | Popular Tags |