com.sun.xml.internal.ws.api.server.SDDocument Java Examples

The following examples show how to use com.sun.xml.internal.ws.api.server.SDDocument. 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: AbstractSchemaValidationTube.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private Document createDOM(SDDocument doc) {
    // Get infoset
    ByteArrayBuffer bab = new ByteArrayBuffer();
    try {
        doc.writeTo(null, resolver, bab);
    } catch (IOException ioe) {
        throw new WebServiceException(ioe);
    }

    // Convert infoset to DOM
    Transformer trans = XmlUtil.newTransformer();
    Source source = new StreamSource(bab.newInputStream(), null); //doc.getURL().toExternalForm());
    DOMResult result = new DOMResult();
    try {
        trans.transform(source, result);
    } catch(TransformerException te) {
        throw new WebServiceException(te);
    }
    return (Document)result.getNode();
}
 
Example #2
Source File: EndpointFactory.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies whether the given primaryWsdl contains the given serviceName.
 * If the WSDL doesn't have the service, it throws an WebServiceException.
 */
private static void verifyPrimaryWSDL(@NotNull SDDocumentSource primaryWsdl, @NotNull QName serviceName) {
    SDDocumentImpl primaryDoc = SDDocumentImpl.create(primaryWsdl,serviceName,null);
    if (!(primaryDoc instanceof SDDocument.WSDL)) {
        throw new WebServiceException(primaryWsdl.getSystemId()+
                " is not a WSDL. But it is passed as a primary WSDL");
    }
    SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)primaryDoc;
    if (!wsdlDoc.hasService()) {
        if(wsdlDoc.getAllServices().isEmpty())
            throw new WebServiceException("Not a primary WSDL="+primaryWsdl.getSystemId()+
                    " since it doesn't have Service "+serviceName);
        else
            throw new WebServiceException("WSDL "+primaryDoc.getSystemId()
                    +" has the following services "+wsdlDoc.getAllServices()
                    +" but not "+serviceName+". Maybe you forgot to specify a serviceName and/or targetNamespace in @WebService/@WebServiceProvider?");
    }
}
 
Example #3
Source File: EndpointFactory.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies whether the given primaryWsdl contains the given serviceName.
 * If the WSDL doesn't have the service, it throws an WebServiceException.
 */
private static void verifyPrimaryWSDL(@NotNull SDDocumentSource primaryWsdl, @NotNull QName serviceName) {
    SDDocumentImpl primaryDoc = SDDocumentImpl.create(primaryWsdl,serviceName,null);
    if (!(primaryDoc instanceof SDDocument.WSDL)) {
        throw new WebServiceException(primaryWsdl.getSystemId()+
                " is not a WSDL. But it is passed as a primary WSDL");
    }
    SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)primaryDoc;
    if (!wsdlDoc.hasService()) {
        if(wsdlDoc.getAllServices().isEmpty())
            throw new WebServiceException("Not a primary WSDL="+primaryWsdl.getSystemId()+
                    " since it doesn't have Service "+serviceName);
        else
            throw new WebServiceException("WSDL "+primaryDoc.getSystemId()
                    +" has the following services "+wsdlDoc.getAllServices()
                    +" but not "+serviceName+". Maybe you forgot to specify a serviceName and/or targetNamespace in @WebService/@WebServiceProvider?");
    }
}
 
Example #4
Source File: EndpointFactory.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds the primary WSDL document from the list of metadata documents. If
 * there are two metadata documents that qualify for primary, it throws an
 * exception. If there are two metadata documents that qualify for porttype,
 * it throws an exception.
 *
 * @return primay wsdl document, null if is not there in the docList
 *
 */
private static @Nullable SDDocumentImpl findPrimary(@NotNull List<SDDocumentImpl> docList) {
    SDDocumentImpl primaryDoc = null;
    boolean foundConcrete = false;
    boolean foundAbstract = false;
    for(SDDocumentImpl doc : docList) {
        if (doc instanceof SDDocument.WSDL) {
            SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)doc;
            if (wsdlDoc.hasService()) {
                primaryDoc = doc;
                if (foundConcrete) {
                    throw new ServerRtException("duplicate.primary.wsdl", doc.getSystemId() );
                }
                foundConcrete = true;
            }
            if (wsdlDoc.hasPortType()) {
                if (foundAbstract) {
                    throw new ServerRtException("duplicate.abstract.wsdl", doc.getSystemId());
                }
                foundAbstract = true;
            }
        }
    }
    return primaryDoc;
}
 
