Java Code Examples for com.sun.tools.internal.ws.wsdl.document.schema.SchemaKinds#XSD_ELEMENT

The following examples show how to use com.sun.tools.internal.ws.wsdl.document.schema.SchemaKinds#XSD_ELEMENT . 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: WSDLModelerBase.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * For Document/Lit the wsdl:part should only have element attribute and
 * for RPC/Lit or RPC/Encoded the wsdl:part should only have type attribute
 * inside wsdl:message.
 */
protected boolean isStyleAndPartMatch(
    SOAPOperation soapOperation,
    MessagePart part) {

    // style attribute on soap:operation takes precedence over the
    // style attribute on soap:binding

    if ((soapOperation != null) && (soapOperation.getStyle() != null)) {
        if ((soapOperation.isDocument()
            && (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT))
            || (soapOperation.isRPC()
                && (part.getDescriptorKind() != SchemaKinds.XSD_TYPE))) {
            return false;
        }
    } else {
        if ((info.soapBinding.isDocument()
            && (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT))
            || (info.soapBinding.isRPC()
                && (part.getDescriptorKind() != SchemaKinds.XSD_TYPE))) {
            return false;
        }
    }

    return true;
}
 
Example 2
Source File: SOAPEntityReferenceValidator.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public boolean isValid(Kind kind, QName name) {

        // just let all "xml:" QNames through
        if (name.getNamespaceURI().equals(Constants.NS_XML))
            return true;

        if (kind == SchemaKinds.XSD_TYPE) {
            return _validTypes.contains(name);
        } else if (kind == SchemaKinds.XSD_ELEMENT) {
            return _validElements.contains(name);
        } else if (kind == SchemaKinds.XSD_ATTRIBUTE) {
            return _validAttributes.contains(name);
        } else {
            // no luck
            return false;
        }
    }
 
Example 3
Source File: WSDLModelerBase.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * For Document/Lit the wsdl:part should only have element attribute and
 * for RPC/Lit or RPC/Encoded the wsdl:part should only have type attribute
 * inside wsdl:message.
 */
protected boolean isStyleAndPartMatch(
    SOAPOperation soapOperation,
    MessagePart part) {

    // style attribute on soap:operation takes precedence over the
    // style attribute on soap:binding

    if ((soapOperation != null) && (soapOperation.getStyle() != null)) {
        if ((soapOperation.isDocument()
            && (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT))
            || (soapOperation.isRPC()
                && (part.getDescriptorKind() != SchemaKinds.XSD_TYPE))) {
            return false;
        }
    } else {
        if ((info.soapBinding.isDocument()
            && (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT))
            || (info.soapBinding.isRPC()
                && (part.getDescriptorKind() != SchemaKinds.XSD_TYPE))) {
            return false;
        }
    }

    return true;
}
 
Example 4
Source File: WSDLModelerBase.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * For Document/Lit the wsdl:part should only have element attribute and
 * for RPC/Lit or RPC/Encoded the wsdl:part should only have type attribute
 * inside wsdl:message.
 */
protected boolean isStyleAndPartMatch(
    SOAPOperation soapOperation,
    MessagePart part) {

    // style attribute on soap:operation takes precedence over the
    // style attribute on soap:binding

    if ((soapOperation != null) && (soapOperation.getStyle() != null)) {
        if ((soapOperation.isDocument()
            && (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT))
            || (soapOperation.isRPC()
                && (part.getDescriptorKind() != SchemaKinds.XSD_TYPE))) {
            return false;
        }
    } else {
        if ((info.soapBinding.isDocument()
            && (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT))
            || (info.soapBinding.isRPC()
                && (part.getDescriptorKind() != SchemaKinds.XSD_TYPE))) {
            return false;
        }
    }

    return true;
}
 
Example 5
Source File: SOAPEntityReferenceValidator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public boolean isValid(Kind kind, QName name) {

        // just let all "xml:" QNames through
        if (name.getNamespaceURI().equals(Constants.NS_XML))
            return true;

        if (kind == SchemaKinds.XSD_TYPE) {
            return _validTypes.contains(name);
        } else if (kind == SchemaKinds.XSD_ELEMENT) {
            return _validElements.contains(name);
        } else if (kind == SchemaKinds.XSD_ATTRIBUTE) {
            return _validAttributes.contains(name);
        } else {
            // no luck
            return false;
        }
    }
 
