Search in sources :

Example 1 with XMLStreamBufferResult

use of com.sun.xml.stream.buffer.XMLStreamBufferResult in project metro-jax-ws by eclipse-ee4j.

the class WSDLGenResolver method getAbstractWSDL.

/**
 * Updates filename if the suggested filename need to be changed in
 * wsdl:import. If the metadata already contains abstract wsdl(i.e. a WSDL
 * which has the porttype), then the abstract wsdl shouldn't be generated
 *
 * return null if abstract WSDL need not be generated
 *        Result the abstract WSDL
 */
public Result getAbstractWSDL(Holder<String> filename) {
    if (abstractWsdl != null) {
        filename.value = abstractWsdl.getURL().toString();
        // Don't generate abstract WSDL
        return null;
    }
    URL url = createURL(filename.value);
    MutableXMLStreamBuffer xsb = new MutableXMLStreamBuffer();
    xsb.setSystemId(url.toExternalForm());
    SDDocumentSource abstractWsdlSource = SDDocumentSource.create(url, xsb);
    newDocs.add(abstractWsdlSource);
    XMLStreamBufferResult r = new XMLStreamBufferResult(xsb);
    r.setSystemId(filename.value);
    return r;
}
Also used : MutableXMLStreamBuffer(com.sun.xml.stream.buffer.MutableXMLStreamBuffer) SDDocumentSource(com.sun.xml.ws.api.server.SDDocumentSource) XMLStreamBufferResult(com.sun.xml.stream.buffer.XMLStreamBufferResult) URL(java.net.URL)

Example 2 with XMLStreamBufferResult

use of com.sun.xml.stream.buffer.XMLStreamBufferResult in project metro-jax-ws by eclipse-ee4j.

the class EndpointImpl method buildDocList.

/**
 * Convert metadata sources using identity transform. So that we can
 * reuse the Source object multiple times.
 */
private List<SDDocumentSource> buildDocList() {
    List<SDDocumentSource> r = new ArrayList<>();
    if (metadata != null) {
        for (Source source : metadata) {
            try {
                XMLStreamBufferResult xsbr = XmlUtil.identityTransform(source, new XMLStreamBufferResult());
                String systemId = source.getSystemId();
                r.add(SDDocumentSource.create(new URL(systemId), xsbr.getXMLStreamBuffer()));
            } catch (TransformerException | IOException | SAXException | ParserConfigurationException te) {
                throw new ServerRtException("server.rt.err", te);
            }
        }
    }
    return r;
}
Also used : ArrayList(java.util.ArrayList) XMLStreamBufferResult(com.sun.xml.stream.buffer.XMLStreamBufferResult) IOException(java.io.IOException) ServerRtException(com.sun.xml.ws.server.ServerRtException) Source(javax.xml.transform.Source) URL(java.net.URL) SAXException(org.xml.sax.SAXException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) TransformerException(javax.xml.transform.TransformerException)

Example 3 with XMLStreamBufferResult

use of com.sun.xml.stream.buffer.XMLStreamBufferResult in project metro-jax-ws by eclipse-ee4j.

the class JAXBTest method testJAXBElementMarshalling.

public void testJAXBElementMarshalling() throws Exception {
    JAXBRIContext jc = (JAXBRIContext) JAXBContext.newInstance(whitebox.jaxb.client.DetailType.class);
    DetailType dt = new DetailType();
    SOAPFault sf = createFault();
    dt.getDetails().add(sf.getDetail());
    Marshaller m = jc.createMarshaller();
    m.marshal(dt, System.out);
    XMLStreamBufferResult sbr = new XMLStreamBufferResult();
    m.setProperty(Marshaller.JAXB_FRAGMENT, true);
    m.marshal(dt, sbr);
    XMLStreamBuffer infoset = sbr.getXMLStreamBuffer();
    XMLStreamReader reader = infoset.readAsXMLStreamReader();
    if (reader.getEventType() == START_DOCUMENT)
        XMLStreamReaderUtil.nextElementContent(reader);
    verifyDetail(reader);
}
Also used : Marshaller(jakarta.xml.bind.Marshaller) XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamBuffer(com.sun.xml.stream.buffer.XMLStreamBuffer) SOAPFault(jakarta.xml.soap.SOAPFault) XMLStreamBufferResult(com.sun.xml.stream.buffer.XMLStreamBufferResult) JAXBRIContext(org.glassfish.jaxb.runtime.api.JAXBRIContext)