Example #5
Source File: AbstractSchemaValidationTube.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private Document createDOM(SDDocument doc) {
    // Get infoset
    ByteArrayBuffer bab = new ByteArrayBuffer();
    try {
        doc.writeTo(null, resolver, bab);
    } catch (IOException ioe) {
        throw new WebServiceException(ioe);
    }

    // Convert infoset to DOM
    Transformer trans = XmlUtil.newTransformer();
    Source source = new StreamSource(bab.newInputStream(), null); //doc.getURL().toExternalForm());
    DOMResult result = new DOMResult();
    try {
        trans.transform(source, result);
    } catch(TransformerException te) {
        throw new WebServiceException(te);
    }
    return (Document)result.getNode();
}
 
Example #6
Source File: EndpointFactory.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds the primary WSDL document from the list of metadata documents. If
 * there are two metadata documents that qualify for primary, it throws an
 * exception. If there are two metadata documents that qualify for porttype,
 * it throws an exception.
 *
 * @return primay wsdl document, null if is not there in the docList
 *
 */
private static @Nullable SDDocumentImpl findPrimary(@NotNull List<SDDocumentImpl> docList) {
    SDDocumentImpl primaryDoc = null;
    boolean foundConcrete = false;
    boolean foundAbstract = false;
    for(SDDocumentImpl doc : docList) {
        if (doc instanceof SDDocument.WSDL) {
            SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)doc;
            if (wsdlDoc.hasService()) {
                primaryDoc = doc;
                if (foundConcrete) {
                    throw new ServerRtException("duplicate.primary.wsdl", doc.getSystemId() );
                }
                foundConcrete = true;
            }
            if (wsdlDoc.hasPortType()) {
                if (foundAbstract) {
                    throw new ServerRtException("duplicate.abstract.wsdl", doc.getSystemId());
                }
                foundAbstract = true;
            }
        }
    }
    return primaryDoc;
}
 
Example #7
Source File: HttpAdapter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sends out the WSDL (and other referenced documents)
 * in response to the GET requests to URLs like "?wsdl" or "?xsd=2".
 *
 * @param con
 *      The connection to which the data will be sent.
 *
 * @throws java.io.IOException when I/O errors happen
 */
public void publishWSDL(@NotNull WSHTTPConnection con) throws IOException {
    con.getInput().close();

    SDDocument doc = wsdls.get(con.getQueryString());
    if (doc == null) {
        writeNotFoundErrorPage(con,"Invalid Request");
        return;
    }

    con.setStatus(HttpURLConnection.HTTP_OK);
    con.setContentTypeResponseHeader("text/xml;charset=utf-8");

    OutputStream os = con.getProtocol().contains("1.1") ? con.getOutput() : new Http10OutputStream(con);

    PortAddressResolver portAddressResolver = getPortAddressResolver(con.getBaseAddress());
    DocumentAddressResolver resolver = getDocumentAddressResolver(portAddressResolver);

    doc.writeTo(portAddressResolver, resolver, os);
    os.close();
}
 
Example #8
Source File: WSDLGenResolver.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public WSDLGenResolver(@NotNull List<SDDocumentImpl> docs,QName serviceName,QName portTypeName) {
    this.docs = docs;
    this.serviceName = serviceName;
    this.portTypeName = portTypeName;

    for (SDDocumentImpl doc : docs) {
        if(doc.isWSDL()) {
            SDDocument.WSDL wsdl = (SDDocument.WSDL) doc;
            if(wsdl.hasPortType())
                abstractWsdl = doc;
        }
        if(doc.isSchema()) {
            SDDocument.Schema schema = (SDDocument.Schema) doc;
            List<SDDocumentImpl> sysIds = nsMapping.get(schema.getTargetNamespace());
            if (sysIds == null) {
                sysIds = new ArrayList<SDDocumentImpl>();
                nsMapping.put(schema.getTargetNamespace(), sysIds);
            }
            sysIds.add(doc);
        }
    }
}
 