Example 6
Source File: WSDLModelerBase.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * For Document/Lit the wsdl:part should only have element attribute and
 * for RPC/Lit or RPC/Encoded the wsdl:part should only have type attribute
 * inside wsdl:message.
 */
protected boolean isStyleAndPartMatch(
    SOAPOperation soapOperation,
    MessagePart part) {

    // style attribute on soap:operation takes precedence over the
    // style attribute on soap:binding

    if ((soapOperation != null) && (soapOperation.getStyle() != null)) {
        if ((soapOperation.isDocument()
            && (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT))
            || (soapOperation.isRPC()
                && (part.getDescriptorKind() != SchemaKinds.XSD_TYPE))) {
            return false;
        }
    } else {
        if ((info.soapBinding.isDocument()
            && (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT))
            || (info.soapBinding.isRPC()
                && (part.getDescriptorKind() != SchemaKinds.XSD_TYPE))) {
            return false;
        }
    }

    return true;
}
 
Example 7
Source File: SOAPEntityReferenceValidator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public boolean isValid(Kind kind, QName name) {

        // just let all "xml:" QNames through
        if (name.getNamespaceURI().equals(Constants.NS_XML))
            return true;

        if (kind == SchemaKinds.XSD_TYPE) {
            return _validTypes.contains(name);
        } else if (kind == SchemaKinds.XSD_ELEMENT) {
            return _validElements.contains(name);
        } else if (kind == SchemaKinds.XSD_ATTRIBUTE) {
            return _validAttributes.contains(name);
        } else {
            // no luck
            return false;
        }
    }
 
Example 8
Source File: WSDLModelerBase.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * For Document/Lit the wsdl:part should only have element attribute and
 * for RPC/Lit or RPC/Encoded the wsdl:part should only have type attribute
 * inside wsdl:message.
 */
protected boolean isStyleAndPartMatch(
    SOAPOperation soapOperation,
    MessagePart part) {

    // style attribute on soap:operation takes precedence over the
    // style attribute on soap:binding

    if ((soapOperation != null) && (soapOperation.getStyle() != null)) {
        if ((soapOperation.isDocument()
            && (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT))
            || (soapOperation.isRPC()
                && (part.getDescriptorKind() != SchemaKinds.XSD_TYPE))) {
            return false;
        }
    } else {
        if ((info.soapBinding.isDocument()
            && (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT))
            || (info.soapBinding.isRPC()
                && (part.getDescriptorKind() != SchemaKinds.XSD_TYPE))) {
            return false;
        }
    }

    return true;
}
 
Example 9
Source File: WSDLModelerBase.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * For Document/Lit the wsdl:part should only have element attribute and
 * for RPC/Lit or RPC/Encoded the wsdl:part should only have type attribute
 * inside wsdl:message.
 */
protected boolean isStyleAndPartMatch(
    SOAPOperation soapOperation,
    MessagePart part) {

    // style attribute on soap:operation takes precedence over the
    // style attribute on soap:binding

    if ((soapOperation != null) && (soapOperation.getStyle() != null)) {
        if ((soapOperation.isDocument()
            && (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT))
            || (soapOperation.isRPC()
                && (part.getDescriptorKind() != SchemaKinds.XSD_TYPE))) {
            return false;
        }
    } else {
        if ((info.soapBinding.isDocument()
            && (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT))
            || (info.soapBinding.isRPC()
                && (part.getDescriptorKind() != SchemaKinds.XSD_TYPE))) {
            return false;
        }
    }

    return true;
}
 
