Search in sources :

Example 41 with MessageInfo

use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.

the class SoapBindingFactory method addOutOfBandParts.

private void addOutOfBandParts(final BindingOperationInfo bop, final javax.wsdl.Message msg, final SchemaCollection schemas, boolean isInput, final String partName) {
    MessageInfo.Type type;
    int nextId = 0;
    MessageInfo minfo = bop.getOperationInfo().getInput();
    if (minfo != null) {
        for (MessagePartInfo part : minfo.getMessageParts()) {
            if (part.getIndex() >= nextId) {
                nextId = part.getIndex() + 1;
            }
        }
    }
    minfo = bop.getOperationInfo().getOutput();
    if (minfo != null) {
        for (MessagePartInfo part : minfo.getMessageParts()) {
            if (part.getIndex() >= nextId) {
                nextId = part.getIndex() + 1;
            }
        }
    }
    if (isInput) {
        type = MessageInfo.Type.INPUT;
        minfo = bop.getOperationInfo().getInput();
    } else {
        type = MessageInfo.Type.OUTPUT;
        minfo = bop.getOperationInfo().getOutput();
    }
    if (minfo == null) {
        minfo = new MessageInfo(bop.getOperationInfo(), type, msg.getQName());
    }
    buildMessage(minfo, msg, schemas, nextId, partName);
    // for wrapped style
    OperationInfo unwrapped = bop.getOperationInfo().getUnwrappedOperation();
    if (unwrapped == null) {
        return;
    }
    nextId = 0;
    if (isInput) {
        minfo = unwrapped.getInput();
        type = MessageInfo.Type.INPUT;
        if (minfo != null) {
            for (MessagePartInfo part : minfo.getMessageParts()) {
                if (part.getIndex() >= nextId) {
                    nextId = part.getIndex() + 1;
                }
            }
        }
    } else {
        minfo = unwrapped.getOutput();
        type = MessageInfo.Type.OUTPUT;
        if (minfo != null) {
            for (MessagePartInfo part : minfo.getMessageParts()) {
                if (part.getIndex() >= nextId) {
                    nextId = part.getIndex() + 1;
                }
            }
        }
    }
    if (minfo == null) {
        minfo = new MessageInfo(unwrapped, type, msg.getQName());
    }
    buildMessage(minfo, msg, schemas, nextId, partName);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo)

Example 42 with MessageInfo

use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.

the class SoapBindingFactory method buildMessage.

private void buildMessage(MessageInfo minfo, javax.wsdl.Message msg, SchemaCollection schemas, int nextId, String partNameFilter) {
    for (Part part : cast(msg.getParts().values(), Part.class)) {
        if (StringUtils.isEmpty(partNameFilter) || part.getName().equals(partNameFilter)) {
            if (StringUtils.isEmpty(part.getName())) {
                throw new RuntimeException("Problem with WSDL: part element in message " + msg.getQName().getLocalPart() + " does not specify a name.");
            }
            QName pqname = new QName(minfo.getName().getNamespaceURI(), part.getName());
            MessagePartInfo pi = minfo.getMessagePart(pqname);
            if (pi != null && pi.getMessageInfo().getName().equals(msg.getQName())) {
                continue;
            }
            pi = minfo.addOutOfBandMessagePart(pqname);
            if (!minfo.getName().equals(msg.getQName())) {
                pi.setMessageContainer(new MessageInfo(minfo.getOperation(), null, msg.getQName()));
            }
            if (part.getTypeName() != null) {
                pi.setTypeQName(part.getTypeName());
                pi.setElement(false);
                pi.setXmlSchema(schemas.getTypeByQName(part.getTypeName()));
            } else {
                pi.setElementQName(part.getElementName());
                pi.setElement(true);
                pi.setXmlSchema(schemas.getElementByQName(part.getElementName()));
            }
            pi.setProperty(OUT_OF_BAND_HEADER, Boolean.TRUE);
            pi.setProperty(HEADER, Boolean.TRUE);
            pi.setIndex(nextId);
            nextId++;
        }
    }
}
Also used : Part(javax.wsdl.Part) MIMEPart(javax.wsdl.extensions.mime.MIMEPart) 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)

Example 43 with MessageInfo

use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.

the class JaxWsServiceConfigurationTest method testGetInPartName.