Example #9
Source File: EndpointFactory.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds the primary WSDL document from the list of metadata documents. If
 * there are two metadata documents that qualify for primary, it throws an
 * exception. If there are two metadata documents that qualify for porttype,
 * it throws an exception.
 *
 * @return primay wsdl document, null if is not there in the docList
 *
 */
private static @Nullable SDDocumentImpl findPrimary(@NotNull List<SDDocumentImpl> docList) {
    SDDocumentImpl primaryDoc = null;
    boolean foundConcrete = false;
    boolean foundAbstract = false;
    for(SDDocumentImpl doc : docList) {
        if (doc instanceof SDDocument.WSDL) {
            SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)doc;
            if (wsdlDoc.hasService()) {
                primaryDoc = doc;
                if (foundConcrete) {
                    throw new ServerRtException("duplicate.primary.wsdl", doc.getSystemId() );
                }
                foundConcrete = true;
            }
            if (wsdlDoc.hasPortType()) {
                if (foundAbstract) {
                    throw new ServerRtException("duplicate.abstract.wsdl", doc.getSystemId());
                }
                foundAbstract = true;
            }
        }
    }
    return primaryDoc;
}
 
Example #10
Source File: AbstractSchemaValidationTube.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private Document createDOM(SDDocument doc) {
    // Get infoset
    ByteArrayBuffer bab = new ByteArrayBuffer();
    try {
        doc.writeTo(null, resolver, bab);
    } catch (IOException ioe) {
        throw new WebServiceException(ioe);
    }

    // Convert infoset to DOM
    Transformer trans = XmlUtil.newTransformer();
    Source source = new StreamSource(bab.newInputStream(), null); //doc.getURL().toExternalForm());
    DOMResult result = new DOMResult();
    try {
        trans.transform(source, result);
    } catch(TransformerException te) {
        throw new WebServiceException(te);
    }
    return (Document)result.getNode();
}
 
Example #11
Source File: HttpAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sends out the WSDL (and other referenced documents)
 * in response to the GET requests to URLs like "?wsdl" or "?xsd=2".
 *
 * @param con
 *      The connection to which the data will be sent.
 *
 * @throws java.io.IOException when I/O errors happen
 */
public void publishWSDL(@NotNull WSHTTPConnection con) throws IOException {
    con.getInput().close();

    SDDocument doc = wsdls.get(con.getQueryString());
    if (doc == null) {
        writeNotFoundErrorPage(con,"Invalid Request");
        return;
    }

    con.setStatus(HttpURLConnection.HTTP_OK);
    con.setContentTypeResponseHeader("text/xml;charset=utf-8");

    OutputStream os = con.getProtocol().contains("1.1") ? con.getOutput() : new Http10OutputStream(con);

    PortAddressResolver portAddressResolver = getPortAddressResolver(con.getBaseAddress());
    DocumentAddressResolver resolver = getDocumentAddressResolver(portAddressResolver);

    doc.writeTo(portAddressResolver, resolver, os);
    os.close();
}
 
Example #12
Source File: EndpointFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies whether the given primaryWsdl contains the given serviceName.
 * If the WSDL doesn't have the service, it throws an WebServiceException.
 */
private static void verifyPrimaryWSDL(@NotNull SDDocumentSource primaryWsdl, @NotNull QName serviceName) {
    SDDocumentImpl primaryDoc = SDDocumentImpl.create(primaryWsdl,serviceName,null);
    if (!(primaryDoc instanceof SDDocument.WSDL)) {
        throw new WebServiceException(primaryWsdl.getSystemId()+
                " is not a WSDL. But it is passed as a primary WSDL");
    }
    SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)primaryDoc;
    if (!wsdlDoc.hasService()) {
        if(wsdlDoc.getAllServices().isEmpty())
            throw new WebServiceException("Not a primary WSDL="+primaryWsdl.getSystemId()+
                    " since it doesn't have Service "+serviceName);
        else
            throw new WebServiceException("WSDL "+primaryDoc.getSystemId()
                    +" has the following services "+wsdlDoc.getAllServices()
                    +" but not "+serviceName+". Maybe you forgot to specify a serviceName and/or targetNamespace in @WebService/@WebServiceProvider?");
    }
}
 
