com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory Java Examples

The following examples show how to use com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EndpointArgumentsBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected void readWrappedRequest(Message msg, Object[] args) throws JAXBException, XMLStreamException {
    if (!msg.hasPayload()) {
        throw new WebServiceException("No payload. Expecting payload with "+wrapperName+" element");
    }
    XMLStreamReader reader = msg.readPayload();
    XMLStreamReaderUtil.verifyTag(reader,wrapperName);
    reader.nextTag();
    while(reader.getEventType()==XMLStreamReader.START_ELEMENT) {
        // TODO: QName has a performance issue
        QName name = reader.getName();
        WrappedPartBuilder part = wrappedParts.get(name);
        if(part==null) {
            // no corresponding part found. ignore
            XMLStreamReaderUtil.skipElement(reader);
            reader.nextTag();
        } else {
            part.readRequest(args,reader, msg.getAttachments());
        }
        XMLStreamReaderUtil.toNextTag(reader, name);
    }

    // we are done with the body
    reader.close();
    XMLStreamReaderFactory.recycle(reader);
}
 
Example #2
Source File: WsimportOptions.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
 * TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
 *
 * Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
 * to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
 *
 * @param receiver {@link ErrorReceiver}
 */
public final void parseBindings(ErrorReceiver receiver){
    for (InputSource is : bindingFiles) {
        XMLStreamReader reader =
                XMLStreamReaderFactory.create(is,true);
        XMLStreamReaderUtil.nextElementContent(reader);
        if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
            jaxwsCustomBindings.add(new RereadInputSource(is));
        } else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
                reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
            jaxbCustomBindings.add(new RereadInputSource(is));
        } else {
            LocatorImpl locator = new LocatorImpl();
            locator.setSystemId(reader.getLocation().getSystemId());
            locator.setPublicId(reader.getLocation().getPublicId());
            locator.setLineNumber(reader.getLocation().getLineNumber());
            locator.setColumnNumber(reader.getLocation().getColumnNumber());
            receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
        }
    }
}
 
Example #3
Source File: EntityResolverWrapper.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException {
    InputSource source = core.resolveEntity(publicId,systemId);
    if(source==null)
        return null;    // default

    // ideally entity resolvers should be giving us the system ID for the resource
    // (or otherwise we won't be able to resolve references within this imported WSDL correctly),
    // but if none is given, the system ID before the entity resolution is better than nothing.
    if(source.getSystemId()!=null)
        systemId = source.getSystemId();

    URL url = new URL(systemId);
    InputStream stream;
    if (useStreamFromEntityResolver) {
            stream = source.getByteStream();
    } else {
            stream = url.openStream();
    }
    return new Parser(url,
            new TidyXMLStreamReader(XMLStreamReaderFactory.create(url.toExternalForm(), stream, true), stream));
}
 
Example #4
Source File: EndpointFactory.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity (String publicId, String systemId) throws IOException, XMLStreamException {
    if (systemId != null) {
        SDDocumentSource doc = metadata.get(systemId);
        if (doc != null)
            return new Parser(doc);
    }
    if (resolver != null) {
        try {
            InputSource source = resolver.resolveEntity(publicId, systemId);
            if (source != null) {
                Parser p = new Parser(null, XMLStreamReaderFactory.create(source, true));
                return p;
            }
        } catch (SAXException e) {
            throw new XMLStreamException(e);
        }
    }
    return null;
}
 
Example #5
Source File: EndpointArgumentsBuilder.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected void readWrappedRequest(Message msg, Object[] args) throws JAXBException, XMLStreamException {
    if (!msg.hasPayload()) {
        throw new WebServiceException("No payload. Expecting payload with "+wrapperName+" element");
    }
    XMLStreamReader reader = msg.readPayload();
    XMLStreamReaderUtil.verifyTag(reader,wrapperName);
    reader.nextTag();
    while(reader.getEventType()==XMLStreamReader.START_ELEMENT) {
        // TODO: QName has a performance issue
        QName name = reader.getName();
        WrappedPartBuilder part = wrappedParts.get(name);
        if(part==null) {
            // no corresponding part found. ignore
            XMLStreamReaderUtil.skipElement(reader);
            reader.nextTag();
        } else {
            part.readRequest(args,reader, msg.getAttachments());
        }
        XMLStreamReaderUtil.toNextTag(reader, name);
    }

    // we are done with the body
    reader.close();
    XMLStreamReaderFactory.recycle(reader);
}
 