@Test
public void testGetInPartName() throws Exception {
    QName opName = new QName("http://cxf.com/", "sayHello");
    Method sayHelloMethod = Hello.class.getMethod("sayHello", new Class[] { String.class, String.class });
    ServiceInfo si = getMockedServiceModel("/wsdl/default_partname_test.wsdl");
    JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    bean.setServiceClass(Hello.class);
    JaxWsServiceConfiguration jwsc = (JaxWsServiceConfiguration) bean.getServiceConfigurations().get(0);
    jwsc.setServiceFactory(bean);
    OperationInfo op = si.getInterface().getOperation(opName);
    op.setInput("input", new MessageInfo(op, MessageInfo.Type.INPUT, new QName("http://cxf.com/", "input")));
    op.setOutput("output", new MessageInfo(op, MessageInfo.Type.OUTPUT, new QName("http://cxf.com/", "output")));
    QName partName = jwsc.getInPartName(op, sayHelloMethod, 0);
    assertEquals("get wrong in partName for first param", new QName("http://cxf.com/", "arg0"), partName);
    op.getInput().addMessagePart(new QName("arg0"));
    partName = jwsc.getInPartName(op, sayHelloMethod, 1);
    assertEquals("get wrong in partName for first param", new QName("http://cxf.com/", "arg1"), partName);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) QName(javax.xml.namespace.QName) Method(java.lang.reflect.Method) WebMethod(javax.jws.WebMethod) MessageInfo(org.apache.cxf.service.model.MessageInfo) Test(org.junit.Test)

Example 44 with MessageInfo

use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.

the class ServiceJavascriptBuilder method buildOperationFunction.

