Search in sources :

Example 66 with XmlSchemaElement

use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.

the class AttributeVisitor method generateSetter.

private void generateSetter(AST typeNode, AST nameNode) {
    // generate wrapped doc element in parameter
    XmlSchemaElement inParameters = generateWrappedDocElement(typeNode, SETTER_PREFIX + nameNode.toString(), PARAM_NAME);
    // generate wrapped doc element out parameter
    XmlSchemaElement outParameters = generateWrappedDocElement(null, SETTER_PREFIX + nameNode.toString() + RESULT_POSTFIX, RETURN_PARAM_NAME);
    // generate input message
    Message inMsg = generateMessage(inParameters, SETTER_PREFIX + nameNode.toString());
    // generate output message
    Message outMsg = generateMessage(outParameters, SETTER_PREFIX + nameNode.toString() + RESPONSE_POSTFIX);
    // generate operation
    String name = SETTER_PREFIX + nameNode.toString();
    Operation op = generateOperation(name, inMsg, outMsg);
    // generate corba return param
    ParamType corbaParam = generateCorbaParam(typeNode);
    // generate corba operation
    OperationType corbaOp = generateCorbaOperation(op, corbaParam, null);
    // generate binding
    generateCorbaBindingOperation(binding, op, corbaOp);
}
Also used : Message(javax.wsdl.Message) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Example 67 with XmlSchemaElement

use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.

the class AttributeVisitor method generateGetter.

private void generateGetter(AST typeNode, AST nameNode) {
    // generate wrapped doc element in parameter
    XmlSchemaElement inParameters = generateWrappedDocElement(null, GETTER_PREFIX + nameNode.toString(), PARAM_NAME);
    // generate wrapped doc element out parameter
    XmlSchemaElement outParameters = generateWrappedDocElement(typeNode, GETTER_PREFIX + nameNode.toString() + RESULT_POSTFIX, RETURN_PARAM_NAME);
    // generate input message
    Message inMsg = generateMessage(inParameters, GETTER_PREFIX + nameNode.toString());
    // generate output message
    Message outMsg = generateMessage(outParameters, GETTER_PREFIX + nameNode.toString() + RESPONSE_POSTFIX);
    // generate operation
    String name = GETTER_PREFIX + nameNode.toString();
    Operation op = generateOperation(name, inMsg, outMsg);
    // generate corba return param
    ArgType corbaReturn = generateCorbaReturnParam(typeNode);
    // generate corba operation
    OperationType corbaOp = generateCorbaOperation(op, null, corbaReturn);
    // generate binding
    generateCorbaBindingOperation(binding, op, corbaOp);
}
Also used : ArgType(org.apache.cxf.binding.corba.wsdl.ArgType) Message(javax.wsdl.Message) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType)

Example 68 with XmlSchemaElement

use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.

the class ParamDclVisitor method addElement.

private XmlSchemaElement addElement(XmlSchemaSequence schemaSequence, XmlSchemaType schemaType, String name, Scope fullyQualifiedName) {
    XmlSchemaElement element = new XmlSchemaElement(schema, false);
    element.setName(name);
    if (schemaType == null) {
        ParamDeferredAction elementAction;
        if (mapper.isDefaultMapping()) {
            elementAction = new ParamDeferredAction(element);
        } else {
            elementAction = new ParamDeferredAction(element, fullyQualifiedName.getParent(), schema, schemas, manager, mapper);
        }
        wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction);
    // ParamDeferredAction elementAction =
    // new ParamDeferredAction(element);
    // wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction);
    } else {
        element.setSchemaTypeName(schemaType.getQName());
        if (schemaType.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
            element.setNillable(true);
        }
    }
    schemaSequence.getItems().add(element);
    return element;
}
Also used : XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement)

Example 69 with XmlSchemaElement

use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.

the class WSDLServiceBuilder method checkForWrapped.