Example 10
Source File: WSDLModeler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private List<MessagePart> getHeaderParts(BindingOperation bindingOperation, boolean isInput) {
    TWSDLExtensible ext;
    if (isInput) {
        ext = bindingOperation.getInput();
    } else {
        ext = bindingOperation.getOutput();
    }

    List<MessagePart> parts = new ArrayList<MessagePart>();
    Iterator<SOAPHeader> headers = getHeaderExtensions(ext).iterator();
    while (headers.hasNext()) {
        SOAPHeader header = headers.next();
        if (!header.isLiteral()) {
            error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_NOT_LITERAL(header.getPart(), bindingOperation.getName()));
        }

        if (header.getNamespace() != null) {
            warning(header, ModelerMessages.WSDLMODELER_WARNING_R_2716_R_2726("soapbind:header", bindingOperation.getName()));
        }
        com.sun.tools.internal.ws.wsdl.document.Message headerMessage = findMessage(header.getMessage(),document);
        if (headerMessage == null) {
            error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_CANT_RESOLVE_MESSAGE(header.getMessage(), bindingOperation.getName()));
        }

        MessagePart part = headerMessage.getPart(header.getPart());
        if (part == null) {
            error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_NOT_FOUND(header.getPart(), bindingOperation.getName()));
        }
        if (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT) {
            if (options.isExtensionMode()) {
                warning(part, ModelerMessages.WSDLMODELER_INVALID_HEADER_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(part.getName(), bindingOperation.getName()));
            } else {
                error(part, ModelerMessages.WSDLMODELER_INVALID_HEADER_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(part.getName(), bindingOperation.getName()));
            }
        }
        part.setBindingExtensibilityElementKind(MessagePart.SOAP_HEADER_BINDING);
        parts.add(part);
    }
    return parts;
}
 
Example 11
Source File: WSDLModeler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private List<MessagePart> getHeaderParts(BindingOperation bindingOperation, boolean isInput) {
    TWSDLExtensible ext;
    if (isInput) {
        ext = bindingOperation.getInput();
    } else {
        ext = bindingOperation.getOutput();
    }

    List<MessagePart> parts = new ArrayList<MessagePart>();
    Iterator<SOAPHeader> headers = getHeaderExtensions(ext).iterator();
    while (headers.hasNext()) {
        SOAPHeader header = headers.next();
        if (!header.isLiteral()) {
            error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_NOT_LITERAL(header.getPart(), bindingOperation.getName()));
        }

        if (header.getNamespace() != null) {
            warning(header, ModelerMessages.WSDLMODELER_WARNING_R_2716_R_2726("soapbind:header", bindingOperation.getName()));
        }
        com.sun.tools.internal.ws.wsdl.document.Message headerMessage = findMessage(header.getMessage(),document);
        if (headerMessage == null) {
            error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_CANT_RESOLVE_MESSAGE(header.getMessage(), bindingOperation.getName()));
        }

        MessagePart part = headerMessage.getPart(header.getPart());
        if (part == null) {
            error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_NOT_FOUND(header.getPart(), bindingOperation.getName()));
        }
        if (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT) {
            if (options.isExtensionMode()) {
                warning(part, ModelerMessages.WSDLMODELER_INVALID_HEADER_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(part.getName(), bindingOperation.getName()));
            } else {
                error(part, ModelerMessages.WSDLMODELER_INVALID_HEADER_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(part.getName(), bindingOperation.getName()));
            }
        }
        part.setBindingExtensibilityElementKind(MessagePart.SOAP_HEADER_BINDING);
        parts.add(part);
    }
    return parts;
}
 
