private static void writeMSMetaData( StreamWriterBufferCreator writer, QName service, QName port, QName portType, List<Element> metadata) throws XMLStreamException { // TODO: write ReferenceProperties // TODO: write ReferenceParameters if (portType != null) { // Write Interface info writer.writeStartElement( AddressingVersion.MEMBER.getPrefix(), MemberSubmissionAddressingConstants.WSA_PORTTYPE_NAME, AddressingVersion.MEMBER.nsUri); String portTypePrefix = portType.getPrefix(); if (portTypePrefix == null || portTypePrefix.equals("")) { // TODO check prefix again portTypePrefix = "wsns"; } writer.writeNamespace(portTypePrefix, portType.getNamespaceURI()); writer.writeCharacters(portTypePrefix + ":" + portType.getLocalPart()); writer.writeEndElement(); } // Write service and Port info if (service != null) { if (!(service.getNamespaceURI().equals("") || service.getLocalPart().equals(""))) { writer.writeStartElement( AddressingVersion.MEMBER.getPrefix(), MemberSubmissionAddressingConstants.WSA_SERVICENAME_NAME, AddressingVersion.MEMBER.nsUri); String servicePrefix = service.getPrefix(); if (servicePrefix == null || servicePrefix.equals("")) { // TODO check prefix again servicePrefix = "wsns"; } writer.writeNamespace(servicePrefix, service.getNamespaceURI()); if (port != null) { writer.writeAttribute( MemberSubmissionAddressingConstants.WSA_PORTNAME_NAME, port.getLocalPart()); } writer.writeCharacters(servicePrefix + ":" + service.getLocalPart()); writer.writeEndElement(); } } }
private static void writeWsdl(StreamWriterBufferCreator writer, QName service, String wsdlAddress) throws XMLStreamException { // Inline-wsdl writer.writeStartElement( WSDLConstants.PREFIX_NS_WSDL, WSDLConstants.QNAME_DEFINITIONS.getLocalPart(), WSDLConstants.NS_WSDL); writer.writeNamespace(WSDLConstants.PREFIX_NS_WSDL, WSDLConstants.NS_WSDL); writer.writeStartElement( WSDLConstants.PREFIX_NS_WSDL, WSDLConstants.QNAME_IMPORT.getLocalPart(), WSDLConstants.NS_WSDL); writer.writeAttribute("namespace", service.getNamespaceURI()); writer.writeAttribute("location", wsdlAddress); writer.writeEndElement(); writer.writeEndElement(); }
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 void writeW3CMetaData( StreamWriterBufferCreator writer, QName service, QName port, QName portType, List<Element> metadata, String wsdlAddress) throws XMLStreamException { writer.writeStartElement( AddressingVersion.W3C.getPrefix(), W3CAddressingConstants.WSA_METADATA_NAME, AddressingVersion.W3C.nsUri); writer.writeNamespace(AddressingVersion.W3C.getWsdlPrefix(), AddressingVersion.W3C.wsdlNsUri); // Write Interface info if (portType != null) { writer.writeStartElement( AddressingVersion.W3C.getWsdlPrefix(), W3CAddressingConstants.WSAW_INTERFACENAME_NAME, AddressingVersion.W3C.wsdlNsUri); String portTypePrefix = portType.getPrefix(); if (portTypePrefix == null || portTypePrefix.equals("")) { // TODO check prefix again portTypePrefix = "wsns"; } writer.writeNamespace(portTypePrefix, portType.getNamespaceURI()); writer.writeCharacters(portTypePrefix + ":" + portType.getLocalPart()); writer.writeEndElement(); } if (service != null) { // Write service and Port info if (!(service.getNamespaceURI().equals("") || service.getLocalPart().equals(""))) { writer.writeStartElement( AddressingVersion.W3C.getWsdlPrefix(), W3CAddressingConstants.WSAW_SERVICENAME_NAME, AddressingVersion.W3C.wsdlNsUri); String servicePrefix = service.getPrefix(); if (servicePrefix == null || servicePrefix.equals("")) { // TODO check prefix again servicePrefix = "wsns"; } writer.writeNamespace(servicePrefix, service.getNamespaceURI()); if (port != null) { writer.writeAttribute(W3CAddressingConstants.WSAW_ENDPOINTNAME_NAME, port.getLocalPart()); } writer.writeCharacters(servicePrefix + ":" + service.getLocalPart()); writer.writeEndElement(); } } // Inline the wsdl if (wsdlAddress != null) { writeWsdl(writer, service, wsdlAddress); } // Add the extra metadata Elements if (metadata != null) for (Element e : metadata) { DOMUtil.serializeNode(e, writer); } writer.writeEndElement(); }
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); } }