Search in sources :

Example 56 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)

Example 57 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 " + currentOperation.getName() + "\n");
    if (!isWrapped) {
        code.append("// - bare operation. Parameters:\n");
        for (ParticleInfo ei : unwrappedElementsAndNames) {
            code.append("// - " + getElementObjectName(ei) + "\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 " + inputParameterNames.get(i) + "\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 " + nameManager.getJavascriptName(baseName) + "\n");
            } else if (type != null) {
                code.append("// - simple type " + 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 + ".prototype." + opFunctionPropertyName + " = " + opFunctionGlobalName + ";\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 58 with MessageInfo

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

the class AbstractInDatabindingInterceptor method getMessageInfo.

protected MessageInfo getMessageInfo(Message message, BindingOperationInfo operation, boolean requestor) {
    MessageInfo msgInfo;
    OperationInfo intfOp = operation.getOperationInfo();
    if (requestor) {
        msgInfo = intfOp.getOutput();
        message.put(MessageInfo.class, intfOp.getOutput());
    } else {
        msgInfo = intfOp.getInput();
        message.put(MessageInfo.class, intfOp.getInput());
    }
    return msgInfo;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo)

Example 59 with MessageInfo

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

the class JaxWsServiceFactoryBean method buildWSAActions.

private void buildWSAActions(OperationInfo operation, Method method) {
    // nothing
    if (method == null) {
        return;
    }
    Action action = method.getAnnotation(Action.class);
    Addressing addressing = method.getDeclaringClass().getAnnotation(Addressing.class);
    if (action == null && addressing == null) {
        return;
    }
    WebMethod wm = method.getAnnotation(WebMethod.class);
    String inputAction = "";
    if (action != null) {
        inputAction = action.input();
    }
    if (wm != null && StringUtils.isEmpty(inputAction)) {
        inputAction = wm.action();
    }
    if (StringUtils.isEmpty(inputAction)) {
        inputAction = computeAction(operation, "Request");
    }
    if (action == null && addressing != null) {
        operation.getInput().addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, inputAction);
        operation.getInput().addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, inputAction);
        if (operation.getOutput() != null) {
            operation.getOutput().addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, "Response"));
            operation.getOutput().addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, computeAction(operation, "Response"));
        }
    } else {
        MessageInfo input = operation.getInput();
        input.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, inputAction);
        if (!StringUtils.isEmpty(action.input())) {
            input.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, inputAction);
        }
        MessageInfo output = operation.getOutput();
        if (output != null && !StringUtils.isEmpty(action.output())) {
            output.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, action.output());
            output.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, action.output());
        } else if (output != null) {
            output.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, "Response"));
        }
        FaultAction[] faultActions = action.fault();
        if (faultActions != null && faultActions.length > 0 && operation.getFaults() != null) {
            for (FaultAction faultAction : faultActions) {
                FaultInfo faultInfo = getFaultInfo(operation, faultAction.className());
                if (faultInfo != null && !StringUtils.isEmpty(faultAction.value())) {
                    faultInfo.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, faultAction.value());
                    faultInfo.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, faultAction.value());
                }
                if (operation.isUnwrappedCapable()) {
                    faultInfo = getFaultInfo(operation.getUnwrappedOperation(), faultAction.className());
                    if (faultInfo != null && !StringUtils.isEmpty(faultAction.value())) {
                        faultInfo.addExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME, faultAction.value());
                        faultInfo.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, faultAction.value());
                    }
                }
            }
        }
    }
    for (FaultInfo fi : operation.getFaults()) {
        if (fi.getExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME) == null) {
            String f = "/Fault/" + fi.getName().getLocalPart();
            fi.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, f));
            if (operation.isUnwrappedCapable()) {
                fi = operation.getUnwrappedOperation().getFault(fi.getName());
                fi.addExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME, computeAction(operation, f));
            }
        }
    }
}
Also used : WebMethod(javax.jws.WebMethod) FaultAction(javax.xml.ws.FaultAction) Action(javax.xml.ws.Action) FaultAction(javax.xml.ws.FaultAction) FaultInfo(org.apache.cxf.service.model.FaultInfo) Addressing(javax.xml.ws.soap.Addressing) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Example 60 with MessageInfo

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

the class DispatchImpl method addInvokeOperation.

private void addInvokeOperation(boolean oneWay) {
    String name = oneWay ? INVOKE_ONEWAY_NAME : INVOKE_NAME;
    ServiceInfo info = client.getEndpoint().getEndpointInfo().getService();
    OperationInfo opInfo = info.getInterface().addOperation(oneWay ? INVOKE_ONEWAY_QNAME : INVOKE_QNAME);
    MessageInfo mInfo = opInfo.createMessage(new QName(DISPATCH_NS, name + "Request"), Type.INPUT);
    opInfo.setInput(name + "Request", mInfo);
    MessagePartInfo mpi = mInfo.addMessagePart("parameters");
    if (context == null) {
        mpi.setTypeClass(cl);
    }
    mpi.setElement(true);
    if (!oneWay) {
        mInfo = opInfo.createMessage(new QName(DISPATCH_NS, name + "Response"), Type.OUTPUT);
        opInfo.setOutput(name + "Response", mInfo);
        mpi = mInfo.addMessagePart("parameters");
        mpi.setElement(true);
        if (context == null) {
            mpi.setTypeClass(cl);
        }
    }
    for (BindingInfo bind : client.getEndpoint().getEndpointInfo().getService().getBindings()) {
        BindingOperationInfo bo = new BindingOperationInfo(bind, opInfo);
        bind.addOperation(bo);
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) QName(javax.xml.namespace.QName) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Aggregations

MessageInfo (org.apache.cxf.service.model.MessageInfo)69 QName (javax.xml.namespace.QName)41 OperationInfo (org.apache.cxf.service.model.OperationInfo)39 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)36 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)36 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)19 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)15 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)14 Test (org.junit.Test)14 Endpoint (org.apache.cxf.endpoint.Endpoint)13 Method (java.lang.reflect.Method)9 ArrayList (java.util.ArrayList)9 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 BindingInfo (org.apache.cxf.service.model.BindingInfo)7 FaultInfo (org.apache.cxf.service.model.FaultInfo)7 Message (org.apache.cxf.message.Message)6 UnwrappedOperationInfo (org.apache.cxf.service.model.UnwrappedOperationInfo)6