Example #6
Source File: EndpointFactory.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity (String publicId, String systemId) throws IOException, XMLStreamException {
    if (systemId != null) {
        SDDocumentSource doc = metadata.get(systemId);
        if (doc != null)
            return new Parser(doc);
    }
    if (resolver != null) {
        try {
            InputSource source = resolver.resolveEntity(publicId, systemId);
            if (source != null) {
                Parser p = new Parser(null, XMLStreamReaderFactory.create(source, true));
                return p;
            }
        } catch (SAXException e) {
            throw new XMLStreamException(e);
        }
    }
    return null;
}
 
Example #7
Source File: EntityResolverWrapper.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException {
    InputSource source = core.resolveEntity(publicId,systemId);
    if(source==null)
        return null;    // default

    // ideally entity resolvers should be giving us the system ID for the resource
    // (or otherwise we won't be able to resolve references within this imported WSDL correctly),
    // but if none is given, the system ID before the entity resolution is better than nothing.
    if(source.getSystemId()!=null)
        systemId = source.getSystemId();

    URL url = new URL(systemId);
    InputStream stream;
    if (useStreamFromEntityResolver) {
            stream = source.getByteStream();
    } else {
            stream = url.openStream();
    }
    return new Parser(url,
            new TidyXMLStreamReader(XMLStreamReaderFactory.create(url.toExternalForm(), stream, true), stream));
}
 
Example #8
Source File: EndpointFactory.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity (String publicId, String systemId) throws IOException, XMLStreamException {
    if (systemId != null) {
        SDDocumentSource doc = metadata.get(systemId);
        if (doc != null)
            return new Parser(doc);
    }
    if (resolver != null) {
        try {
            InputSource source = resolver.resolveEntity(publicId, systemId);
            if (source != null) {
                Parser p = new Parser(null, XMLStreamReaderFactory.create(source, true));
                return p;
            }
        } catch (SAXException e) {
            throw new XMLStreamException(e);
        }
    }
    return null;
}
 
Example #9
Source File: EndpointFactory.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity (String publicId, String systemId) throws IOException, XMLStreamException {
    if (systemId != null) {
        SDDocumentSource doc = metadata.get(systemId);
        if (doc != null)
            return new Parser(doc);
    }
    if (resolver != null) {
        try {
            InputSource source = resolver.resolveEntity(publicId, systemId);
            if (source != null) {
                Parser p = new Parser(null, XMLStreamReaderFactory.create(source, true));
                return p;
            }
        } catch (SAXException e) {
            throw new XMLStreamException(e);
        }
    }
    return null;
}
 
Example #10
Source File: EntityResolverWrapper.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException {
    InputSource source = core.resolveEntity(publicId,systemId);
    if(source==null)
        return null;    // default

    // ideally entity resolvers should be giving us the system ID for the resource
    // (or otherwise we won't be able to resolve references within this imported WSDL correctly),
    // but if none is given, the system ID before the entity resolution is better than nothing.
    if(source.getSystemId()!=null)
        systemId = source.getSystemId();

    URL url = new URL(systemId);
    InputStream stream;
    if (useStreamFromEntityResolver) {
            stream = source.getByteStream();
    } else {
            stream = url.openStream();
    }
    return new Parser(url,
            new TidyXMLStreamReader(XMLStreamReaderFactory.create(url.toExternalForm(), stream, true), stream));
}
 
Example #11
Source File: EndpointArgumentsBuilder.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected void readWrappedRequest(Message msg, Object[] args) throws JAXBException, XMLStreamException {
    if (!msg.hasPayload()) {
        throw new WebServiceException("No payload. Expecting payload with "+wrapperName+" element");
    }
    XMLStreamReader reader = msg.readPayload();
    XMLStreamReaderUtil.verifyTag(reader,wrapperName);
    reader.nextTag();
    while(reader.getEventType()==XMLStreamReader.START_ELEMENT) {
        // TODO: QName has a performance issue
        QName name = reader.getName();
        WrappedPartBuilder part = wrappedParts.get(name);
        if(part==null) {
            // no corresponding part found. ignore
            XMLStreamReaderUtil.skipElement(reader);
            reader.nextTag();
        } else {
            part.readRequest(args,reader, msg.getAttachments());
        }
        XMLStreamReaderUtil.toNextTag(reader, name);
    }

    // we are done with the body
    reader.close();
    XMLStreamReaderFactory.recycle(reader);
}
 
