public void marshall( Class parentType, QName elementType, ExtensibilityElement extension, PrintWriter pw, Definition def, ExtensionRegistry extReg) throws WSDLException { MIMEContent mimeContent = (MIMEContent) extension; if (mimeContent != null) { String tagName = DOMUtils.getQualifiedValue(MIMEConstants.NS_URI_MIME, "content", def); if (parentType != null && MIMEPart.class.isAssignableFrom(parentType)) { pw.print(" "); } pw.print(" <" + tagName); DOMUtils.printAttribute(MIMEConstants.ATTR_PART, mimeContent.getPart(), pw); DOMUtils.printAttribute(Constants.ATTR_TYPE, mimeContent.getType(), pw); Boolean required = mimeContent.getRequired(); if (required != null) { DOMUtils.printQualifiedAttribute(Constants.Q_ATTR_REQUIRED, required.toString(), def, pw); } pw.println("/>"); } }
public ExtensibilityElement unmarshall( Class parentType, QName elementType, Element el, Definition def, ExtensionRegistry extReg) throws WSDLException { MIMEContent mimeContent = (MIMEContent) extReg.createExtension(parentType, elementType); String part = DOMUtils.getAttribute(el, MIMEConstants.ATTR_PART); String type = DOMUtils.getAttribute(el, Constants.ATTR_TYPE); String requiredStr = DOMUtils.getAttributeNS(el, Constants.NS_URI_WSDL, Constants.ATTR_REQUIRED); if (part != null) { mimeContent.setPart(part); } if (type != null) { mimeContent.setType(type); } if (requiredStr != null) { mimeContent.setRequired(new Boolean(requiredStr)); } return mimeContent; }
private List<MessagePartInfo> handleMimePart( MIMEPart mpart, List<MessagePartInfo> attParts, MessageInfo msg, BindingMessageInfo bmsg, List<MessagePartInfo> bodyParts, List<MessagePartInfo> messageParts) { if (mpart.getExtensibilityElements().size() < 1) { throw new RuntimeException("MIMEPart should at least contain one element!"); } String partName = null; for (Object content : mpart.getExtensibilityElements()) { if (content instanceof MIMEContent) { MIMEContent mc = (MIMEContent) content; partName = mc.getPart(); if (attParts == null) { attParts = new LinkedList<MessagePartInfo>(); } if (StringUtils.isEmpty(partName)) { throw new RuntimeException( "Problem with WSDL: mime content element in operation " + bmsg.getBindingOperation().getName().getLocalPart() + " does not specify a part."); } MessagePartInfo mpi = msg.getMessagePart(new QName(msg.getName().getNamespaceURI(), partName)); mpi.setProperty(Message.CONTENT_TYPE, mc.getType()); attParts.add(mpi); // Attachments shouldn't be part of the body message bmsg.getMessageParts().remove(mpi); } else if (SOAPBindingUtil.isSOAPBody(content)) { SoapBody sb = SOAPBindingUtil.getSoapBody(content); if (sb.getParts() != null && sb.getParts().size() == 1) { partName = (String) sb.getParts().get(0); } // We can have a list of empty part names here. if (partName != null) { addSoapBodyPart(msg, bodyParts, partName); } } else if (SOAPBindingUtil.isSOAPHeader(content)) { SoapHeader header = SOAPBindingUtil.getSoapHeader(content); SoapHeaderInfo headerInfo = new SoapHeaderInfo(); headerInfo.setUse(header.getUse()); if (StringUtils.isEmpty(header.getPart())) { throw new RuntimeException( "Problem with WSDL: soap:header element in operation " + bmsg.getBindingOperation().getName().getLocalPart() + " does not specify a part."); } MessagePartInfo mpi = msg.getMessagePart(new QName(msg.getName().getNamespaceURI(), header.getPart())); if (mpi != null && header.getMessage() != null && !mpi.getMessageInfo().getName().equals(header.getMessage())) { mpi = null; // out of band, let's find it for (MessagePartInfo mpi2 : msg.getOutOfBandParts()) { if (mpi2.getName().getLocalPart().equals(header.getPart()) && mpi2.getMessageInfo().getName().equals(header.getMessage())) { mpi = mpi2; } } } if (mpi != null) { headerInfo.setPart(mpi); messageParts.remove(mpi); bmsg.getMessageParts().remove(mpi); bmsg.addExtensor(headerInfo); } } } return attParts; }