Example 12
Source File: WSDLModeler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private List<MessagePart> getHeaderParts(BindingOperation bindingOperation, boolean isInput) {
    TWSDLExtensible ext;
    if (isInput) {
        ext = bindingOperation.getInput();
    } else {
        ext = bindingOperation.getOutput();
    }

    List<MessagePart> parts = new ArrayList<MessagePart>();
    Iterator<SOAPHeader> headers = getHeaderExtensions(ext).iterator();
    while (headers.hasNext()) {
        SOAPHeader header = headers.next();
        if (!header.isLiteral()) {
            error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_NOT_LITERAL(header.getPart(), bindingOperation.getName()));
        }

        if (header.getNamespace() != null) {
            warning(header, ModelerMessages.WSDLMODELER_WARNING_R_2716_R_2726("soapbind:header", bindingOperation.getName()));
        }
        com.sun.tools.internal.ws.wsdl.document.Message headerMessage = findMessage(header.getMessage(),document);
        if (headerMessage == null) {
            error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_CANT_RESOLVE_MESSAGE(header.getMessage(), bindingOperation.getName()));
        }

        MessagePart part = headerMessage.getPart(header.getPart());
        if (part == null) {
            error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_NOT_FOUND(header.getPart(), bindingOperation.getName()));
        }
        if (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT) {
            if (options.isExtensionMode()) {
                warning(part, ModelerMessages.WSDLMODELER_INVALID_HEADER_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(part.getName(), bindingOperation.getName()));
            } else {
                error(part, ModelerMessages.WSDLMODELER_INVALID_HEADER_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(part.getName(), bindingOperation.getName()));
            }
        }
        part.setBindingExtensibilityElementKind(MessagePart.SOAP_HEADER_BINDING);
        parts.add(part);
    }
    return parts;
}
 
Example 13
Source File: WSDLModeler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private List<MessagePart> getHeaderParts(BindingOperation bindingOperation, boolean isInput) {
    TWSDLExtensible ext;
    if (isInput) {
        ext = bindingOperation.getInput();
    } else {
        ext = bindingOperation.getOutput();
    }

    List<MessagePart> parts = new ArrayList<MessagePart>();
    Iterator<SOAPHeader> headers = getHeaderExtensions(ext).iterator();
    while (headers.hasNext()) {
        SOAPHeader header = headers.next();
        if (!header.isLiteral()) {
            error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_NOT_LITERAL(header.getPart(), bindingOperation.getName()));
        }

        if (header.getNamespace() != null) {
            warning(header, ModelerMessages.WSDLMODELER_WARNING_R_2716_R_2726("soapbind:header", bindingOperation.getName()));
        }
        com.sun.tools.internal.ws.wsdl.document.Message headerMessage = findMessage(header.getMessage(),document);
        if (headerMessage == null) {
            error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_CANT_RESOLVE_MESSAGE(header.getMessage(), bindingOperation.getName()));
        }

        MessagePart part = headerMessage.getPart(header.getPart());
        if (part == null) {
            error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_NOT_FOUND(header.getPart(), bindingOperation.getName()));
        }
        if (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT) {
            if (options.isExtensionMode()) {
                warning(part, ModelerMessages.WSDLMODELER_INVALID_HEADER_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(part.getName(), bindingOperation.getName()));
            } else {
                error(part, ModelerMessages.WSDLMODELER_INVALID_HEADER_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(part.getName(), bindingOperation.getName()));
            }
        }
        part.setBindingExtensibilityElementKind(MessagePart.SOAP_HEADER_BINDING);
        parts.add(part);
    }
    return parts;
}
 