public static void checkForWrapped(OperationInfo opInfo, boolean allowRefs, boolean relaxed, Level logLevel) {
    MessageInfo inputMessage = opInfo.getInput();
    MessageInfo outputMessage = opInfo.getOutput();
    boolean passedRule = true;
    // input message must exist
    if (inputMessage == null || inputMessage.size() == 0 || (inputMessage.size() > 1 && !relaxed)) {
        passedRule = false;
    }
    if (outputMessage != null && outputMessage.size() > 1) {
        passedRule = false;
    }
    if (!passedRule) {
        org.apache.cxf.common.i18n.Message message = new org.apache.cxf.common.i18n.Message("WRAPPED_RULE_1", LOG, opInfo.getName());
        LOG.log(logLevel, message.toString());
        return;
    }
    SchemaCollection schemas = opInfo.getInterface().getService().getXmlSchemaCollection();
    XmlSchemaElement inputEl = null;
    XmlSchemaElement outputEl = null;
    // RULE No.2:
    // The input message part refers to a global element declaration whose
    // local name is equal to the operation name.
    MessagePartInfo inputPart = inputMessage.getMessagePartByIndex(0);
    if (!inputPart.isElement()) {
        passedRule = false;
    } else {
        QName inputElementName = inputPart.getElementQName();
        inputEl = schemas.getElementByQName(inputElementName);
        if (inputEl == null) {
            passedRule = false;
        } else if (!opInfo.getName().getLocalPart().equals(inputElementName.getLocalPart())) {
            passedRule = relaxed;
        }
    }
    if (!passedRule) {
        org.apache.cxf.common.i18n.Message message = new org.apache.cxf.common.i18n.Message("WRAPPED_RULE_2", LOG, opInfo.getName());
        LOG.log(logLevel, message.toString());
        return;
    }
    // The output message part refers to a global element declaration
    if (outputMessage != null && outputMessage.size() == 1) {
        final MessagePartInfo outputPart = outputMessage.getMessagePartByIndex(0);
        if (outputPart != null) {
            if (!outputPart.isElement() || schemas.getElementByQName(outputPart.getElementQName()) == null) {
                passedRule = false;
            } else {
                outputEl = schemas.getElementByQName(outputPart.getElementQName());
            }
        }
    }
    if (!passedRule) {
        org.apache.cxf.common.i18n.Message message = new org.apache.cxf.common.i18n.Message("WRAPPED_RULE_3", LOG, opInfo.getName());
        LOG.log(logLevel, message.toString());
        return;
    }
    // RULE No.4 and No5:
    // wrapper element should be pure complex type
    // Now lets see if we have any attributes...
    // This should probably look at the restricted and substitute types too.
    OperationInfo unwrapped = new UnwrappedOperationInfo(opInfo);
    MessageInfo unwrappedInput = new MessageInfo(unwrapped, MessageInfo.Type.INPUT, inputMessage.getName());
    MessageInfo unwrappedOutput = null;
    XmlSchemaComplexType xsct;
    if (inputEl.getSchemaType() instanceof XmlSchemaComplexType) {
        xsct = (XmlSchemaComplexType) inputEl.getSchemaType();
        if (hasAttributes(xsct) || (inputEl.isNillable() && !relaxed) || !isWrappableSequence(xsct, inputEl.getQName().getNamespaceURI(), unwrappedInput, allowRefs)) {
            passedRule = false;
        }
    } else {
        passedRule = false;
    }
    if (!passedRule) {
        org.apache.cxf.common.i18n.Message message = new org.apache.cxf.common.i18n.Message("WRAPPED_RULE_4", LOG, opInfo.getName());
        LOG.log(logLevel, message.toString());
        return;
    }
    if (outputMessage != null) {
        unwrappedOutput = new MessageInfo(unwrapped, MessageInfo.Type.OUTPUT, outputMessage.getName());
        if (outputEl != null && outputEl.getSchemaType() instanceof XmlSchemaComplexType) {
            xsct = (XmlSchemaComplexType) outputEl.getSchemaType();
            if (xsct.isAbstract()) {
                passedRule = false;
            }
            if (hasAttributes(xsct) || (outputEl.isNillable() && !relaxed) || !isWrappableSequence(xsct, outputEl.getQName().getNamespaceURI(), unwrappedOutput, allowRefs)) {
                passedRule = false;
            }
        } else {
            passedRule = false;
        }
    }
    if (!passedRule) {
        org.apache.cxf.common.i18n.Message message = new org.apache.cxf.common.i18n.Message("WRAPPED_RULE_5", LOG, opInfo.getName());
        LOG.log(logLevel, message.toString());
        return;
    }
    // we are wrappable!!
    opInfo.setUnwrappedOperation(unwrapped);
    unwrapped.setInput(opInfo.getInputName(), unwrappedInput);
    if (outputMessage != null) {
        unwrapped.setOutput(opInfo.getOutputName(), unwrappedOutput);
    }
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) UnwrappedOperationInfo(org.apache.cxf.service.model.UnwrappedOperationInfo) Message(javax.wsdl.Message) UnwrappedOperationInfo(org.apache.cxf.service.model.UnwrappedOperationInfo) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) SchemaCollection(org.apache.cxf.common.xmlschema.SchemaCollection)

Example 70 with XmlSchemaElement

use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.

the class WSDLServiceBuilderTest method testOperationInfo.

