Search in sources :

Example 1 with Types

use of com.predic8.wsdl.Types in project service-proxy by membrane.

the class WSDLValidator method getSchemas.

@Override
protected List<Schema> getSchemas() {
    WSDLParserContext ctx = new WSDLParserContext();
    ctx.setInput(location);
    try {
        WSDLParser wsdlParser = new WSDLParser();
        // System.out.println("Resolver----" + resourceResolver);
        wsdlParser.setResourceResolver(resourceResolver.toExternalResolver().toExternalResolver());
        List<Schema> schemaList = new ArrayList<Schema>();
        for (Types t : wsdlParser.parse(ctx).getTypes()) schemaList.addAll(t.getSchemas());
        return schemaList;
    } catch (RuntimeException e) {
        throw new IllegalArgumentException("Could not download the WSDL " + location + " or its dependent XML Schemas.", e);
    }
}
Also used : Types(com.predic8.wsdl.Types) Schema(com.predic8.schema.Schema) ArrayList(java.util.ArrayList) WSDLParser(com.predic8.wsdl.WSDLParser) WSDLParserContext(com.predic8.wsdl.WSDLParserContext)

Example 2 with Types

use of com.predic8.wsdl.Types in project service-proxy by membrane.

the class HelpReference method handle.

/*
	private int getId(String xsdTypeName) {
		if (ids.containsKey(xsdTypeName))
			return ids.get(xsdTypeName);
		int id = Math.abs(xsdTypeName.hashCode());
		if (idsReverse.containsKey(id))
			throw new ProcessingException("ID-assigning algorithm failed (two XSD types got the same ID)");
		ids.put(xsdTypeName, id);
		idsReverse.put(id, xsdTypeName);
		return id;
	}
	 */
private void handle(Model m, MainInfo main, ChildElementInfo cei) throws XMLStreamException {
    xew.writeStartElement("child");
    xew.writeAttribute("min", cei.isRequired() ? "1" : "0");
    xew.writeAttribute("max", cei.isList() ? "unbounded" : "1");
    handleDoc(cei);
    SortedSet<String> possibilities = new TreeSet<String>();
    for (ElementInfo ei : main.getChildElementDeclarations().get(cei.getTypeDeclaration()).getElementInfo()) {
        possibilities.add(ei.getId());
    }
    for (String id : possibilities) {
        xew.writeStartElement("possibility");
        xew.writeAttribute("refId", id);
        xew.writeEndElement();
    }
    if (cei.getAnnotation().allowForeign()) {
        xew.writeStartElement("possibility");
        xew.writeAttribute("foreign", "true");
        xew.writeEndElement();
    }
    xew.writeEndElement();
}
Also used : ElementInfo(com.predic8.membrane.annot.model.ElementInfo) ChildElementInfo(com.predic8.membrane.annot.model.ChildElementInfo) TreeSet(java.util.TreeSet)

Example 3 with Types

use of com.predic8.wsdl.Types in project service-proxy by membrane.

the class AttributeInfo method analyze.

private void analyze(Types typeUtils) {
    if (// already analyzed?
    xsdType != null)
        return;
    if (getE().getParameters().size() != 1)
        throw new ProcessingException("Setter is supposed to have 1 parameter.", getE());
    VariableElement ve = getE().getParameters().get(0);
    switch(ve.asType().getKind()) {
        case INT:
            xsdType = "spel_number";
            return;
        case LONG:
            xsdType = "spel_number";
            return;
        case BOOLEAN:
            xsdType = "spel_boolean";
            return;
        case DECLARED:
            TypeElement e = (TypeElement) typeUtils.asElement(ve.asType());
            if (e.getQualifiedName().toString().equals("java.lang.String")) {
                xsdType = "xsd:string";
                return;
            }
            if (e.getSuperclass().getKind() == TypeKind.DECLARED) {
                TypeElement superClass = ((TypeElement) typeUtils.asElement(e.getSuperclass()));
                if (superClass.getQualifiedName().toString().equals("java.lang.Enum")) {
                    isEnum = true;
                    // TODO: restriction, but be carefull about Spring EL usage, for example "#{config.XXX}"
                    xsdType = "xsd:string";
                    /*
					 *	<xsd:attribute name=\"target\" use=\"optional\" default=\"body\">\r\n" +
					 *		<xsd:simpleType>\r\n" +
					 *			<xsd:restriction base=\"xsd:string\">\r\n" +
					 *				<xsd:enumeration value=\"body\" />\r\n" +
					 *				<xsd:enumeration value=\"header\" />\r\n" +
					 *			</xsd:restriction>\r\n" +
					 *		</xsd:simpleType>\r\n" +
					 *	</xsd:attribute>\r\n"
					 */
                    return;
                }
            }
            isBeanReference = true;
            xsdType = "xsd:string";
            return;
        default:
            throw new ProcessingException("Not implemented: XSD type for " + ve.asType().getKind().toString(), this.getE());
    }
}
Also used : TypeElement(javax.lang.model.element.TypeElement) VariableElement(javax.lang.model.element.VariableElement) ProcessingException(com.predic8.membrane.annot.ProcessingException)

Aggregations

ProcessingException (com.predic8.membrane.annot.ProcessingException)1 ChildElementInfo (com.predic8.membrane.annot.model.ChildElementInfo)1 ElementInfo (com.predic8.membrane.annot.model.ElementInfo)1 Schema (com.predic8.schema.Schema)1 Types (com.predic8.wsdl.Types)1 WSDLParser (com.predic8.wsdl.WSDLParser)1 WSDLParserContext (com.predic8.wsdl.WSDLParserContext)1 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 TypeElement (javax.lang.model.element.TypeElement)1 VariableElement (javax.lang.model.element.VariableElement)1