Example 14
Source File: WSDLModeler.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected boolean isUnwrappable() {
    if (!getWrapperStyleCustomization()) {
        return false;
    }

    com.sun.tools.internal.ws.wsdl.document.Message inputMessage = getInputMessage();
    com.sun.tools.internal.ws.wsdl.document.Message outputMessage = getOutputMessage();

    // Wrapper style if the operation's input and output messages each contain
    // only a single part
    if ((inputMessage != null && inputMessage.numParts() != 1)
            || (outputMessage != null && outputMessage.numParts() != 1)) {
        return false;
    }

    MessagePart inputPart = inputMessage != null
            ? inputMessage.parts().next() : null;
    MessagePart outputPart = outputMessage != null
            ? outputMessage.parts().next() : null;
    String operationName = info.portTypeOperation.getName();

    // Wrapper style if the input message part refers to a global element declaration whose localname
    // is equal to the operation name
    // Wrapper style if the output message part refers to a global element declaration
    if ((inputPart != null && !inputPart.getDescriptor().getLocalPart().equals(operationName)) ||
            (outputPart != null && outputPart.getDescriptorKind() != SchemaKinds.XSD_ELEMENT)) {
        return false;
    }

    //check to see if either input or output message part not bound to soapbing:body
    //in that case the operation is not wrapper style
    if (((inputPart != null) && (inputPart.getBindingExtensibilityElementKind() != MessagePart.SOAP_BODY_BINDING)) ||
            ((outputPart != null) && (outputPart.getBindingExtensibilityElementKind() != MessagePart.SOAP_BODY_BINDING))) {
        return false;
    }

    // Wrapper style if the elements referred to by the input and output message parts
    // (henceforth referred to as wrapper elements) are both complex types defined
    // using the xsd:sequence compositor
    // Wrapper style if the wrapper elements only contain child elements, they must not
    // contain other structures such as xsd:choice, substitution groups1 or attributes
    //These checkins are done by jaxb, we just check if jaxb has wrapper children. If there
    // are then its wrapper style
    //if(inputPart != null && outputPart != null){
    if (inputPart != null) {
        boolean inputWrappable = false;
        JAXBType inputType = getJAXBType(inputPart);
        if (inputType != null) {
            inputWrappable = inputType.isUnwrappable();
        }
        //if there are no output part (oneway), the operation can still be wrapper style
        if (outputPart == null) {
            return inputWrappable;
        }
        JAXBType outputType = getJAXBType(outputPart);
        if ((inputType != null) && (outputType != null)) {
            return inputType.isUnwrappable() && outputType.isUnwrappable();
        }
    }

    return false;
}
 
Example 15
Source File: PseudoSchemaBuilder.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private void build(QName elementName, List<MessagePart> allParts){

        print(
                "<xs:schema xmlns:xs=''http://www.w3.org/2001/XMLSchema''" +
                "           xmlns:jaxb=''http://java.sun.com/xml/ns/jaxb''" +
                "           xmlns:xjc=''http://java.sun.com/xml/ns/jaxb/xjc''" +
                "           jaxb:extensionBindingPrefixes=''xjc''" +
                "           jaxb:version=''1.0''" +
                "           targetNamespace=''{0}''>",
                elementName.getNamespaceURI());

        writeImports(elementName, allParts);

        if(!asyncRespBeanBinding){
            print(
                    "<xs:annotation><xs:appinfo>" +
                    "  <jaxb:schemaBindings>" +
                    "    <jaxb:package name=''{0}'' />" +
                    "  </jaxb:schemaBindings>" +
                    "</xs:appinfo></xs:annotation>",
                    wsdlModeler.getJavaPackage() );
            asyncRespBeanBinding = true;
        }

        print("<xs:element name=''{0}''>", elementName.getLocalPart());
        print("<xs:complexType>");
        print("<xs:sequence>");


        for(MessagePart p:allParts) {
            //rpclit wsdl:part must reference schema type not element, also it must exclude headers and mime parts
            if(p.getDescriptorKind() == SchemaKinds.XSD_ELEMENT){
                print("<xs:element ref=''types:{0}'' xmlns:types=''{1}''/>",p.getDescriptor().getLocalPart(), p.getDescriptor().getNamespaceURI());
            }else{
                print("<xs:element name=''{0}'' type=''{1}'' xmlns=''{2}'' />",
                    p.getName(),
                    p.getDescriptor().getLocalPart(),
                    p.getDescriptor().getNamespaceURI() );
            }
        }

        print("</xs:sequence>");
        print("</xs:complexType>");
        print("</xs:element>");
        print("</xs:schema>");

        // reset the StringWriter, so that next operation element could be written
        if(buf.toString().length() > 0){
            //System.out.println("Response bean Schema for operation========> "+ elementName+"\n\n"+buf);
            InputSource is = new InputSource(new StringReader(buf.toString()));
            schemas.add(is);
            buf.getBuffer().setLength(0);
        }
    }
 
