1 55 56 package org.jboss.axis.transport.local; 57 58 import org.jboss.axis.AxisFault; 59 import org.jboss.axis.Constants; 60 import org.jboss.axis.Message; 61 import org.jboss.axis.MessageContext; 62 import org.jboss.axis.attachments.Attachments; 63 import org.jboss.axis.handlers.BasicHandler; 64 import org.jboss.axis.message.SOAPEnvelopeAxisImpl; 65 import org.jboss.axis.message.SOAPFaultImpl; 66 import org.jboss.axis.server.AxisServer; 67 import org.jboss.axis.utils.Messages; 68 import org.jboss.logging.Logger; 69 70 import java.net.URL ; 71 72 77 public class LocalSender extends BasicHandler 78 { 79 private static Logger log = Logger.getLogger(LocalSender.class.getName()); 80 81 private volatile AxisServer server; 82 83 86 public synchronized void init() 87 { 88 this.server = new AxisServer(); 89 } 90 91 public void invoke(MessageContext clientContext) throws AxisFault 92 { 93 if (log.isDebugEnabled()) 94 { 95 log.debug("Enter: LocalSender::invoke"); 96 } 97 98 AxisServer targetServer = 99 (AxisServer)clientContext.getProperty(LocalTransport.LOCAL_SERVER); 100 101 if (log.isDebugEnabled()) 102 { 103 log.debug(Messages.getMessage("usingServer00", 104 "LocalSender", "" + targetServer)); 105 } 106 107 if (targetServer == null) 108 { 109 if (server == null) init(); 112 targetServer = server; 113 } 114 115 MessageContext serverContext = new MessageContext(targetServer); 117 118 121 123 Message clientRequest = clientContext.getRequestMessage(); 124 125 String msgStr = clientRequest.getSOAPPartAsString(); 126 127 if (log.isDebugEnabled()) 128 { 129 log.debug(Messages.getMessage("sendingXML00", "LocalSender")); 130 log.debug(msgStr); 131 } 132 133 Message serverRequest = new Message(msgStr); 134 135 Attachments serverAttachments = serverRequest.getAttachmentsImpl(); 136 Attachments clientAttachments = clientRequest.getAttachmentsImpl(); 137 138 if (null != clientAttachments && null != serverAttachments) 139 { 140 serverAttachments.setAttachmentParts(clientAttachments.getAttachments()); 141 } 142 143 serverContext.setRequestMessage(serverRequest); 144 145 147 serverContext.setTransportName("local"); 148 149 String user = clientContext.getUsername(); 151 if (user != null) 152 { 153 serverContext.setUsername(user); 154 String pass = clientContext.getPassword(); 155 if (pass != null) 156 serverContext.setPassword(pass); 157 } 158 159 String transURL = clientContext.getStrProp(MessageContext.TRANS_URL); 161 if (transURL != null) 162 { 163 try 164 { 165 URL url = new URL (transURL); 166 String file = url.getFile(); 167 if (file.length() > 0 && file.charAt(0) == '/') file = file.substring(1); 168 serverContext.setProperty(Constants.MC_REALPATH, file); 169 170 serverContext.setTargetService(file); 172 } 173 catch (Exception e) 174 { 175 throw AxisFault.makeFault(e); 176 } 177 } 178 179 String remoteService = clientContext.getStrProp(LocalTransport.REMOTE_SERVICE); 183 if (remoteService != null) 184 serverContext.setTargetService(remoteService); 185 186 try 188 { 189 targetServer.invoke(serverContext); 190 } 191 catch (AxisFault fault) 192 { 193 Message respMsg = serverContext.getResponseMessage(); 194 if (respMsg == null) 195 { 196 respMsg = new Message(fault); 197 serverContext.setResponseMessage(respMsg); 198 } 199 else 200 { 201 SOAPFaultImpl faultEl = new SOAPFaultImpl(fault); 202 SOAPEnvelopeAxisImpl env = respMsg.getSOAPEnvelope(); 203 env.clearBody(); 204 env.addBodyElement(faultEl); 205 } 206 } 207 208 clientContext.setResponseMessage(serverContext.getResponseMessage()); 211 213 if (log.isDebugEnabled()) 214 { 215 log.debug("Exit: LocalSender::invoke"); 216 } 217 } 218 } 219 | Popular Tags |