Example #13
Source File: EndpointFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds the primary WSDL document from the list of metadata documents. If
 * there are two metadata documents that qualify for primary, it throws an
 * exception. If there are two metadata documents that qualify for porttype,
 * it throws an exception.
 *
 * @return primay wsdl document, null if is not there in the docList
 *
 */
private static @Nullable SDDocumentImpl findPrimary(@NotNull List<SDDocumentImpl> docList) {
    SDDocumentImpl primaryDoc = null;
    boolean foundConcrete = false;
    boolean foundAbstract = false;
    for(SDDocumentImpl doc : docList) {
        if (doc instanceof SDDocument.WSDL) {
            SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)doc;
            if (wsdlDoc.hasService()) {
                primaryDoc = doc;
                if (foundConcrete) {
                    throw new ServerRtException("duplicate.primary.wsdl", doc.getSystemId() );
                }
                foundConcrete = true;
            }
            if (wsdlDoc.hasPortType()) {
                if (foundAbstract) {
                    throw new ServerRtException("duplicate.abstract.wsdl", doc.getSystemId());
                }
                foundAbstract = true;
            }
        }
    }
    return primaryDoc;
}
 
Example #14
Source File: HttpAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sends out the WSDL (and other referenced documents)
 * in response to the GET requests to URLs like "?wsdl" or "?xsd=2".
 *
 * @param con
 *      The connection to which the data will be sent.
 *
 * @throws java.io.IOException when I/O errors happen
 */
public void publishWSDL(@NotNull WSHTTPConnection con) throws IOException {
    con.getInput().close();

    SDDocument doc = wsdls.get(con.getQueryString());
    if (doc == null) {
        writeNotFoundErrorPage(con,"Invalid Request");
        return;
    }

    con.setStatus(HttpURLConnection.HTTP_OK);
    con.setContentTypeResponseHeader("text/xml;charset=utf-8");

    OutputStream os = con.getProtocol().contains("1.1") ? con.getOutput() : new Http10OutputStream(con);

    PortAddressResolver portAddressResolver = getPortAddressResolver(con.getBaseAddress());
    DocumentAddressResolver resolver = getDocumentAddressResolver(portAddressResolver);

    doc.writeTo(portAddressResolver, resolver, os);
    os.close();
}
 
Example #15
Source File: EndpointFactory.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds the primary WSDL document from the list of metadata documents. If
 * there are two metadata documents that qualify for primary, it throws an
 * exception. If there are two metadata documents that qualify for porttype,
 * it throws an exception.
 *
 * @return primay wsdl document, null if is not there in the docList
 *
 */
private static @Nullable SDDocumentImpl findPrimary(@NotNull List<SDDocumentImpl> docList) {
    SDDocumentImpl primaryDoc = null;
    boolean foundConcrete = false;
    boolean foundAbstract = false;
    for(SDDocumentImpl doc : docList) {
        if (doc instanceof SDDocument.WSDL) {
            SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)doc;
            if (wsdlDoc.hasService()) {
                primaryDoc = doc;
                if (foundConcrete) {
                    throw new ServerRtException("duplicate.primary.wsdl", doc.getSystemId() );
                }
                foundConcrete = true;
            }
            if (wsdlDoc.hasPortType()) {
                if (foundAbstract) {
                    throw new ServerRtException("duplicate.abstract.wsdl", doc.getSystemId());
                }
                foundAbstract = true;
            }
        }
    }
    return primaryDoc;
}
 
Example #16
Source File: HttpAdapter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sends out the WSDL (and other referenced documents)
 * in response to the GET requests to URLs like "?wsdl" or "?xsd=2".
 *
 * @param con
 *      The connection to which the data will be sent.
 *
 * @throws java.io.IOException when I/O errors happen
 */
