1 22 23 package org.objectweb.petals.binding.axis2; 24 25 import java.util.Set ; 26 27 import javax.jbi.messaging.MessagingException; 28 import javax.jbi.messaging.NormalizedMessage; 29 import javax.xml.namespace.QName ; 30 31 import org.apache.axiom.attachments.Attachments; 32 import org.apache.axis2.AxisFault; 33 import org.apache.axis2.context.MessageContext; 34 import org.apache.axis2.description.AxisService; 35 36 42 public class SOAPHelper { 43 44 47 private SOAPHelper() { 48 } 49 50 59 public static QName getServiceName(AxisService service) { 60 61 QName name = null; 62 63 if (service != null) { 64 if (service.getName().startsWith("{")) { 65 name = new QName (service.getName()); 66 } else { 67 name = new QName (service.getTargetNamespace(), service 68 .getName()); 69 } 70 } 71 return name; 72 } 73 74 81 public static void copyAttachmentsFromSOAPToJBI( 82 MessageContext messageContext, NormalizedMessage nm) 83 throws MessagingException { 84 85 if (nm != null && messageContext != null) { 86 Attachments attachments = messageContext.getAttachmentMap(); 87 if (attachments != null) { 88 String [] ids = attachments.getAllContentIDs(); 89 for (String id : ids) { 90 nm.addAttachment(id, attachments.getDataHandler(id)); 91 } 92 } 93 } 94 } 95 96 104 public static void copyAttachmentsFromJBIToSOAP(NormalizedMessage nm, 105 MessageContext messageContext) { 106 if (nm != null && messageContext != null) { 107 Set attachmentNames = nm.getAttachmentNames(); 108 for (Object id : attachmentNames) { 109 String name = (String ) id; 110 messageContext.addAttachment(name, nm.getAttachment(name)); 111 } 112 } 113 } 114 115 } 116 | Popular Tags |