Example 16
Source File: PseudoSchemaBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void build(QName elementName, List<MessagePart> allParts){

        print(
                "<xs:schema xmlns:xs=''http://www.w3.org/2001/XMLSchema''" +
                "           xmlns:jaxb=''http://java.sun.com/xml/ns/jaxb''" +
                "           xmlns:xjc=''http://java.sun.com/xml/ns/jaxb/xjc''" +
                "           jaxb:extensionBindingPrefixes=''xjc''" +
                "           jaxb:version=''1.0''" +
                "           targetNamespace=''{0}''>",
                elementName.getNamespaceURI());

        writeImports(elementName, allParts);

        if(!asyncRespBeanBinding){
            print(
                    "<xs:annotation><xs:appinfo>" +
                    "  <jaxb:schemaBindings>" +
                    "    <jaxb:package name=''{0}'' />" +
                    "  </jaxb:schemaBindings>" +
                    "</xs:appinfo></xs:annotation>",
                    wsdlModeler.getJavaPackage() );
            asyncRespBeanBinding = true;
        }

        print("<xs:element name=''{0}''>", elementName.getLocalPart());
        print("<xs:complexType>");
        print("<xs:sequence>");


        for(MessagePart p:allParts) {
            //rpclit wsdl:part must reference schema type not element, also it must exclude headers and mime parts
            if(p.getDescriptorKind() == SchemaKinds.XSD_ELEMENT){
                print("<xs:element ref=''types:{0}'' xmlns:types=''{1}''/>",p.getDescriptor().getLocalPart(), p.getDescriptor().getNamespaceURI());
            }else{
                print("<xs:element name=''{0}'' type=''{1}'' xmlns=''{2}'' />",
                    p.getName(),
                    p.getDescriptor().getLocalPart(),
                    p.getDescriptor().getNamespaceURI() );
            }
        }

        print("</xs:sequence>");
        print("</xs:complexType>");
        print("</xs:element>");
        print("</xs:schema>");

        // reset the StringWriter, so that next operation element could be written
        if(buf.toString().length() > 0){
            //System.out.println("Response bean Schema for operation========> "+ elementName+"\n\n"+buf);
            InputSource is = new InputSource(new StringReader(buf.toString()));
            schemas.add(is);
            buf.getBuffer().setLength(0);
        }
    }
 
Example 17
Source File: WSDLModeler.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected boolean isUnwrappable() {
    if (!getWrapperStyleCustomization()) {
        return false;
    }

    com.sun.tools.internal.ws.wsdl.document.Message inputMessage = getInputMessage();
    com.sun.tools.internal.ws.wsdl.document.Message outputMessage = getOutputMessage();

    // Wrapper style if the operation's input and output messages each contain
    // only a single part
    if ((inputMessage != null && inputMessage.numParts() != 1)
            || (outputMessage != null && outputMessage.numParts() != 1)) {
        return false;
    }

    MessagePart inputPart = inputMessage != null
            ? inputMessage.parts().next() : null;
    MessagePart outputPart = outputMessage != null
            ? outputMessage.parts().next() : null;
    String operationName = info.portTypeOperation.getName();

    // Wrapper style if the input message part refers to a global element declaration whose localname
    // is equal to the operation name
    // Wrapper style if the output message part refers to a global element declaration
    if ((inputPart != null && !inputPart.getDescriptor().getLocalPart().equals(operationName)) ||
            (outputPart != null && outputPart.getDescriptorKind() != SchemaKinds.XSD_ELEMENT)) {
        return false;
    }

    //check to see if either input or output message part not bound to soapbing:body
    //in that case the operation is not wrapper style
    if (((inputPart != null) && (inputPart.getBindingExtensibilityElementKind() != MessagePart.SOAP_BODY_BINDING)) ||
            ((outputPart != null) && (outputPart.getBindingExtensibilityElementKind() != MessagePart.SOAP_BODY_BINDING))) {
        return false;
    }

    // Wrapper style if the elements referred to by the input and output message parts
    // (henceforth referred to as wrapper elements) are both complex types defined
    // using the xsd:sequence compositor
    // Wrapper style if the wrapper elements only contain child elements, they must not
    // contain other structures such as xsd:choice, substitution groups1 or attributes
    //These checkins are done by jaxb, we just check if jaxb has wrapper children. If there
    // are then its wrapper style
    //if(inputPart != null && outputPart != null){
    if (inputPart != null) {
        boolean inputWrappable = false;
        JAXBType inputType = getJAXBType(inputPart);
        if (inputType != null) {
            inputWrappable = inputType.isUnwrappable();
        }
        //if there are no output part (oneway), the operation can still be wrapper style
        if (outputPart == null) {
            return inputWrappable;
        }
        JAXBType outputType = getJAXBType(outputPart);
        if ((inputType != null) && (outputType != null)) {
            return inputType.isUnwrappable() && outputType.isUnwrappable();
        }
    }

    return false;
}
 
