Package javax.wsdl

Examples of javax.wsdl.BindingOperation


        }
    }

    protected void buildBindingOperation(Definition def, Binding binding,
                                       Collection<BindingOperationInfo> bindingOperationInfos) {
        BindingOperation bindingOperation = null;
        for (BindingOperationInfo bindingOperationInfo : bindingOperationInfos) {
            bindingOperation = def.createBindingOperation();
            bindingOperation.setName(bindingOperationInfo.getName().getLocalPart());
            for (Operation operation
                    : CastUtils.cast(binding.getPortType().getOperations(), Operation.class)) {
                if (operation.getName().equals(bindingOperation.getName())) {
                    bindingOperation.setOperation(operation);
                    break;
                }
            }
            buildBindingInput(def, bindingOperation, bindingOperationInfo.getInput());
            buildBindingOutput(def, bindingOperation, bindingOperationInfo.getOutput());
View Full Code Here


        // Add the port and binding operations.
        ArrayList operations = serviceDesc.getOperations();
        for (Iterator i = operations.iterator(); i.hasNext();) {
            OperationDesc thisOper = (OperationDesc)i.next();

            BindingOperation bindingOper = writeOperation(def,
                                                          binding,
                                                          thisOper);
            Operation oper = bindingOper.getOperation();

            OperationDesc messageOper = thisOper;
            if (serviceDesc2 != null) {
                // If a serviceDesc containing an impl class is provided,
                // try and locate the corresponding operation
View Full Code Here

     */
    private BindingOperation writeBindingOperation (Definition def,
                                        Binding binding,
                                        Operation oper,
                                        OperationDesc desc) {
        BindingOperation bindingOper = def.createBindingOperation();
        BindingInput bindingInput = def.createBindingInput();
        BindingOutput bindingOutput = def.createBindingOutput();

        bindingOper.setName(oper.getName());
        bindingOper.setOperation(oper);

        SOAPOperation soapOper = new SOAPOperationImpl();


        // If the soapAction option is OPERATION, force
        // soapAction to the name of the operation. If NONE,
        // force soapAction to "".
        // Otherwise use the information in the operationDesc.
        String soapAction = "";
        if (getSoapAction().equals("OPERATION")) {
            soapAction = oper.getName();
        } else if (getSoapAction().equals("NONE")) {
            soapAction = "";
        } else {
            soapAction = desc.getSoapAction();
            if (soapAction == null) {
                soapAction = "";
            }
        }
        soapOper.setSoapActionURI(soapAction);

        // Until we have per-operation configuration, this will always be
        // the same as the binding default.
        // soapOper.setStyle("rpc");

        bindingOper.addExtensibilityElement(soapOper);

        // Input clause
        ExtensibilityElement input = null;
        input = writeSOAPBody(desc.getElementQName());
        bindingInput.addExtensibilityElement(input);

        //Output clause
        ExtensibilityElement output = null;
        output = writeSOAPBody(desc.getReturnQName());

        bindingOutput.addExtensibilityElement(output);
       
        // Ad input and output to operation
        bindingOper.setBindingInput(bindingInput);
        bindingOper.setBindingOutput(bindingOutput);

        // Faults clause
        ArrayList faultList = desc.getFaults();
        if (faultList != null) {
            for (Iterator it = faultList.iterator(); it.hasNext();) {
                FaultDesc faultDesc = (FaultDesc) it.next();
                // Get a soap:fault
                ExtensibilityElement soapFault = writeSOAPFault(faultDesc);
                // Get a wsdl:fault to put the soap:fault in
                BindingFault bindingFault = new BindingFaultImpl();
                bindingFault.setName(faultDesc.getName());
                bindingFault.addExtensibilityElement(soapFault);
                bindingOper.addBindingFault(bindingFault);
            }
        }
       
        binding.addBindingOperation(bindingOper);

View Full Code Here

        }

        // Get the SOAPAction
        ////////////////////////////////////////////////////////////////////
        String opStyle = null;
        BindingOperation bop = binding.getBindingOperation(opName,
                                                           null, null);
        if ( bop == null )
            throw new JAXRPCException( Messages.getMessage("noOperation02",
                                                            opName ));
        list = bop.getExtensibilityElements();
        for ( int i = 0 ; list != null && i < list.size() ; i++ ) {
            Object obj = list.get(i);
            if ( obj instanceof SOAPOperation ) {
                SOAPOperation sop    = (SOAPOperation) obj ;
                opStyle = ((SOAPOperation) obj).getStyle();
                String        action = sop.getSoapActionURI();
                if ( action != null ) {
                    setUseSOAPAction(true);
                    setSOAPActionURI(action);
                }
                else {
                    setUseSOAPAction(false);
                    setSOAPActionURI(null);
                }
                break ;
            }
        }

        // Get the body's namespace URI and encoding style
        ////////////////////////////////////////////////////////////////////
        BindingInput bIn = bop.getBindingInput();
        if ( bIn != null ) {
            list = bIn.getExtensibilityElements();
            for ( int i = 0 ; list != null && i < list.size() ; i++ ) {
                Object obj = list.get(i);
                if( obj instanceof
                        javax.wsdl.extensions.mime.MIMEMultipartRelated){
                  javax.wsdl.extensions.mime.MIMEMultipartRelated mpr=
                  (javax.wsdl.extensions.mime.MIMEMultipartRelated) obj;
                  Object part= null;
                  List l=  mpr.getMIMEParts();
                  for(int j=0; l!= null && j< l.size() && part== null; j++){
                     javax.wsdl.extensions.mime.MIMEPart mp
                     = (javax.wsdl.extensions.mime.MIMEPart)l.get(j);
                     List ll= mp.getExtensibilityElements();
                     for(int k=0; ll != null && k < ll.size() && part == null;
                           k++){
                       part= ll.get(k);
                       if ( !(part instanceof SOAPBody)) part = null;
                     }
                  }
                  if(null != part) obj= part;
                }

                if ( obj instanceof SOAPBody ) {
                    SOAPBody sBody  = (SOAPBody) obj ;
                    list = sBody.getEncodingStyles();
                    if ( list != null && list.size() > 0 )
                        this.setEncodingStyle( (String) list.get(0) );
                    String ns = sBody.getNamespaceURI();
                    if (ns != null && !ns.equals(""))
                      setOperationName( new QName( ns, opName ) );
                    break ;
                }
            }
        }

        Service service = this.getService();
        SymbolTable symbolTable = service.getWSDLParser().getSymbolTable();
        BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
        Parameters parameters = bEntry.getParameters(bop.getOperation());

        // loop over paramters and set up in/out params
        for (int j = 0; j < parameters.list.size(); ++j) {
            Parameter p = (Parameter) parameters.list.get(j);
            // Get the QName representing the parameter type
            QName paramType = Utils.getXSIType(p);
            this.addParameter( p.getQName(), paramType, modes[p.getMode()]);
        }

        // set output type
        if (parameters.returnParam != null) {
            // Get the QName for the return Type
            QName returnType = Utils.getXSIType(parameters.returnParam);
            QName returnQName = parameters.returnParam.getQName();

            // Get the javaType
            String javaType = null;
            if (parameters.returnParam.getMIMEType() != null) {
                javaType = "javax.activation.DataHandler";
            }
            else {
                javaType = parameters.returnParam.getType().getName();
            }
            if (javaType == null) {
                javaType = "";
            }
            else {
                javaType = javaType + ".class";
            }
            this.setReturnType(returnType);
            try {
                this.setReturnClass(ClassUtils.forName(javaType));
            } catch (Exception e){
                //TODO: ???
            }
            this.setReturnQName(returnQName);
        }
        else {
            this.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID);
        }
       
        boolean hasMIME = Utils.hasMIME(bEntry, bop);
        Use use = bEntry.getInputBodyType(bop.getOperation());
        Style style = Style.getStyle(opStyle, bEntry.getBindingStyle());
        if (use == Use.LITERAL) {
            // Turn off encoding
            setEncodingStyle(null);
            // turn off XSI types
            setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
        }
        if (hasMIME || use == Use.LITERAL) {
            // If it is literal, turn off multirefs.
            //
            // If there are any MIME types, turn off multirefs.
            // I don't know enough about the guts to know why
            // attachments don't work with multirefs, but they don't.
            setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
        }

        if (style == Style.DOCUMENT && symbolTable.isWrapped()) {
            style = Style.WRAPPED;
        }

        // Operation name
        if (style == Style.WRAPPED) {
            // We need to make sure the operation name, which is what we
            // wrap the elements in, matches the Qname of the parameter
            // element.
            Map partsMap = bop.getOperation().getInput().getMessage().getParts();
            Part p = (Part)partsMap.values().iterator().next();
            QName q = p.getElementName();
            setOperationName(q);
        } else {
            QName elementQName =
View Full Code Here

     * Write the body of the binding's stub file.
     */
    protected void writeFileBody(PrintWriter pw) throws IOException {
        List operations = binding.getBindingOperations();
        for (int i = 0; i < operations.size(); ++i) {
            BindingOperation operation = (BindingOperation) operations.get(i);
            Operation ptOperation = operation.getOperation();
            OperationType type = ptOperation.getStyle();
            Parameters parameters =
                    bEntry.getParameters(operation.getOperation());

            // These operation types are not supported.  The signature
            // will be a string stating that fact.
            if (type == OperationType.NOTIFICATION
                    || type == OperationType.SOLICIT_RESPONSE) {
View Full Code Here

        pw.println("        org.apache.axis.description.OperationDesc _oper;");
        pw.println("        org.apache.axis.description.FaultDesc _fault;");
        pw.println("        org.apache.axis.description.ParameterDesc [] _params;");
        List operations = binding.getBindingOperations();
        for (int i = 0; i < operations.size(); ++i) {
            BindingOperation bindingOper = (BindingOperation) operations.get(i);
            Operation operation = bindingOper.getOperation();
            OperationType type = operation.getStyle();
            // These operation types are not supported.  The signature
            // will be a string stating that fact.
            if (type == OperationType.NOTIFICATION
                    || type == OperationType.SOLICIT_RESPONSE) {
                continue;
            }
           
            Parameters parameters =
                    bEntry.getParameters(bindingOper.getOperation());

            if (parameters != null) {
                // The invoked java name of the bindingOper is stored.
                String opName = bindingOper.getOperation().getName();
                String javaOpName = Utils.xmlNameToJava(opName);
                pw.println("        _params = new org.apache.axis.description.ParameterDesc [] {");

                for (int j=0; j < parameters.list.size(); j++) {
                    Parameter p = (Parameter) parameters.list.get(j);
                    String modeStr;
                    switch (p.getMode()) {
                        case Parameter.IN:
                            modeStr = "org.apache.axis.description.ParameterDesc.IN";
                            break;
                        case Parameter.OUT:
                            modeStr = "org.apache.axis.description.ParameterDesc.OUT";
                            break;
                        case Parameter.INOUT:
                            modeStr = "org.apache.axis.description.ParameterDesc.INOUT";
                            break;
                        default:
                            throw new IOException(
                                Messages.getMessage("badParmMode00",
                                        (new Byte(p.getMode())).toString()));
                    }

                    // Get the QNames representing the parameter name and type
                    QName paramName = p.getQName();
                    QName paramType = Utils.getXSIType(p);

                    // Is this parameter a header?
                    String inHeader = p.isInHeader() ? "true" : "false";
                    String outHeader = p.isOutHeader() ? "true" : "false";
                    pw.println("            " +
                        "new org.apache.axis.description.ParameterDesc(" +
                        Utils.getNewQName(paramName) +
                        ", " + modeStr +
                        ", " + Utils.getNewQName(paramType) +
                        ", " + Utils.getParameterTypeName(p) + ".class" +
                        ", " + inHeader +
                        ", " + outHeader + "), ");
                }

                pw.println("        };");

                // Get the return name QName and type
                QName retName = null;
                QName retType = null;
                if (parameters.returnParam != null) {
                    retName = parameters.returnParam.getQName();
                    retType = Utils.getXSIType(parameters.returnParam);
                }

                String returnStr;
                if (retName != null) {
                    returnStr = Utils.getNewQName(retName);
                } else {
                    returnStr = "null";
                }
                pw.println("        _oper = new org.apache.axis.description.OperationDesc(\"" +
                           javaOpName + "\", _params, " + returnStr + ");");

                if (retType != null) {
                    pw.println("        _oper.setReturnType(" +
                               Utils.getNewQName(retType) + ");");
                    if (parameters.returnParam != null &&
                        parameters.returnParam.isOutHeader()) {
                        pw.println("        _oper.setReturnHeader(true);");
                    }
                }

                // If we need to know the QName (if we have a namespace or
                // the actual method name doesn't match the XML we expect),
                // record it in the OperationDesc
                QName elementQName =
                    Utils.getOperationQName(bindingOper, bEntry, symbolTable);
                if (elementQName != null) {
                    pw.println("        _oper.setElementQName(" +
                            Utils.getNewQName(elementQName) + ");");
                }

                // Find the SOAPAction.
                List elems = bindingOper.getExtensibilityElements();
                Iterator it = elems.iterator();
                boolean found = false;
                while (!found && it.hasNext()) {
                    ExtensibilityElement elem = (ExtensibilityElement) it.next();
                    if (elem instanceof SOAPOperation) {
                        SOAPOperation soapOp = (SOAPOperation) elem;
                        String action = soapOp.getSoapActionURI();
                        if (action != null) {
                            pw.println("        _oper.setSoapAction(\"" + action + "\");");
                            found = true;
                        }
                    }
                }

                pw.println("        _myOperationsList.add(_oper);");
                pw.println("        if (_myOperations.get(\"" + javaOpName + "\") == null) {");
                pw.println("            _myOperations.put(\"" + javaOpName + "\", new java.util.ArrayList());");
                pw.println("        }");
                pw.println("        ((java.util.List)_myOperations.get(\"" + javaOpName + "\")).add(_oper);");
            }

            // Now generate FaultDesc
            if (bEntry.getFaults() != null) {
                ArrayList faults = (ArrayList) bEntry.getFaults().get(bindingOper);
                if (faults != null) {

                    // Operation was not created if there were no parameters
                    if (parameters == null) {
                        String opName = bindingOper.getOperation().getName();
                        String javaOpName = Utils.xmlNameToJava(opName);
                        pw.println("        _oper = " +
                                   "new org.apache.axis.description.OperationDesc();");
                        pw.println("        _oper.setName(\"" +
                                   javaOpName + "\");");
                    }
                    // Create FaultDesc items for each fault
                    Iterator it = faults.iterator();
                    while (it.hasNext()) {
                        FaultInfo faultInfo = (FaultInfo) it.next();
                        QName faultQName = faultInfo.getQName();
                        QName faultXMLType = faultInfo.getXMLType();
                        String faultName = faultInfo.getName();
                        String className =
                            Utils.getFullExceptionName(
                               faultInfo.getMessage(), symbolTable);
                        pw.println("        _fault = " +
                                   "new org.apache.axis.description.FaultDesc();");
                        if (faultName != null) {
                            pw.println("        _fault.setName(\"" +
                                       faultName + "\");");
                        }
                        if (faultQName != null) {
                            pw.println("        _fault.setQName(" +
                                       Utils.getNewQName(faultQName+ ");");
                        }
                        if (className != null) {
                            pw.println("        _fault.setClassName(\"" +
                                       className + "\");");
                        }
                        if (faultXMLType != null) {
                            pw.println("        _fault.setXmlType(" +
                                       Utils.getNewQName(faultXMLType+ ");");
                        }
                        pw.println("        _oper.addFault(_fault);");
                    }
                }
            }
        }
        pw.println("    }");
        pw.println();

        // Skeleton constructors
        pw.println("    public " + className + "() {");
        pw.println("        this.impl = new " + bEntry.getName() + "Impl();");
        pw.println("    }");
        pw.println();
        pw.println("    public " + className + "(" + implType + ") {");
        pw.println("        this.impl = impl;");
        pw.println("    }");

        // Now write each of the operation methods
        for (int i = 0; i < operations.size(); ++i) {
            BindingOperation operation = (BindingOperation) operations.get(i);
            Parameters parameters =
                    bEntry.getParameters(operation.getOperation());

            // Get the soapAction from the <soap:operation>
            String soapAction = "";
            Iterator operationExtensibilityIterator = operation.getExtensibilityElements().iterator();
            for (; operationExtensibilityIterator.hasNext();) {
                Object obj = operationExtensibilityIterator.next();
                if (obj instanceof SOAPOperation) {
                    soapAction = ((SOAPOperation) obj).getSoapActionURI();
                    break;
                }
            }
            // Get the namespace for the operation from the <soap:body>
            // RJB: is this the right thing to do?
            String namespace = "";
            Iterator bindingMsgIterator = null;
            BindingInput input = operation.getBindingInput();
            BindingOutput output;
            if (input != null) {
                bindingMsgIterator =
                        input.getExtensibilityElements().iterator();
            }
            else {
                output = operation.getBindingOutput();
                if (output != null) {
                    bindingMsgIterator =
                            output.getExtensibilityElements().iterator();
                }
            }
            if (bindingMsgIterator != null) {
                for (; bindingMsgIterator.hasNext();) {
                    Object obj = bindingMsgIterator.next();
                    if (obj instanceof SOAPBody) {
                        namespace = ((SOAPBody) obj).getNamespaceURI();
                        if (namespace == null) {
                            namespace = symbolTable.getDefinition().getTargetNamespace();
                        }
                        if (namespace == null)
                            namespace = "";
                        break;
                    }
                }
            }
            Operation ptOperation = operation.getOperation();
            OperationType type = ptOperation.getStyle();

            // These operation types are not supported.  The signature
            // will be a string stating that fact.
            if (type == OperationType.NOTIFICATION
View Full Code Here

            return null;
        }

        List operations = binding.getBindingOperations();
        for (Object opObj : operations) {
            BindingOperation operation = (BindingOperation)opObj;
            return operation.getName();
        }
        return null;
    }
View Full Code Here

        if (binding == null) {
            return null;
        }
        List operations = binding.getBindingOperations();
        for (Object opObj : operations) {
            BindingOperation operation = (BindingOperation)opObj;
            List exElements = operation.getExtensibilityElements();
            for (Object elObj : exElements) {
                ExtensibilityElement exElement = (ExtensibilityElement)elObj;
                if (isSoapOperation(exElement)) {
                    SOAPOperation soapOperation = (SOAPOperation)exElement;
                    return soapOperation.getSoapActionURI();
View Full Code Here

        if (binding == null) {
            return null;
        }
        List operations = binding.getBindingOperations();
        for (Object opObj : operations) {
            BindingOperation operation = (BindingOperation)opObj;
            List exElements = operation.getExtensibilityElements();
            for (Object elObj : exElements) {
                ExtensibilityElement exElement = (ExtensibilityElement)elObj;
                if (isSoapOperation(exElement)) {
                    SOAPOperation soapOperation = (SOAPOperation)exElement;
                    return soapOperation.getSoapActionURI();
View Full Code Here

        }
        List operations = binding.getBindingOperations();
        if (operations == null) {
            return null;
        }
        BindingOperation operation = null;
        for (Object opObj : operations) {
            operation = (BindingOperation)opObj;
        }
        List exElements = operation.getExtensibilityElements();
        for (Object elObj : exElements) {
            ExtensibilityElement exElement = (ExtensibilityElement)elObj;
            if (isSoapOperation(exElement)) {
                SOAPOperation soapOperation = (SOAPOperation)exElement;
                if (soapOperation.getElementType().equals(operationQname)) {
View Full Code Here

TOP

Related Classes of javax.wsdl.BindingOperation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.