private void buildOperationFunction(StringBuilder parameterList) {
    String responseCallbackParams = "";
    if (!currentOperation.isOneWay()) {
        responseCallbackParams = "successCallback, errorCallback";
    }
    MessageInfo inputMessage = currentOperation.getInput();
    code.append("//\n");
    code.append("// Operation ").append(currentOperation.getName()).append('\n');
    if (!isWrapped) {
        code.append("// - bare operation. Parameters:\n");
        for (ParticleInfo ei : unwrappedElementsAndNames) {
            code.append("// - ").append(getElementObjectName(ei)).append('\n');
        }
    } else {
        code.append("// Wrapped operation.\n");
        QName contextQName = inputWrapperComplexType.getQName();
        if (contextQName == null) {
            contextQName = inputWrapperElement.getQName();
        }
        XmlSchemaSequence sequence = JavascriptUtils.getSequence(inputWrapperComplexType);
        XmlSchema wrapperSchema = xmlSchemaCollection.getSchemaByTargetNamespace(contextQName.getNamespaceURI());
        for (int i = 0; i < sequence.getItems().size(); i++) {
            code.append("// parameter ").append(inputParameterNames.get(i)).append('\n');
            XmlSchemaSequenceMember sequenceItem = sequence.getItems().get(i);
            ParticleInfo itemInfo = ParticleInfo.forLocalItem((XmlSchemaObject) sequenceItem, wrapperSchema, xmlSchemaCollection, prefixAccumulator, contextQName);
            if (itemInfo.isArray()) {
                code.append("// - array\n");
            }
            // null for an any.
            XmlSchemaType type = itemInfo.getType();
            if (type instanceof XmlSchemaComplexType) {
                QName baseName;
                if (type.getQName() != null) {
                    baseName = type.getQName();
                } else {
                    baseName = ((XmlSchemaElement) sequenceItem).getQName();
                }
                code.append("// - Object constructor is ").append(nameManager.getJavascriptName(baseName)).append('\n');
            } else if (type != null) {
                code.append("// - simple type ").append(type.getQName());
            }
        }
    }
    code.append("//\n");
    code.append("function " + opFunctionGlobalName + "(" + responseCallbackParams + ((parameterList.length() > 0 && !currentOperation.isOneWay()) ? ", " : "") + parameterList + ") {\n");
    utils.appendLine("this.client = new CxfApacheOrgClient(this.jsutils);");
    utils.appendLine("var xml = null;");
    if (inputMessage != null) {
        utils.appendLine("var args = new Array(" + inputParameterNames.size() + ");");
        int px = 0;
        for (String param : inputParameterNames) {
            utils.appendLine("args[" + px + "] = " + param + ";");
            px++;
        }
        utils.appendLine("xml = this." + getFunctionPropertyName(inputMessagesWithNameConflicts, inputMessage, inputMessage.getName()) + "_serializeInput" + "(this.jsutils, args);");
    }
    // functions.
    if (!currentOperation.isOneWay()) {
        utils.appendLine("this.client.user_onsuccess = successCallback;");
        utils.appendLine("this.client.user_onerror = errorCallback;");
        utils.appendLine("var closureThis = this;");
        // client will pass itself and the response XML.
        utils.appendLine("this.client.onsuccess = function(client, responseXml) { closureThis." + opFunctionPropertyName + "_onsuccess(client, responseXml); };");
        // client will pass itself.
        utils.appendLine("this.client.onerror = function(client) { closureThis." + opFunctionPropertyName + "_onerror(client); };");
    }
    utils.appendLine("var requestHeaders = [];");
    if (soapBindingInfo != null) {
        String action = soapBindingInfo.getSoapAction(currentOperation);
        utils.appendLine("requestHeaders['SOAPAction'] = '" + action + "';");
    }
    // default 'method' by passing null. Is there some place this lives in the
    // service model?
    String syncAsyncFlag;
    if (currentOperation.isOneWay()) {
        utils.appendLine("this.jsutils.trace('oneway operation');");
        syncAsyncFlag = "false";
    } else {
        utils.appendLine("this.jsutils.trace('synchronous = ' + this.synchronous);");
        syncAsyncFlag = "this.synchronous";
    }
    utils.appendLine("this.client.request(this.url, xml, null, " + syncAsyncFlag + ", requestHeaders);");
    code.append("}\n\n");
    code.append(currentInterfaceClassName).append(".prototype.").append(opFunctionPropertyName).append(" = ").append(opFunctionGlobalName).append(";\n\n");
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchema(org.apache.ws.commons.schema.XmlSchema) QName(javax.xml.namespace.QName) ParticleInfo(org.apache.cxf.javascript.ParticleInfo) XmlSchemaSequenceMember(org.apache.ws.commons.schema.XmlSchemaSequenceMember) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Example 45 with MessageInfo

use of org.apache.cxf.service.model.MessageInfo in project cxf by apache.

the class ServiceJavascriptBuilder method begin.

@Override
public void begin(MessageInfo msg) {
    if (isInUnwrappedOperation) {
        return;
    }
    LOG.fine("Message " + msg.getName().toString());
    Map<String, MessageInfo> nameMap;
    Set<MessageInfo> conflicts;
    if (msg.getType() == MessageInfo.Type.INPUT) {
        nameMap = localInputMessagesNameMap;
        conflicts = inputMessagesWithNameConflicts;
    } else {
        nameMap = localOutputMessagesNameMap;
        conflicts = outputMessagesWithNameConflicts;
    }
    MessageInfo conflict = nameMap.get(msg.getName().getLocalPart());
    if (conflict != null) {
        conflicts.add(conflict);
        conflicts.add(msg);
    }
    nameMap.put(msg.getName().getLocalPart(), msg);
}
Also used : MessageInfo(org.apache.cxf.service.model.MessageInfo)

Aggregations

MessageInfo (org.apache.cxf.service.model.MessageInfo)73 QName (javax.xml.namespace.QName)42 OperationInfo (org.apache.cxf.service.model.OperationInfo)42 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)38 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)36 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)19 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)15 Test (org.junit.Test)15 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)14 Endpoint (org.apache.cxf.endpoint.Endpoint)13 Method (java.lang.reflect.Method)11 ArrayList (java.util.ArrayList)10 Service (org.apache.cxf.service.Service)9 MessageContentsList (org.apache.cxf.message.MessageContentsList)8 Fault (org.apache.cxf.interceptor.Fault)7 Exchange (org.apache.cxf.message.Exchange)7 Message (org.apache.cxf.message.Message)7 BindingInfo (org.apache.cxf.service.model.BindingInfo)7 FaultInfo (org.apache.cxf.service.model.FaultInfo)7 UnwrappedOperationInfo (org.apache.cxf.service.model.UnwrappedOperationInfo)7