Example 18
Source File: PseudoSchemaBuilder.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private void build(QName elementName, List<MessagePart> allParts){

        print(
                "<xs:schema xmlns:xs=''http://www.w3.org/2001/XMLSchema''" +
                "           xmlns:jaxb=''http://java.sun.com/xml/ns/jaxb''" +
                "           xmlns:xjc=''http://java.sun.com/xml/ns/jaxb/xjc''" +
                "           jaxb:extensionBindingPrefixes=''xjc''" +
                "           jaxb:version=''1.0''" +
                "           targetNamespace=''{0}''>",
                elementName.getNamespaceURI());

        writeImports(elementName, allParts);

        if(!asyncRespBeanBinding){
            print(
                    "<xs:annotation><xs:appinfo>" +
                    "  <jaxb:schemaBindings>" +
                    "    <jaxb:package name=''{0}'' />" +
                    "  </jaxb:schemaBindings>" +
                    "</xs:appinfo></xs:annotation>",
                    wsdlModeler.getJavaPackage() );
            asyncRespBeanBinding = true;
        }

        print("<xs:element name=''{0}''>", elementName.getLocalPart());
        print("<xs:complexType>");
        print("<xs:sequence>");


        for(MessagePart p:allParts) {
            //rpclit wsdl:part must reference schema type not element, also it must exclude headers and mime parts
            if(p.getDescriptorKind() == SchemaKinds.XSD_ELEMENT){
                print("<xs:element ref=''types:{0}'' xmlns:types=''{1}''/>",p.getDescriptor().getLocalPart(), p.getDescriptor().getNamespaceURI());
            }else{
                print("<xs:element name=''{0}'' type=''{1}'' xmlns=''{2}'' />",
                    p.getName(),
                    p.getDescriptor().getLocalPart(),
                    p.getDescriptor().getNamespaceURI() );
            }
        }

        print("</xs:sequence>");
        print("</xs:complexType>");
        print("</xs:element>");
        print("</xs:schema>");

        // reset the StringWriter, so that next operation element could be written
        if(buf.toString().length() > 0){
            //System.out.println("Response bean Schema for operation========> "+ elementName+"\n\n"+buf);
            InputSource is = new InputSource(new StringReader(buf.toString()));
            schemas.add(is);
            buf.getBuffer().setLength(0);
        }
    }
 