Example #12
Source File: WsimportOptions.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
 * TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
 *
 * Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
 * to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
 *
 * @param receiver {@link ErrorReceiver}
 */
public final void parseBindings(ErrorReceiver receiver){
    for (InputSource is : bindingFiles) {
        XMLStreamReader reader =
                XMLStreamReaderFactory.create(is,true);
        XMLStreamReaderUtil.nextElementContent(reader);
        if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
            jaxwsCustomBindings.add(new RereadInputSource(is));
        } else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
                reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
            jaxbCustomBindings.add(new RereadInputSource(is));
        } else {
            LocatorImpl locator = new LocatorImpl();
            locator.setSystemId(reader.getLocation().getSystemId());
            locator.setPublicId(reader.getLocation().getPublicId());
            locator.setLineNumber(reader.getLocation().getLineNumber());
            locator.setColumnNumber(reader.getLocation().getColumnNumber());
            receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
        }
    }
}
 
Example #13
Source File: WsimportOptions.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
 * TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
 *
 * Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
 * to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
 *
 * @param receiver {@link ErrorReceiver}
 */
public final void parseBindings(ErrorReceiver receiver){
    for (InputSource is : bindingFiles) {
        XMLStreamReader reader =
                XMLStreamReaderFactory.create(is,true);
        XMLStreamReaderUtil.nextElementContent(reader);
        if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
            jaxwsCustomBindings.add(new RereadInputSource(is));
        } else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
                reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
            jaxbCustomBindings.add(new RereadInputSource(is));
        } else {
            LocatorImpl locator = new LocatorImpl();
            locator.setSystemId(reader.getLocation().getSystemId());
            locator.setPublicId(reader.getLocation().getPublicId());
            locator.setLineNumber(reader.getLocation().getLineNumber());
            locator.setColumnNumber(reader.getLocation().getColumnNumber());
            receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
        }
    }
}
 
Example #14
Source File: EntityResolverWrapper.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException {
    InputSource source = core.resolveEntity(publicId,systemId);
    if(source==null)
        return null;    // default

    // ideally entity resolvers should be giving us the system ID for the resource
    // (or otherwise we won't be able to resolve references within this imported WSDL correctly),
    // but if none is given, the system ID before the entity resolution is better than nothing.
    if(source.getSystemId()!=null)
        systemId = source.getSystemId();

    URL url = new URL(systemId);
    InputStream stream;
    if (useStreamFromEntityResolver) {
            stream = source.getByteStream();
    } else {
            stream = url.openStream();
    }
    return new Parser(url,
            new TidyXMLStreamReader(XMLStreamReaderFactory.create(url.toExternalForm(), stream, true), stream));
}
 
Example #15
Source File: WsimportOptions.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
 * TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
 *
 * Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
 * to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
 *
 * @param receiver {@link ErrorReceiver}
 */
public final void parseBindings(ErrorReceiver receiver){
    for (InputSource is : bindingFiles) {
        XMLStreamReader reader =
                XMLStreamReaderFactory.create(is,true);
        XMLStreamReaderUtil.nextElementContent(reader);
        if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
            jaxwsCustomBindings.add(new RereadInputSource(is));
        } else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
                reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
            jaxbCustomBindings.add(new RereadInputSource(is));
        } else {
            LocatorImpl locator = new LocatorImpl();
            locator.setSystemId(reader.getLocation().getSystemId());
            locator.setPublicId(reader.getLocation().getPublicId());
            locator.setLineNumber(reader.getLocation().getLineNumber());
            locator.setColumnNumber(reader.getLocation().getColumnNumber());
            receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
        }
    }
}
 
