1 7 package org.jboss.axis.message; 8 9 11 import org.jboss.axis.AxisFault; 12 import org.jboss.axis.attachments.AttachmentSupport; 13 import org.jboss.axis.attachments.Attachments; 14 import org.jboss.axis.transport.http.HTTPConstants; 15 import org.jboss.axis.utils.Messages; 16 import org.jboss.logging.Logger; 17 18 import javax.xml.soap.AttachmentPart ; 19 import javax.xml.soap.MimeHeaders ; 20 import javax.xml.soap.SOAPBody ; 21 import javax.xml.soap.SOAPException ; 22 import javax.xml.soap.SOAPHeader ; 23 import javax.xml.soap.SOAPMessage ; 24 import java.io.IOException ; 25 import java.io.OutputStream ; 26 import java.util.Collections ; 27 import java.util.Hashtable ; 28 import java.util.Iterator ; 29 30 39 public class SOAPMessageImpl extends SOAPMessage 40 { 41 44 private static Logger log = Logger.getLogger(SOAPMessageAxisImpl.class.getName()); 45 46 protected javax.xml.soap.SOAPPart mSOAPPart; 48 protected Attachments mAttachments; 50 protected MimeHeadersImpl headers; 52 53 private Hashtable mProps = new Hashtable (); 54 private boolean saveRequired = true; 55 56 protected SOAPMessageImpl() 57 { 58 } 59 60 77 public void writeTo(OutputStream os) throws SOAPException , IOException 78 { 79 111 } 112 113 public SOAPBody getSOAPBody() throws SOAPException 114 { 115 return mSOAPPart.getEnvelope().getBody(); 116 } 117 118 public SOAPHeader getSOAPHeader() throws SOAPException 119 { 120 return mSOAPPart.getEnvelope().getHeader(); 121 } 122 123 public void setProperty(String property, Object value) throws SOAPException 124 { 125 mProps.put(property, value); 126 } 127 128 public Object getProperty(String property) throws SOAPException 129 { 130 return mProps.get(property); 131 } 132 133 142 public String getContentDescription() 143 { 144 String values[] = headers.getHeader(HTTPConstants.HEADER_CONTENT_DESCRIPTION); 145 if (values != null && values.length > 0) 146 return values[0]; 147 return null; 148 } 149 150 158 public void setContentDescription(String description) 159 { 160 headers.setHeader(HTTPConstants.HEADER_CONTENT_DESCRIPTION, description); 161 } 162 163 187 public void saveChanges() throws SOAPException 188 { 189 205 } 206 207 216 public boolean saveRequired() 217 { 218 return saveRequired; 219 } 220 221 229 public MimeHeaders getMimeHeaders() 230 { 231 return headers; 232 } 233 234 public javax.xml.soap.SOAPPart getSOAPPart() 235 { 236 return mSOAPPart; 237 } 238 239 245 public void removeAllAttachments() 246 { 247 mAttachments.removeAllAttachments(); 248 } 249 250 258 public int countAttachments() 259 { 260 return mAttachments == null ? 0 : mAttachments.getAttachmentCount(); 261 } 262 263 270 public Iterator getAttachments() 271 { 272 try 273 { 274 if (mAttachments != null && 0 != mAttachments.getAttachmentCount()) 275 { 276 return mAttachments.getAttachments().iterator(); 277 } 278 } 279 catch (AxisFault af) 280 { 281 log.error(Messages.getMessage("exception00"), af); 282 } 283 return Collections.EMPTY_LIST.iterator(); 284 } 285 286 298 public Iterator getAttachments(javax.xml.soap.MimeHeaders headers) 299 { 300 return mAttachments.getAttachments(headers); 301 } 302 303 314 public void addAttachmentPart(AttachmentPart attachmentpart) 315 { 316 try 317 { 318 mAttachments.addAttachmentPart((org.jboss.axis.Part)attachmentpart); 319 } 320 catch (AxisFault af) 321 { 322 log.error(Messages.getMessage("exception00"), af); 323 } 324 } 325 326 337 public AttachmentPart createAttachmentPart() 338 { 339 if (!AttachmentSupport.isAttachmentSupportEnabled()) 340 { 341 throw new RuntimeException (Messages.getMessage("noAttachments")); 342 } 343 344 try 345 { 346 return (AttachmentPart )mAttachments.createAttachmentPart(); 347 } 348 catch (AxisFault af) 349 { 350 log.error(Messages.getMessage("exception00"), af); 351 } 352 return null; 353 } 354 } 355 | Popular Tags |