1 16 package org.apache.axis.soap; 17 18 import org.apache.axis.Message; 19 import org.apache.axis.attachments.Attachments; 20 import org.apache.axis.client.Call; 21 import org.apache.axis.utils.Messages; 22 23 import javax.xml.soap.SOAPException ; 24 import javax.xml.soap.SOAPMessage ; 25 import javax.xml.soap.MimeHeaders ; 26 import java.util.Iterator ; 27 28 33 public class SOAPConnectionImpl extends javax.xml.soap.SOAPConnection { 34 private boolean closed = false; 35 private Integer timeout = null; 36 37 41 public Integer getTimeout() { 42 return timeout; 43 } 44 45 49 public void setTimeout(Integer timeout) { 50 this.timeout = timeout; 51 } 52 53 65 public SOAPMessage call(SOAPMessage request, Object endpoint) 66 throws SOAPException { 67 if(closed){ 68 throw new SOAPException (Messages.getMessage("connectionClosed00")); 69 } 70 try { 71 Call call = new Call(endpoint.toString()); 72 ((org.apache.axis.Message)request).setMessageContext(call.getMessageContext()); 73 Attachments attachments = ((org.apache.axis.Message) 74 request).getAttachmentsImpl(); 75 if (attachments != null) { 76 Iterator iterator = attachments.getAttachments().iterator(); 77 while (iterator.hasNext()) { 78 Object attachment = iterator.next(); 79 call.addAttachmentPart(attachment); 80 } 81 } 82 83 String soapActionURI = checkForSOAPActionHeader(request); 84 if (soapActionURI != null) 85 call.setSOAPActionURI(soapActionURI); 86 87 call.setTimeout(timeout); 88 call.setReturnClass(SOAPMessage .class); 89 call.setProperty(Call.CHECK_MUST_UNDERSTAND,Boolean.FALSE); 90 call.invoke((Message) request); 91 return call.getResponseMessage(); 92 } catch (java.net.MalformedURLException mue){ 93 throw new SOAPException (mue); 94 } catch (org.apache.axis.AxisFault af){ 95 throw new SOAPException (af); 96 } 97 } 98 99 106 private String checkForSOAPActionHeader(SOAPMessage request) { 107 MimeHeaders hdrs = request.getMimeHeaders(); 108 if (hdrs != null) { 109 String [] saHdrs = hdrs.getHeader("SOAPAction"); 110 if (saHdrs != null && saHdrs.length > 0) 111 return saHdrs[0]; 112 } 113 return null; 114 } 115 116 120 public void close() throws SOAPException { 121 if(closed){ 122 throw new SOAPException (Messages.getMessage("connectionClosed00")); 123 } 124 closed = true; 125 } 126 } 127 | Popular Tags |