Example #16
Source File: EndpointArgumentsBuilder.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected void readWrappedRequest(Message msg, Object[] args) throws JAXBException, XMLStreamException {
    if (!msg.hasPayload()) {
        throw new WebServiceException("No payload. Expecting payload with "+wrapperName+" element");
    }
    XMLStreamReader reader = msg.readPayload();
    XMLStreamReaderUtil.verifyTag(reader,wrapperName);
    reader.nextTag();
    while(reader.getEventType()==XMLStreamReader.START_ELEMENT) {
        // TODO: QName has a performance issue
        QName name = reader.getName();
        WrappedPartBuilder part = wrappedParts.get(name);
        if(part==null) {
            // no corresponding part found. ignore
            XMLStreamReaderUtil.skipElement(reader);
            reader.nextTag();
        } else {
            part.readRequest(args,reader, msg.getAttachments());
        }
        XMLStreamReaderUtil.toNextTag(reader, name);
    }

    // we are done with the body
    reader.close();
    XMLStreamReaderFactory.recycle(reader);
}
 
Example #17
Source File: EndpointFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity (String publicId, String systemId) throws IOException, XMLStreamException {
    if (systemId != null) {
        SDDocumentSource doc = metadata.get(systemId);
        if (doc != null)
            return new Parser(doc);
    }
    if (resolver != null) {
        try {
            InputSource source = resolver.resolveEntity(publicId, systemId);
            if (source != null) {
                Parser p = new Parser(null, XMLStreamReaderFactory.create(source, true));
                return p;
            }
        } catch (SAXException e) {
            throw new XMLStreamException(e);
        }
    }
    return null;
}
 
Example #18
Source File: WsimportOptions.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
 * TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
 *
 * Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
 * to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
 *
 * @param receiver {@link ErrorReceiver}
 */
public final void parseBindings(ErrorReceiver receiver){
    for (InputSource is : bindingFiles) {
        XMLStreamReader reader =
                XMLStreamReaderFactory.create(is,true);
        XMLStreamReaderUtil.nextElementContent(reader);
        if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
            jaxwsCustomBindings.add(new RereadInputSource(is));
        } else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
                reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
            jaxbCustomBindings.add(new RereadInputSource(is));
        } else {
            LocatorImpl locator = new LocatorImpl();
            locator.setSystemId(reader.getLocation().getSystemId());
            locator.setPublicId(reader.getLocation().getPublicId());
            locator.setLineNumber(reader.getLocation().getLineNumber());
            locator.setColumnNumber(reader.getLocation().getColumnNumber());
            receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
        }
    }
}
 
Example #19
Source File: EntityResolverWrapper.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException {
    InputSource source = core.resolveEntity(publicId,systemId);
    if(source==null)
        return null;    // default

    // ideally entity resolvers should be giving us the system ID for the resource
    // (or otherwise we won't be able to resolve references within this imported WSDL correctly),
    // but if none is given, the system ID before the entity resolution is better than nothing.
    if(source.getSystemId()!=null)
        systemId = source.getSystemId();

    URL url = new URL(systemId);
    InputStream stream;
    if (useStreamFromEntityResolver) {
            stream = source.getByteStream();
    } else {
            stream = url.openStream();
    }
    return new Parser(url,
            new TidyXMLStreamReader(XMLStreamReaderFactory.create(url.toExternalForm(), stream, true), stream));
}
 
Example #20
Source File: EntityResolverWrapper.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException {
    InputSource source = core.resolveEntity(publicId,systemId);
    if(source==null)
        return null;    // default

    // ideally entity resolvers should be giving us the system ID for the resource
    // (or otherwise we won't be able to resolve references within this imported WSDL correctly),
    // but if none is given, the system ID before the entity resolution is better than nothing.
    if(source.getSystemId()!=null)
        systemId = source.getSystemId();

    URL url = new URL(systemId);
    InputStream stream;
    if (useStreamFromEntityResolver) {
            stream = source.getByteStream();
    } else {
            stream = url.openStream();
    }
    return new Parser(url,
            new TidyXMLStreamReader(XMLStreamReaderFactory.create(url.toExternalForm(), stream, true), stream));
}
 
Example #21
Source File: WsimportOptions.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
 * TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
 *
 * Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
 * to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
 *
 * @param receiver {@link ErrorReceiver}
 */
