1 55 package org.jboss.axis.soap; 56 57 import org.jboss.axis.AxisFault; 58 import org.jboss.axis.Constants; 59 import org.jboss.axis.Message; 60 import org.jboss.axis.attachments.Attachments; 61 import org.jboss.axis.client.Call; 62 import org.jboss.axis.message.SOAPEnvelopeAxisImpl; 63 import org.jboss.axis.transport.http.HTTPConstants; 64 import org.jboss.axis.utils.Messages; 65 import org.jboss.logging.Logger; 66 import org.w3c.dom.Element ; 67 68 import javax.xml.soap.MimeHeader ; 69 import javax.xml.soap.MimeHeaders ; 70 import javax.xml.soap.SOAPException ; 71 import javax.xml.soap.SOAPMessage ; 72 import java.net.MalformedURLException ; 73 import java.util.Hashtable ; 74 import java.util.Iterator ; 75 76 81 public class SOAPConnectionImpl extends javax.xml.soap.SOAPConnection 82 { 83 boolean closed = false; 84 85 private static Logger log = Logger.getLogger(SOAPConnectionImpl.class.getName()); 86 87 100 public SOAPMessage call(SOAPMessage request, Object endpoint) 101 throws SOAPException 102 { 103 if (closed) 104 { 105 throw new SOAPException (Messages.getMessage("connectionClosed00")); 106 } 107 try 108 { 109 Call call = createCall(endpoint); 110 ((org.jboss.axis.Message)request).setMessageContext(call.getMessageContext()); 111 SOAPEnvelopeAxisImpl env = ((org.jboss.axis.Message)request).getSOAPEnvelope(); 112 Attachments attachments = ((org.jboss.axis.Message) 113 request).getAttachmentsImpl(); 114 if (attachments != null) 115 { 116 Iterator iterator = attachments.getAttachments().iterator(); 117 while (iterator.hasNext()) 118 { 119 Object attachment = iterator.next(); 120 call.addAttachmentPart(attachment); 121 } 122 } 123 124 call.setReturnClass(SOAPMessage .class); 125 call.invoke(env, request.getMimeHeaders()); 126 return call.getResponseMessage(); 127 } 128 catch (java.net.MalformedURLException mue) 129 { 130 throw new SOAPException (mue); 131 } 132 catch (org.jboss.axis.AxisFault af) 133 { 134 processAxisFault(af); 135 Message msg = new Message(af); 136 msg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true"); 137 msg.setMessageContext(((org.jboss.axis.Message)request).getMessageContext()); 138 return msg; 139 } 141 catch (java.rmi.RemoteException re) 142 { 143 throw new SOAPException (re); 144 } 145 } 146 147 154 protected void processAxisFault(AxisFault fault) 155 { 156 Element runtimeException = fault.lookupFaultDetail(Constants.QNAME_FAULTDETAIL_STACKTRACE); 158 if (runtimeException != null) 159 { 160 fault.removeFaultDetail(Constants.QNAME_FAULTDETAIL_STACKTRACE); 162 } 163 } 164 165 168 protected Call createCall(Object endpoint) throws MalformedURLException 169 { 170 Call call = new Call(endpoint.toString()); 171 return call; 172 } 173 174 179 public void close() throws SOAPException 180 { 181 if (closed) 182 { 183 throw new SOAPException (Messages.getMessage("connectionClosed00")); 184 } 185 closed = true; 186 } 187 } 188 | Popular Tags |