public void publishWSDL(@NotNull WSHTTPConnection con) throws IOException {
    con.getInput().close();

    SDDocument doc = wsdls.get(con.getQueryString());
    if (doc == null) {
        writeNotFoundErrorPage(con,"Invalid Request");
        return;
    }

    con.setStatus(HttpURLConnection.HTTP_OK);
    con.setContentTypeResponseHeader("text/xml;charset=utf-8");

    OutputStream os = con.getProtocol().contains("1.1") ? con.getOutput() : new Http10OutputStream(con);

    PortAddressResolver portAddressResolver = getPortAddressResolver(con.getBaseAddress());
    DocumentAddressResolver resolver = getDocumentAddressResolver(portAddressResolver);

    doc.writeTo(portAddressResolver, resolver, os);
    os.close();
}
 
Example #17
Source File: EndpointFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies whether the given primaryWsdl contains the given serviceName.
 * If the WSDL doesn't have the service, it throws an WebServiceException.
 */
private static void verifyPrimaryWSDL(@NotNull SDDocumentSource primaryWsdl, @NotNull QName serviceName) {
    SDDocumentImpl primaryDoc = SDDocumentImpl.create(primaryWsdl,serviceName,null);
    if (!(primaryDoc instanceof SDDocument.WSDL)) {
        throw new WebServiceException(primaryWsdl.getSystemId()+
                " is not a WSDL. But it is passed as a primary WSDL");
    }
    SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)primaryDoc;
    if (!wsdlDoc.hasService()) {
        if(wsdlDoc.getAllServices().isEmpty())
            throw new WebServiceException("Not a primary WSDL="+primaryWsdl.getSystemId()+
                    " since it doesn't have Service "+serviceName);
        else
            throw new WebServiceException("WSDL "+primaryDoc.getSystemId()
                    +" has the following services "+wsdlDoc.getAllServices()
                    +" but not "+serviceName+". Maybe you forgot to specify a serviceName and/or targetNamespace in @WebService/@WebServiceProvider?");
    }
}
 
Example #18
Source File: AbstractSchemaValidationTube.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private Document createDOM(SDDocument doc) {
    // Get infoset
    ByteArrayBuffer bab = new ByteArrayBuffer();
    try {
        doc.writeTo(null, resolver, bab);
    } catch (IOException ioe) {
        throw new WebServiceException(ioe);
    }

    // Convert infoset to DOM
    Transformer trans = XmlUtil.newTransformer();
    Source source = new StreamSource(bab.newInputStream(), null); //doc.getURL().toExternalForm());
    DOMResult result = new DOMResult();
    try {
        trans.transform(source, result);
    } catch(TransformerException te) {
        throw new WebServiceException(te);
    }
    return (Document)result.getNode();
}
 
Example #19
Source File: EndpointFactory.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies whether the given primaryWsdl contains the given serviceName.
 * If the WSDL doesn't have the service, it throws an WebServiceException.
 */
private static void verifyPrimaryWSDL(@NotNull SDDocumentSource primaryWsdl, @NotNull QName serviceName) {
    SDDocumentImpl primaryDoc = SDDocumentImpl.create(primaryWsdl,serviceName,null);
    if (!(primaryDoc instanceof SDDocument.WSDL)) {
        throw new WebServiceException(primaryWsdl.getSystemId()+
                " is not a WSDL. But it is passed as a primary WSDL");
    }
    SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)primaryDoc;
    if (!wsdlDoc.hasService()) {
        if(wsdlDoc.getAllServices().isEmpty())
            throw new WebServiceException("Not a primary WSDL="+primaryWsdl.getSystemId()+
                    " since it doesn't have Service "+serviceName);
        else
            throw new WebServiceException("WSDL "+primaryDoc.getSystemId()
                    +" has the following services "+wsdlDoc.getAllServices()
                    +" but not "+serviceName+". Maybe you forgot to specify a serviceName and/or targetNamespace in @WebService/@WebServiceProvider?");
    }
}
 