public final void parseBindings(ErrorReceiver receiver){
    for (InputSource is : bindingFiles) {
        XMLStreamReader reader =
                XMLStreamReaderFactory.create(is,true);
        XMLStreamReaderUtil.nextElementContent(reader);
        if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
            jaxwsCustomBindings.add(new RereadInputSource(is));
        } else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
                reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
            jaxbCustomBindings.add(new RereadInputSource(is));
        } else {
            LocatorImpl locator = new LocatorImpl();
            locator.setSystemId(reader.getLocation().getSystemId());
            locator.setPublicId(reader.getLocation().getPublicId());
            locator.setLineNumber(reader.getLocation().getLineNumber());
            locator.setColumnNumber(reader.getLocation().getColumnNumber());
            receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
        }
    }
}
 
Example #22
Source File: EndpointFactory.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity (String publicId, String systemId) throws IOException, XMLStreamException {
    if (systemId != null) {
        SDDocumentSource doc = metadata.get(systemId);
        if (doc != null)
            return new Parser(doc);
    }
    if (resolver != null) {
        try {
            InputSource source = resolver.resolveEntity(publicId, systemId);
            if (source != null) {
                Parser p = new Parser(null, XMLStreamReaderFactory.create(source, true));
                return p;
            }
        } catch (SAXException e) {
            throw new XMLStreamException(e);
        }
    }
    return null;
}
 
Example #23
Source File: EndpointArgumentsBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected void readWrappedRequest(Message msg, Object[] args) throws JAXBException, XMLStreamException {
    if (!msg.hasPayload()) {
        throw new WebServiceException("No payload. Expecting payload with "+wrapperName+" element");
    }
    XMLStreamReader reader = msg.readPayload();
    XMLStreamReaderUtil.verifyTag(reader,wrapperName);
    reader.nextTag();
    while(reader.getEventType()==XMLStreamReader.START_ELEMENT) {
        // TODO: QName has a performance issue
        QName name = reader.getName();
        WrappedPartBuilder part = wrappedParts.get(name);
        if(part==null) {
            // no corresponding part found. ignore
            XMLStreamReaderUtil.skipElement(reader);
            reader.nextTag();
        } else {
            part.readRequest(args,reader, msg.getAttachments());
        }
        XMLStreamReaderUtil.toNextTag(reader, name);
    }

    // we are done with the body
    reader.close();
    XMLStreamReaderFactory.recycle(reader);
}
 
Example #24
Source File: EndpointArgumentsBuilder.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected void readWrappedRequest(Message msg, Object[] args) throws JAXBException, XMLStreamException {
    if (!msg.hasPayload()) {
        throw new WebServiceException("No payload. Expecting payload with "+wrapperName+" element");
    }
    XMLStreamReader reader = msg.readPayload();
    XMLStreamReaderUtil.verifyTag(reader,wrapperName);
    reader.nextTag();
    while(reader.getEventType()==XMLStreamReader.START_ELEMENT) {
        // TODO: QName has a performance issue
        QName name = reader.getName();
        WrappedPartBuilder part = wrappedParts.get(name);
        if(part==null) {
            // no corresponding part found. ignore
            XMLStreamReaderUtil.skipElement(reader);
            reader.nextTag();
        } else {
            part.readRequest(args,reader, msg.getAttachments());
        }
        XMLStreamReaderUtil.toNextTag(reader, name);
    }

    // we are done with the body
    reader.close();
    XMLStreamReaderFactory.recycle(reader);
}
 
Example #25
Source File: EndpointFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity (String publicId, String systemId) throws IOException, XMLStreamException {
    if (systemId != null) {
        SDDocumentSource doc = metadata.get(systemId);
        if (doc != null)
            return new Parser(doc);
    }
    if (resolver != null) {
        try {
            InputSource source = resolver.resolveEntity(publicId, systemId);
            if (source != null) {
                Parser p = new Parser(null, XMLStreamReaderFactory.create(source, true));
                return p;
            }
        } catch (SAXException e) {
            throw new XMLStreamException(e);
        }
    }
    return null;
}
 
Example #26
Source File: WsimportOptions.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
 * TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
 *
 * Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
 * to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
 *
 * @param receiver {@link ErrorReceiver}
 */
