public SOAPBodyElement addDocument(Document doc) throws SOAPException { Element rootElement = doc.getDocumentElement(); SOAPFactoryImpl soapFactory = new SOAPFactoryImpl(); SOAPElement soapElement = soapFactory.createElement(rootElement); return (SOAPBodyElement)addChildElement(soapElement); }
private Detail extractDetail(final QName detailQName) { SOAPElement obj = getChildElement(this, detailQName); Detail detail = null; if (obj instanceof Detail) { detail = (Detail)obj; } else if(obj instanceof SOAPElementImpl) { try { SOAPElementImpl soapEl = (SOAPElementImpl)obj; SOAPFactoryImpl factory = new SOAPFactoryImpl(); detail = (Detail)addChildElement(factory.createDetail()); Iterator<Element> childIt = DOMUtils.getChildElements(soapEl); while (childIt.hasNext()) { Element domElement = childIt.next(); SOAPElement detailEntry = new DetailEntryImpl(factory.createElement(domElement, true)); detail.addChildElement(detailEntry); } } catch (SOAPException e) { throw new WSException(BundleUtils.getMessage(bundle, "UNABLE_TO_CREATE_FAULT_DETAIL", e.getMessage())); } } return detail; }
String nsURI = domElement.getNamespaceURI() != null ? domElement.getNamespaceURI() : ""; SOAPElement soapElement = this.createElement(localName, prefix, nsURI); if (nodeType == Node.ELEMENT_NODE) SOAPElement soapChild = createElement((Element)child); soapElement.addChildElement(soapChild); removeNSAttribute(soapElement, prefixs); return soapElement;
@Override public SOAPElement createElement(Element domElement) throws SOAPException { return createElement(domElement, true); }
@Override public Detail createDetail() throws SOAPException { assertEnvNamespace(); return SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(envNamespace) ? new DetailImpl() : new DetailImpl(SOAPConstants.SOAP_ENV_PREFIX, envNamespace); }
private static SOAPFactory newSOAPFactory(final String protocol) { try { return new SOAPFactoryImpl(protocol); } catch (final SOAPException ignore) { return null; } // TODO: use standard SOAP API to create objects //return MessageFactory.newInstance() }
private void removeNSAttribute(SOAPElement soapElement, List<String> prefixes) { Iterator ite2 = soapElement.getChildElements(); while (ite2 != null && ite2.hasNext()) { Object obj = ite2.next(); if (obj instanceof SOAPElement) { SOAPElement ele = (SOAPElement) obj; removeNSAttribute(ele, prefixes); for (String str : prefixes) { Attr attr = ele.getAttributeNode("xmlns:" + str); if (attr != null) ele.removeAttribute("xmlns:" + str); } } } }
@Override public SOAPElement createElement(QName qname) throws SOAPException { return createElement(new NameImpl(qname)); }
@Override public SOAPFault createFault() throws SOAPException { assertEnvNamespace(); SOAPFaultImpl soapFault = new SOAPFaultImpl(SOAPConstants.SOAP_ENV_PREFIX, envNamespace); soapFault.setFaultCode(soapFault.getDefaultFaultCode()); return soapFault; }
@Override protected SOAPFactory newSOAPFactory(String protocol) throws SOAPException { return new SOAPFactoryImpl(protocol); }
private static SOAPBodyElementDoc convertToBodyElement(Node node) throws DOMException { if (!(node instanceof SOAPElementImpl) && (node instanceof Element)) { try { SOAPFactoryImpl soapFactory = new SOAPFactoryImpl(); node = (SOAPElementImpl)soapFactory.createElement((Element)node); } catch (SOAPException ex) { throw new DOMException(DOMException.INVALID_STATE_ERR, "Could not convert Element to a SOAPElement"); } } if (!(node instanceof SOAPElementImpl)) throw new IllegalArgumentException(BundleUtils.getMessage(bundle, "SOAPELEMENT_EXPECTED")); SOAPElementImpl element = (SOAPElementImpl)node; element.detachNode(); return new SOAPBodyElementDoc(element); }
public SOAPEnvelope build(SOAPMessage soapMessage, Element domEnv) throws SOAPException { // Construct the envelope SOAPPartImpl soapPart = (SOAPPartImpl)soapMessage.getSOAPPart(); SOAPEnvelopeImpl soapEnv = new SOAPEnvelopeImpl(soapPart, (SOAPElementImpl)soapFactory.createElement(domEnv, false), false); DOMUtils.copyAttributes(soapEnv, domEnv); NodeList envChildNodes = domEnv.getChildNodes(); for (int i = 0; i < envChildNodes.getLength(); i++) { Node child = envChildNodes.item(i); short childType = child.getNodeType(); if (childType == Node.ELEMENT_NODE) { String elName = child.getLocalName(); if ("Header".equals(elName)) { buildSOAPHeader(soapEnv, (Element)child); } else if ("Body".equals(elName)) { buildSOAPBody(soapEnv, (Element)child); } else { log.warn(BundleUtils.getMessage(bundle, "IGNORE_ENVELOPE_CHILD", elName)); } } } return soapEnv; }
@Override public SOAPFault createFault(String reasonText, QName faultCode) throws SOAPException { assertEnvNamespace(); SOAPFaultImpl soapFault = new SOAPFaultImpl(SOAPConstants.SOAP_ENV_PREFIX, envNamespace); soapFault.setFaultCode(faultCode); soapFault.setFaultString(reasonText); return soapFault; }
try SOAPFactoryImpl soapFactory = new SOAPFactoryImpl(); for (Node node = docFragment.getFirstChild(); node != null; node = node.getNextSibling()) SOAPElementImpl soapChild = (SOAPElementImpl)soapFactory.createElement((Element)node); list.add(soapChild); break;
if (childType == Node.ELEMENT_NODE) SOAPElement soapElement = soapFactory.createElement((Element)child); soapBodyElement.addChildElement(soapElement);
soapElement = (SOAPElementImpl) new SOAPFactoryImpl().createElement((Element) (soapElement.domNode)); DOMUtils.setOwnerDocument(oldDoc);
soapBody.addChildElement(soapFactory.createElement((Element)child, true));
retNode = new SOAPFactoryImpl().createElement((Element)node);
if (childNode instanceof SOAPElement) SOAPElement childClone = soapFactory.createElement((SOAPElement)childNode, true); hrefElement.addChildElement(childClone);
container.setPrefix(domElement.getPrefix()); SOAPFactoryImpl soapFactory = new SOAPFactoryImpl(); SOAPElement soapElement = soapFactory.createElement((Element)child); container.addChildElement(soapElement);