Example 4 with XMLStreamBufferResult

use of com.sun.xml.stream.buffer.XMLStreamBufferResult in project metro-jax-ws by eclipse-ee4j.

the class WSDLGenResolver method getWSDL.

/**
 * Generates the concrete WSDL that contains service element.
 *
 * @return Result the generated concrete WSDL
 */
public Result getWSDL(String filename) {
    URL url = createURL(filename);
    MutableXMLStreamBuffer xsb = new MutableXMLStreamBuffer();
    xsb.setSystemId(url.toExternalForm());
    concreteWsdlSource = SDDocumentSource.create(url, xsb);
    newDocs.add(concreteWsdlSource);
    XMLStreamBufferResult r = new XMLStreamBufferResult(xsb);
    r.setSystemId(filename);
    return r;
}
Also used : MutableXMLStreamBuffer(com.sun.xml.stream.buffer.MutableXMLStreamBuffer) XMLStreamBufferResult(com.sun.xml.stream.buffer.XMLStreamBufferResult) URL(java.net.URL)

Example 5 with XMLStreamBufferResult

use of com.sun.xml.stream.buffer.XMLStreamBufferResult in project metro-jax-ws by eclipse-ee4j.

the class WSDLGenResolver method getSchemaOutput.

/**
 * Updates filename if the suggested filename need to be changed in
 * xsd:import. If there is already a schema document for the namespace
 * in the metadata, then it is not generated.
 *
 * return null if schema need not be generated
 *        Result the generated schema document
 */
public Result getSchemaOutput(String namespace, Holder<String> filename) {
    List<SDDocumentImpl> schemas = nsMapping.get(namespace);
    if (schemas != null) {
        if (schemas.size() > 1) {
            throw new ServerRtException("server.rt.err", "More than one schema for the target namespace " + namespace);
        }
        filename.value = schemas.get(0).getURL().toExternalForm();
        // Don't generate schema
        return null;
    }
    URL url = createURL(filename.value);
    MutableXMLStreamBuffer xsb = new MutableXMLStreamBuffer();
    xsb.setSystemId(url.toExternalForm());
    SDDocumentSource sd = SDDocumentSource.create(url, xsb);
    newDocs.add(sd);
    XMLStreamBufferResult r = new XMLStreamBufferResult(xsb);
    r.setSystemId(filename.value);
    return r;
}
Also used : MutableXMLStreamBuffer(com.sun.xml.stream.buffer.MutableXMLStreamBuffer) SDDocumentSource(com.sun.xml.ws.api.server.SDDocumentSource) XMLStreamBufferResult(com.sun.xml.stream.buffer.XMLStreamBufferResult) URL(java.net.URL)

Aggregations

XMLStreamBufferResult (com.sun.xml.stream.buffer.XMLStreamBufferResult)6 MutableXMLStreamBuffer (com.sun.xml.stream.buffer.MutableXMLStreamBuffer)4 URL (java.net.URL)4 SDDocumentSource (com.sun.xml.ws.api.server.SDDocumentSource)2 Marshaller (jakarta.xml.bind.Marshaller)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2 XMLStreamBuffer (com.sun.xml.stream.buffer.XMLStreamBuffer)1 ServerRtException (com.sun.xml.ws.server.ServerRtException)1 JAXBException (jakarta.xml.bind.JAXBException)1 AttachmentMarshaller (jakarta.xml.bind.attachment.AttachmentMarshaller)1 SOAPFault (jakarta.xml.soap.SOAPFault)1 WebServiceException (jakarta.xml.ws.WebServiceException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Source (javax.xml.transform.Source)1 TransformerException (javax.xml.transform.TransformerException)1 JAXBRIContext (org.glassfish.jaxb.runtime.api.JAXBRIContext)1 SAXException (org.xml.sax.SAXException)1