Example #20
Source File: HttpAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sends out the WSDL (and other referenced documents)
 * in response to the GET requests to URLs like "?wsdl" or "?xsd=2".
 *
 * @param con
 *      The connection to which the data will be sent.
 *
 * @throws java.io.IOException when I/O errors happen
 */
public void publishWSDL(@NotNull WSHTTPConnection con) throws IOException {
    con.getInput().close();

    SDDocument doc = wsdls.get(con.getQueryString());
    if (doc == null) {
        writeNotFoundErrorPage(con,"Invalid Request");
        return;
    }

    con.setStatus(HttpURLConnection.HTTP_OK);
    con.setContentTypeResponseHeader("text/xml;charset=utf-8");

    OutputStream os = con.getProtocol().contains("1.1") ? con.getOutput() : new Http10OutputStream(con);

    PortAddressResolver portAddressResolver = getPortAddressResolver(con.getBaseAddress());
    DocumentAddressResolver resolver = getDocumentAddressResolver(portAddressResolver);

    doc.writeTo(portAddressResolver, resolver, os);
    os.close();
}
 
Example #21
Source File: WSDLGenResolver.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public WSDLGenResolver(@NotNull Collection<SDDocumentImpl> docs,QName serviceName,QName portTypeName) {
    this.docs = docs;
    this.serviceName = serviceName;
    this.portTypeName = portTypeName;

    for (SDDocumentImpl doc : docs) {
        if(doc.isWSDL()) {
            SDDocument.WSDL wsdl = (SDDocument.WSDL) doc;
            if(wsdl.hasPortType())
                abstractWsdl = doc;
        }
        if(doc.isSchema()) {
            SDDocument.Schema schema = (SDDocument.Schema) doc;
            List<SDDocumentImpl> sysIds = nsMapping.get(schema.getTargetNamespace());
            if (sysIds == null) {
                sysIds = new ArrayList<SDDocumentImpl>();
                nsMapping.put(schema.getTargetNamespace(), sysIds);
            }
            sysIds.add(doc);
        }
    }
}
 
Example #22
Source File: AbstractSchemaValidationTube.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private Document createDOM(SDDocument doc) {
    // Get infoset
    ByteArrayBuffer bab = new ByteArrayBuffer();
    try {
        doc.writeTo(null, resolver, bab);
    } catch (IOException ioe) {
        throw new WebServiceException(ioe);
    }

    // Convert infoset to DOM
    Transformer trans = XmlUtil.newTransformer();
    Source source = new StreamSource(bab.newInputStream(), null); //doc.getURL().toExternalForm());
    DOMResult result = new DOMResult();
    try {
        trans.transform(source, result);
    } catch(TransformerException te) {
        throw new WebServiceException(te);
    }
    return (Document)result.getNode();
}
 
Example #23
Source File: EndpointFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies whether the given primaryWsdl contains the given serviceName.
 * If the WSDL doesn't have the service, it throws an WebServiceException.
 */
private static void verifyPrimaryWSDL(@NotNull SDDocumentSource primaryWsdl, @NotNull QName serviceName) {
    SDDocumentImpl primaryDoc = SDDocumentImpl.create(primaryWsdl,serviceName,null);
    if (!(primaryDoc instanceof SDDocument.WSDL)) {
        throw new WebServiceException(primaryWsdl.getSystemId()+
                " is not a WSDL. But it is passed as a primary WSDL");
    }
    SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)primaryDoc;
    if (!wsdlDoc.hasService()) {
        if(wsdlDoc.getAllServices().isEmpty())
            throw new WebServiceException("Not a primary WSDL="+primaryWsdl.getSystemId()+
                    " since it doesn't have Service "+serviceName);
        else
            throw new WebServiceException("WSDL "+primaryDoc.getSystemId()
                    +" has the following services "+wsdlDoc.getAllServices()
                    +" but not "+serviceName+". Maybe you forgot to specify a serviceName and/or targetNamespace in @WebService/@WebServiceProvider?");
    }
}
 
