protected void createDocumentIfNecessary() { if (document == null && parser.getEventType() == XMLStreamReader.START_DOCUMENT) { document = createDocument(); if (charEncoding != null) { document.setCharsetEncoding(charEncoding); } document.setXMLVersion(parser.getVersion()); document.setXMLEncoding(parser.getCharacterEncodingScheme()); document.setStandalone(parser.isStandalone() ? "yes" : "no"); target = (OMContainerEx)document; } }
private void write(OutputStream out) throws IOException, XMLStreamException { if (targetNamespace == null) { targetNamespace = detectTargetNamespace(); } if (targetNamespace == null) { throw new PaxmlRuntimeException("No @targetNamespace attribute given on <soap> tag," + " and the target namespace cannot be detected from WSDL: " + getWsdlUrl()); } OMFactory factory = AxiomUtils.getOMFactory(); Map<?, ?> bd = (Map<?, ?>) this.body; OMNamespace targetNs = factory.createOMNamespace(targetNamespace, "ns"); OMNamespace ns = factory.createOMNamespace(SOAP_NS, "soapenv"); OMDocument doc = AxiomUtils.newDocument(); doc.setXMLEncoding("UTF-8"); OMElement root = factory.createOMElement("Envelope", ns); doc.addChild(root); OMElement headerEle = factory.createOMElement("Header", ns); root.addChild(headerEle); OMElement bodyEle = factory.createOMElement("Body", ns); root.addChild(bodyEle); Iterator<?> it = bd.entrySet().iterator(); if (!it.hasNext()) { throw new PaxmlRuntimeException("No webservice operation name given!"); } toXml(bodyEle, bd, targetNs, factory); doc.serializeAndConsume(out); }
private void write(OutputStream out) throws IOException, XMLStreamException { if (targetNamespace == null) { targetNamespace = detectTargetNamespace(); } if (targetNamespace == null) { throw new PaxmlRuntimeException("No @targetNamespace attribute given on <soap> tag," + " and the target namespace cannot be detected from WSDL: " + getWsdlUrl()); } OMFactory factory = AxiomUtils.getOMFactory(); Map<?, ?> bd = (Map<?, ?>) this.body; OMNamespace targetNs = factory.createOMNamespace(targetNamespace, "ns"); OMNamespace ns = factory.createOMNamespace(SOAP_NS, "soapenv"); OMDocument doc = AxiomUtils.newDocument(); doc.setXMLEncoding("UTF-8"); OMElement root = factory.createOMElement("Envelope", ns); doc.addChild(root); OMElement headerEle = factory.createOMElement("Header", ns); root.addChild(headerEle); OMElement bodyEle = factory.createOMElement("Body", ns); root.addChild(bodyEle); Iterator<?> it = bd.entrySet().iterator(); if (!it.hasNext()) { throw new PaxmlRuntimeException("No webservice operation name given!"); } toXml(bodyEle, bd, targetNs, factory); doc.serializeAndConsume(out); }