private static XMLStreamBuffer createBufferFromAddress( String address, AddressingVersion version) { try { MutableXMLStreamBuffer xsb = new MutableXMLStreamBuffer(); StreamWriterBufferCreator w = new StreamWriterBufferCreator(xsb); w.writeStartDocument(); w.writeStartElement(version.getPrefix(), "EndpointReference", version.nsUri); w.writeNamespace(version.getPrefix(), version.nsUri); w.writeStartElement( version.getPrefix(), W3CAddressingConstants.WSA_ADDRESS_NAME, version.nsUri); w.writeCharacters(address); w.writeEndElement(); w.writeEndElement(); w.writeEndDocument(); w.close(); return xsb; } catch (XMLStreamException e) { // can never happen because we are writing to XSB throw new AssertionError(e); } }
private static XMLStreamBuffer createBufferFromData( AddressingVersion version, String address, List<Element> referenceParameters, QName service, QName port, QName portType, List<Element> metadata, String wsdlAddress) { StreamWriterBufferCreator writer = new StreamWriterBufferCreator(); try { writer.writeStartDocument(); writer.writeStartElement(version.getPrefix(), "EndpointReference", version.nsUri); writer.writeNamespace(version.getPrefix(), version.nsUri); writer.writeStartElement(version.getPrefix(), "Address", version.nsUri); writer.writeCharacters(address); writer.writeEndElement(); if (referenceParameters != null) { writer.writeStartElement(version.getPrefix(), "ReferenceParameters", version.nsUri); for (Element e : referenceParameters) DOMUtil.serializeNode(e, writer); writer.writeEndElement(); } switch (version) { case W3C: writeW3CMetaData(writer, service, port, portType, metadata, wsdlAddress); break; case MEMBER: writeMSMetaData(writer, service, port, portType, metadata); if (wsdlAddress != null) { // Inline the wsdl as extensibility element // Write mex:Metadata wrapper writer.writeStartElement( MemberSubmissionAddressingConstants.MEX_METADATA.getPrefix(), MemberSubmissionAddressingConstants.MEX_METADATA.getLocalPart(), MemberSubmissionAddressingConstants.MEX_METADATA.getNamespaceURI()); writer.writeStartElement( MemberSubmissionAddressingConstants.MEX_METADATA_SECTION.getPrefix(), MemberSubmissionAddressingConstants.MEX_METADATA_SECTION.getLocalPart(), MemberSubmissionAddressingConstants.MEX_METADATA_SECTION.getNamespaceURI()); writer.writeAttribute( MemberSubmissionAddressingConstants.MEX_METADATA_DIALECT_ATTRIBUTE, MemberSubmissionAddressingConstants.MEX_METADATA_DIALECT_VALUE); writeWsdl(writer, service, wsdlAddress); writer.writeEndElement(); writer.writeEndElement(); } break; } writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); return writer.getXMLStreamBuffer(); } catch (XMLStreamException e) { throw new WebServiceException(e); } }