@Test
public void testOperationInfo() throws Exception {
    setUpBasic();
    QName name = new QName(serviceInfo.getName().getNamespaceURI(), "sayHi");
    assertEquals(4, serviceInfo.getInterface().getOperations().size());
    OperationInfo sayHi = serviceInfo.getInterface().getOperation(new QName(serviceInfo.getName().getNamespaceURI(), "sayHi"));
    assertNotNull(sayHi);
    assertEquals(sayHi.getName(), name);
    assertFalse(sayHi.isOneWay());
    assertTrue(sayHi.hasInput());
    assertTrue(sayHi.hasOutput());
    assertNull(sayHi.getParameterOrdering());
    name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMe");
    OperationInfo greetMe = serviceInfo.getInterface().getOperation(name);
    assertNotNull(greetMe);
    assertEquals(greetMe.getName(), name);
    assertFalse(greetMe.isOneWay());
    assertTrue(greetMe.hasInput());
    assertTrue(greetMe.hasOutput());
    List<MessagePartInfo> inParts = greetMe.getInput().getMessageParts();
    assertEquals(1, inParts.size());
    MessagePartInfo part = inParts.get(0);
    assertNotNull(part.getXmlSchema());
    assertTrue(part.getXmlSchema() instanceof XmlSchemaElement);
    List<MessagePartInfo> outParts = greetMe.getOutput().getMessageParts();
    assertEquals(1, outParts.size());
    part = outParts.get(0);
    assertNotNull(part.getXmlSchema());
    assertTrue(part.getXmlSchema() instanceof XmlSchemaElement);
    assertTrue("greatMe should be wrapped", greetMe.isUnwrappedCapable());
    OperationInfo greetMeUnwrapped = greetMe.getUnwrappedOperation();
    assertNotNull(greetMeUnwrapped.getInput());
    assertNotNull(greetMeUnwrapped.getOutput());
    assertEquals("wrapped part not set", 1, greetMeUnwrapped.getInput().size());
    assertEquals("wrapped part not set", 1, greetMeUnwrapped.getOutput().size());
    assertEquals("wrapper part name wrong", "requestType", greetMeUnwrapped.getInput().getMessagePartByIndex(0).getName().getLocalPart());
    assertEquals("wrapper part type name wrong", "MyStringType", greetMeUnwrapped.getInput().getMessagePartByIndex(0).getTypeQName().getLocalPart());
    assertEquals("wrapper part name wrong", "responseType", greetMeUnwrapped.getOutput().getMessagePartByIndex(0).getName().getLocalPart());
    assertEquals("wrapper part type name wrong", "string", greetMeUnwrapped.getOutput().getMessagePartByIndex(0).getTypeQName().getLocalPart());
    name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMeOneWay");
    OperationInfo greetMeOneWay = serviceInfo.getInterface().getOperation(name);
    assertNotNull(greetMeOneWay);
    assertEquals(greetMeOneWay.getName(), name);
    assertTrue(greetMeOneWay.isOneWay());
    assertTrue(greetMeOneWay.hasInput());
    assertFalse(greetMeOneWay.hasOutput());
    OperationInfo greetMeOneWayUnwrapped = greetMeOneWay.getUnwrappedOperation();
    assertNotNull(greetMeOneWayUnwrapped);
    assertNotNull(greetMeOneWayUnwrapped.getInput());
    assertNull(greetMeOneWayUnwrapped.getOutput());
    assertEquals("wrapped part not set", 1, greetMeOneWayUnwrapped.getInput().size());
    assertEquals(new QName("http://apache.org/hello_world_soap_http/types", "requestType"), greetMeOneWayUnwrapped.getInput().getMessagePartByIndex(0).getConcreteName());
    name = new QName(serviceInfo.getName().getNamespaceURI(), "pingMe");
    OperationInfo pingMe = serviceInfo.getInterface().getOperation(name);
    assertNotNull(pingMe);
    assertEquals(pingMe.getName(), name);
    assertFalse(pingMe.isOneWay());
    assertTrue(pingMe.hasInput());
    assertTrue(pingMe.hasOutput());
    assertNull(serviceInfo.getInterface().getOperation(new QName("what ever")));
    control.verify();
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) Test(org.junit.Test)

Aggregations

XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)164 QName (javax.xml.namespace.QName)100 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)59 XmlSchema (org.apache.ws.commons.schema.XmlSchema)54 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)51 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)42 Test (org.junit.Test)42 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)39 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)32 Message (org.apache.cxf.common.i18n.Message)15 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)15 XmlSchemaSequenceMember (org.apache.ws.commons.schema.XmlSchemaSequenceMember)14 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)13 ArrayList (java.util.ArrayList)12 JAXBBeanInfo (org.apache.cxf.common.jaxb.JAXBBeanInfo)12 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)12 Method (java.lang.reflect.Method)11 SchemaInfo (org.apache.cxf.service.model.SchemaInfo)11 XmlSchemaAttribute (org.apache.ws.commons.schema.XmlSchemaAttribute)10 Iterator (java.util.Iterator)9