Example #24
Source File: EndpointFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds the primary WSDL document from the list of metadata documents. If
 * there are two metadata documents that qualify for primary, it throws an
 * exception. If there are two metadata documents that qualify for porttype,
 * it throws an exception.
 *
 * @return primay wsdl document, null if is not there in the docList
 *
 */
private static @Nullable SDDocumentImpl findPrimary(@NotNull Collection<SDDocumentImpl> docList) {
    SDDocumentImpl primaryDoc = null;
    boolean foundConcrete = false;
    boolean foundAbstract = false;
    for(SDDocumentImpl doc : docList) {
        if (doc instanceof SDDocument.WSDL) {
            SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)doc;
            if (wsdlDoc.hasService()) {
                primaryDoc = doc;
                if (foundConcrete) {
                    throw new ServerRtException("duplicate.primary.wsdl", doc.getSystemId() );
                }
                foundConcrete = true;
            }
            if (wsdlDoc.hasPortType()) {
                if (foundAbstract) {
                    throw new ServerRtException("duplicate.abstract.wsdl", doc.getSystemId());
                }
                foundAbstract = true;
            }
        }
    }
    return primaryDoc;
}
 
Example #25
Source File: WSDLGenResolver.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public WSDLGenResolver(@NotNull List<SDDocumentImpl> docs,QName serviceName,QName portTypeName) {
    this.docs = docs;
    this.serviceName = serviceName;
    this.portTypeName = portTypeName;

    for (SDDocumentImpl doc : docs) {
        if(doc.isWSDL()) {
            SDDocument.WSDL wsdl = (SDDocument.WSDL) doc;
            if(wsdl.hasPortType())
                abstractWsdl = doc;
        }
        if(doc.isSchema()) {
            SDDocument.Schema schema = (SDDocument.Schema) doc;
            List<SDDocumentImpl> sysIds = nsMapping.get(schema.getTargetNamespace());
            if (sysIds == null) {
                sysIds = new ArrayList<SDDocumentImpl>();
                nsMapping.put(schema.getTargetNamespace(), sysIds);
            }
            sysIds.add(doc);
        }
    }
}
 
Example #26
Source File: EndpointFactory.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Verifies whether the given primaryWsdl contains the given serviceName.
 * If the WSDL doesn't have the service, it throws an WebServiceException.
 */
private static void verifyPrimaryWSDL(@NotNull SDDocumentSource primaryWsdl, @NotNull QName serviceName) {
    SDDocumentImpl primaryDoc = SDDocumentImpl.create(primaryWsdl,serviceName,null);
    if (!(primaryDoc instanceof SDDocument.WSDL)) {
        throw new WebServiceException(primaryWsdl.getSystemId()+
                " is not a WSDL. But it is passed as a primary WSDL");
    }
    SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)primaryDoc;
    if (!wsdlDoc.hasService()) {
        if(wsdlDoc.getAllServices().isEmpty())
            throw new WebServiceException("Not a primary WSDL="+primaryWsdl.getSystemId()+
                    " since it doesn't have Service "+serviceName);
        else
            throw new WebServiceException("WSDL "+primaryDoc.getSystemId()
                    +" has the following services "+wsdlDoc.getAllServices()
                    +" but not "+serviceName+". Maybe you forgot to specify a serviceName and/or targetNamespace in @WebService/@WebServiceProvider?");
    }
}
 
Example #27
Source File: EndpointFactory.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds the primary WSDL document from the list of metadata documents. If
 * there are two metadata documents that qualify for primary, it throws an
 * exception. If there are two metadata documents that qualify for porttype,
 * it throws an exception.
 *
 * @return primay wsdl document, null if is not there in the docList
 *
 */
private static @Nullable SDDocumentImpl findPrimary(@NotNull List<SDDocumentImpl> docList) {
    SDDocumentImpl primaryDoc = null;
    boolean foundConcrete = false;
    boolean foundAbstract = false;
    for(SDDocumentImpl doc : docList) {
        if (doc instanceof SDDocument.WSDL) {
            SDDocument.WSDL wsdlDoc = (SDDocument.WSDL)doc;
            if (wsdlDoc.hasService()) {
                primaryDoc = doc;
                if (foundConcrete) {
                    throw new ServerRtException("duplicate.primary.wsdl", doc.getSystemId() );
                }
                foundConcrete = true;
            }
            if (wsdlDoc.hasPortType()) {
                if (foundAbstract) {
                    throw new ServerRtException("duplicate.abstract.wsdl", doc.getSystemId());
                }
                foundAbstract = true;
            }
        }
    }
    return primaryDoc;
}
 