Example 19
Source File: WSDLModeler.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected boolean isUnwrappable() {
    if (!getWrapperStyleCustomization()) {
        return false;
    }

    com.sun.tools.internal.ws.wsdl.document.Message inputMessage = getInputMessage();
    com.sun.tools.internal.ws.wsdl.document.Message outputMessage = getOutputMessage();

    // Wrapper style if the operation's input and output messages each contain
    // only a single part
    if ((inputMessage != null && inputMessage.numParts() != 1)
            || (outputMessage != null && outputMessage.numParts() != 1)) {
        return false;
    }

    MessagePart inputPart = inputMessage != null
            ? inputMessage.parts().next() : null;
    MessagePart outputPart = outputMessage != null
            ? outputMessage.parts().next() : null;
    String operationName = info.portTypeOperation.getName();

    // Wrapper style if the input message part refers to a global element declaration whose localname
    // is equal to the operation name
    // Wrapper style if the output message part refers to a global element declaration
    if ((inputPart != null && !inputPart.getDescriptor().getLocalPart().equals(operationName)) ||
            (outputPart != null && outputPart.getDescriptorKind() != SchemaKinds.XSD_ELEMENT)) {
        return false;
    }

    //check to see if either input or output message part not bound to soapbing:body
    //in that case the operation is not wrapper style
    if (((inputPart != null) && (inputPart.getBindingExtensibilityElementKind() != MessagePart.SOAP_BODY_BINDING)) ||
            ((outputPart != null) && (outputPart.getBindingExtensibilityElementKind() != MessagePart.SOAP_BODY_BINDING))) {
        return false;
    }

    // Wrapper style if the elements referred to by the input and output message parts
    // (henceforth referred to as wrapper elements) are both complex types defined
    // using the xsd:sequence compositor
    // Wrapper style if the wrapper elements only contain child elements, they must not
    // contain other structures such as xsd:choice, substitution groups1 or attributes
    //These checkins are done by jaxb, we just check if jaxb has wrapper children. If there
    // are then its wrapper style
    //if(inputPart != null && outputPart != null){
    if (inputPart != null) {
        boolean inputWrappable = false;
        JAXBType inputType = getJAXBType(inputPart);
        if (inputType != null) {
            inputWrappable = inputType.isUnwrappable();
        }
        //if there are no output part (oneway), the operation can still be wrapper style
        if (outputPart == null) {
            return inputWrappable;
        }
        JAXBType outputType = getJAXBType(outputPart);
        if ((inputType != null) && (outputType != null)) {
            return inputType.isUnwrappable() && outputType.isUnwrappable();
        }
    }

    return false;
}
 
Example 20
Source File: WSDLModeler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected boolean isUnwrappable() {
    if (!getWrapperStyleCustomization()) {
        return false;
    }

    com.sun.tools.internal.ws.wsdl.document.Message inputMessage = getInputMessage();
    com.sun.tools.internal.ws.wsdl.document.Message outputMessage = getOutputMessage();

    // Wrapper style if the operation's input and output messages each contain
    // only a single part
    if ((inputMessage != null && inputMessage.numParts() != 1)
            || (outputMessage != null && outputMessage.numParts() != 1)) {
        return false;
    }

    MessagePart inputPart = inputMessage != null
            ? inputMessage.parts().next() : null;
    MessagePart outputPart = outputMessage != null
            ? outputMessage.parts().next() : null;
    String operationName = info.portTypeOperation.getName();

    // Wrapper style if the input message part refers to a global element declaration whose localname
    // is equal to the operation name
    // Wrapper style if the output message part refers to a global element declaration
    if ((inputPart != null && !inputPart.getDescriptor().getLocalPart().equals(operationName)) ||
            (outputPart != null && outputPart.getDescriptorKind() != SchemaKinds.XSD_ELEMENT)) {
        return false;
    }

    //check to see if either input or output message part not bound to soapbing:body
    //in that case the operation is not wrapper style
    if (((inputPart != null) && (inputPart.getBindingExtensibilityElementKind() != MessagePart.SOAP_BODY_BINDING)) ||
            ((outputPart != null) && (outputPart.getBindingExtensibilityElementKind() != MessagePart.SOAP_BODY_BINDING))) {
        return false;
    }

    // Wrapper style if the elements referred to by the input and output message parts
    // (henceforth referred to as wrapper elements) are both complex types defined
    // using the xsd:sequence compositor
    // Wrapper style if the wrapper elements only contain child elements, they must not
    // contain other structures such as xsd:choice, substitution groups1 or attributes
    //These checkins are done by jaxb, we just check if jaxb has wrapper children. If there
    // are then its wrapper style
    //if(inputPart != null && outputPart != null){
    if (inputPart != null) {
        boolean inputWrappable = false;
        JAXBType inputType = getJAXBType(inputPart);
        if (inputType != null) {
            inputWrappable = inputType.isUnwrappable();
        }
        //if there are no output part (oneway), the operation can still be wrapper style
        if (outputPart == null) {
            return inputWrappable;
        }
        JAXBType outputType = getJAXBType(outputPart);
        if ((inputType != null) && (outputType != null)) {
            return inputType.isUnwrappable() && outputType.isUnwrappable();
        }
    }

    return false;
}