public final void parseBindings(ErrorReceiver receiver){
    for (InputSource is : bindingFiles) {
        XMLStreamReader reader =
                XMLStreamReaderFactory.create(is,true);
        XMLStreamReaderUtil.nextElementContent(reader);
        if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
            jaxwsCustomBindings.add(new RereadInputSource(is));
        } else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
                reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
            jaxbCustomBindings.add(new RereadInputSource(is));
        } else {
            LocatorImpl locator = new LocatorImpl();
            locator.setSystemId(reader.getLocation().getSystemId());
            locator.setPublicId(reader.getLocation().getPublicId());
            locator.setLineNumber(reader.getLocation().getLineNumber());
            locator.setColumnNumber(reader.getLocation().getColumnNumber());
            receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
        }
    }
}
 
Example #27
Source File: EntityResolverWrapper.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException {
    InputSource source = core.resolveEntity(publicId,systemId);
    if(source==null)
        return null;    // default

    // ideally entity resolvers should be giving us the system ID for the resource
    // (or otherwise we won't be able to resolve references within this imported WSDL correctly),
    // but if none is given, the system ID before the entity resolution is better than nothing.
    if(source.getSystemId()!=null)
        systemId = source.getSystemId();

    URL url = new URL(systemId);
    InputStream stream;
    if (useStreamFromEntityResolver) {
            stream = source.getByteStream();
    } else {
            stream = url.openStream();
    }
    return new Parser(url,
            new TidyXMLStreamReader(XMLStreamReaderFactory.create(url.toExternalForm(), stream, true), stream));
}
 
Example #28
Source File: EntityResolverWrapper.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException {
    InputSource source = core.resolveEntity(publicId,systemId);
    if(source==null)
        return null;    // default

    // ideally entity resolvers should be giving us the system ID for the resource
    // (or otherwise we won't be able to resolve references within this imported WSDL correctly),
    // but if none is given, the system ID before the entity resolution is better than nothing.
    if(source.getSystemId()!=null)
        systemId = source.getSystemId();

    URL url = new URL(systemId);
    InputStream stream;
    if (useStreamFromEntityResolver) {
            stream = source.getByteStream();
    } else {
            stream = url.openStream();
    }
    return new Parser(url,
            new TidyXMLStreamReader(XMLStreamReaderFactory.create(url.toExternalForm(), stream, true), stream));
}
 
Example #29
Source File: WsimportOptions.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
 * TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
 *
 * Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
 * to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
 *
 * @param receiver {@link ErrorReceiver}
 */
public final void parseBindings(ErrorReceiver receiver){
    for (InputSource is : bindingFiles) {
        XMLStreamReader reader =
                XMLStreamReaderFactory.create(is,true);
        XMLStreamReaderUtil.nextElementContent(reader);
        if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
            jaxwsCustomBindings.add(new RereadInputSource(is));
        } else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
                reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
            jaxbCustomBindings.add(new RereadInputSource(is));
        } else {
            LocatorImpl locator = new LocatorImpl();
            locator.setSystemId(reader.getLocation().getSystemId());
            locator.setPublicId(reader.getLocation().getPublicId());
            locator.setLineNumber(reader.getLocation().getLineNumber());
            locator.setColumnNumber(reader.getLocation().getColumnNumber());
            receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
        }
    }
}
 
Example #30
Source File: EndpointArgumentsBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected void readWrappedRequest(Message msg, Object[] args) throws JAXBException, XMLStreamException {
    if (!msg.hasPayload()) {
        throw new WebServiceException("No payload. Expecting payload with "+wrapperName+" element");
    }
    XMLStreamReader reader = msg.readPayload();
    XMLStreamReaderUtil.verifyTag(reader,wrapperName);
    reader.nextTag();
    while(reader.getEventType()==XMLStreamReader.START_ELEMENT) {
        // TODO: QName has a performance issue
        QName name = reader.getName();
        WrappedPartBuilder part = wrappedParts.get(name);
        if(part==null) {
            // no corresponding part found. ignore
            XMLStreamReaderUtil.skipElement(reader);
            reader.nextTag();
        } else {
            part.readRequest(args,reader, msg.getAttachments());
        }
        XMLStreamReaderUtil.toNextTag(reader, name);
    }

    // we are done with the body
    reader.close();
    XMLStreamReaderFactory.recycle(reader);
}