Example #28
Source File: HttpAdapter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sends out the WSDL (and other referenced documents)
 * in response to the GET requests to URLs like "?wsdl" or "?xsd=2".
 *
 * @param con
 *      The connection to which the data will be sent.
 *
 * @throws java.io.IOException when I/O errors happen
 */
public void publishWSDL(@NotNull WSHTTPConnection con) throws IOException {
    con.getInput().close();

    SDDocument doc = wsdls.get(con.getQueryString());
    if (doc == null) {
        writeNotFoundErrorPage(con,"Invalid Request");
        return;
    }

    con.setStatus(HttpURLConnection.HTTP_OK);
    con.setContentTypeResponseHeader("text/xml;charset=utf-8");

    OutputStream os = con.getProtocol().contains("1.1") ? con.getOutput() : new Http10OutputStream(con);

    PortAddressResolver portAddressResolver = getPortAddressResolver(con.getBaseAddress());
    DocumentAddressResolver resolver = getDocumentAddressResolver(portAddressResolver);

    doc.writeTo(portAddressResolver, resolver, os);
    os.close();
}
 
Example #29
Source File: ClientSchemaValidationTube.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public ClientSchemaValidationTube(WSBinding binding, WSDLPort port, Tube next) {
    super(binding, next);
    this.port = port;
    if (port != null) {
        String primaryWsdl = port.getOwner().getParent().getLocation().getSystemId();
        MetadataResolverImpl mdresolver = new MetadataResolverImpl();
        Map<String, SDDocument> docs = MetadataUtil.getMetadataClosure(primaryWsdl, mdresolver, true);
        mdresolver = new MetadataResolverImpl(docs.values());
        Source[] sources = getSchemaSources(docs.values(), mdresolver);
        for(Source source : sources) {
            LOGGER.fine("Constructing client validation schema from = "+source.getSystemId());
            //printDOM((DOMSource)source);
        }
        if (sources.length != 0) {
            noValidation = false;
            sf.setResourceResolver(mdresolver);
            try {
                schema = sf.newSchema(sources);
            } catch(SAXException e) {
                throw new WebServiceException(e);
            }
            validator = schema.newValidator();
            return;
        }
    }
    noValidation = true;
    schema = null;
    validator = null;
}
 
Example #30
Source File: MetadataUtil.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets closure of all the referenced documents from the primary document(typically
 * the service WSDL). It traverses the WSDL and schema imports and builds a closure
 * set of documents.
 *
 * @param systemId primary wsdl or the any root document
 * @param resolver used to get SDDocumentImpl for a document
 * @param onlyTopLevelSchemas if true, the imported schemas from a schema would be ignored
 * @return all the documents
 */
public static Map<String, SDDocument> getMetadataClosure(@NotNull String systemId,
        @NotNull SDDocumentResolver resolver, boolean onlyTopLevelSchemas) {
    Map <String, SDDocument> closureDocs = new HashMap<String, SDDocument>();
    Set<String> remaining = new HashSet<String>();
    remaining.add(systemId);

    while(!remaining.isEmpty()) {
        Iterator<String> it = remaining.iterator();
        String current = it.next();
        remaining.remove(current);

        SDDocument currentDoc = resolver.resolve(current);
        SDDocument old = closureDocs.put(currentDoc.getURL().toExternalForm(), currentDoc);
        assert old == null;

        Set<String> imports =  currentDoc.getImports();
        if (!currentDoc.isSchema() || !onlyTopLevelSchemas) {
            for(String importedDoc : imports) {
                if (closureDocs.get(importedDoc) == null) {
                    remaining.add(importedDoc);
                }
            }
        }
    }

    return closureDocs;
}