Package javax.wsdl

Examples of javax.wsdl.BindingOperation


            }
        }
        PortType wsdlPortType = wsdlBinding.getPortType();
        for (Iterator iter = wsdlPortType.getOperations().iterator(); iter.hasNext();) {
            Operation wsdlOperation = (Operation) iter.next();
            BindingOperation wsdlBindingOperation = wsdlBinding.getBindingOperation(wsdlOperation.getName(), null, null);
            SOAPOperation wsdlSoapOperation = WSDLUtils.getExtension(wsdlBindingOperation, SOAPOperation.class);
            Wsdl1SoapOperationImpl operation = new Wsdl1SoapOperationImpl();
            operation.setName(new QName(wsdlPortType.getQName().getNamespaceURI(), wsdlOperation.getName()));
            if (wsdlSoapOperation != null) {
                operation.setSoapAction(wsdlSoapOperation.getSoapActionURI());
                operation.setStyle(getStyle(wsdlSoapOperation.getStyle()));
            } else {
                operation.setSoapAction("");
            }
            if (operation.getStyle() == null) {
                operation.setStyle(binding.getStyle() != null ? binding.getStyle() : Style.DOCUMENT);
            }
            if (wsdlOperation.getStyle() == OperationType.ONE_WAY) {
                operation.setMep(JbiConstants.IN_ONLY);
            } else if (wsdlOperation.getStyle() == OperationType.REQUEST_RESPONSE) {
                operation.setMep(JbiConstants.IN_OUT);
            }
           
            // Create input
            createInput(operation, wsdlBindingOperation);
            // Create output
            createOutput(operation, wsdlBindingOperation);
            // Create faults
            Collection faults = wsdlOperation.getFaults().values();
            for (Iterator itFault = faults.iterator(); itFault.hasNext();) {
                Fault fault = (Fault) itFault.next();
                createFault(operation, wsdlBindingOperation.getBindingFaults().get(fault.getName()));
            }
            // Add operation
            binding.addOperation(operation);
        }
       
View Full Code Here


        StringWriter writer = new StringWriter();
        factory.newWSDLWriter().writeWSDL(def, writer);
        log.info(writer.toString());
        Binding b = (Binding) def.getBindings().values().iterator().next();
        BindingOperation bop = (BindingOperation) b.getBindingOperations().iterator().next();
        assertEquals(1, bop.getExtensibilityElements().size());
        ExtensibilityElement ee = (ExtensibilityElement) bop.getExtensibilityElements().iterator().next();
        assertTrue(ee instanceof SOAPOperation);
        assertEquals("", ((SOAPOperation) ee).getSoapActionURI());
    }
View Full Code Here

        }
        // Create operations
        List<?> operations = portType.getOperations();
        for (Iterator<?> iter = operations.iterator(); iter.hasNext();) {
            Operation operation = (Operation) iter.next();
            BindingOperation bindingOp = createBindingOperation(def, soap11, operation);
            binding.addBindingOperation(bindingOp);
        }
        def.addBinding(binding);
        // Create service
        Service service = def.createService();
View Full Code Here

        service.addPort(port);
        def.addService(service);
    }

    private static BindingOperation createBindingOperation(Definition def, boolean soap11, Operation operation) {
        BindingOperation bindingOp = def.createBindingOperation();
        bindingOp.setName(operation.getName());
        if (soap11) {
            SOAPOperation op = new SOAPOperationImpl();
            op.setSoapActionURI("");
            bindingOp.addExtensibilityElement(op);
        } else {
            SOAP12Operation op = new SOAP12OperationImpl();
            op.setSoapActionURI("");
            bindingOp.addExtensibilityElement(op);
        }
        if (operation.getInput() != null) {
            BindingInput in = def.createBindingInput();
            in.setName(operation.getInput().getName());
            if (soap11) {
                SOAPBody body = new SOAPBodyImpl();
                body.setUse("literal");
                in.addExtensibilityElement(body);
            } else {
                SOAP12Body body = new SOAP12BodyImpl();
                body.setUse("literal");
                in.addExtensibilityElement(body);
            }
            bindingOp.setBindingInput(in);
        }
        if (operation.getOutput() != null) {
            BindingOutput out = def.createBindingOutput();
            out.setName(operation.getOutput().getName());
            if (soap11) {
                SOAPBody body = new SOAPBodyImpl();
                body.setUse("literal");
                out.addExtensibilityElement(body);
            } else {
                SOAP12Body body = new SOAP12BodyImpl();
                body.setUse("literal");
                out.addExtensibilityElement(body);
            }
            bindingOp.setBindingOutput(out);
        }
        for (Iterator<?> itf = operation.getFaults().values().iterator(); itf.hasNext();) {
            Fault fault = (Fault) itf.next();
            BindingFault bindingFault = def.createBindingFault();
            bindingFault.setName(fault.getName());
            if (soap11) {
                SOAPFault soapFault = new SOAPFaultImpl();
                soapFault.setUse("literal");
                soapFault.setName(fault.getName());
                bindingFault.addExtensibilityElement(soapFault);
            } else {
                SOAP12Fault soapFault = new SOAP12FaultImpl();
                soapFault.setUse("literal");
                soapFault.setName(fault.getName());
                bindingFault.addExtensibilityElement(soapFault);
            }
            bindingOp.addBindingFault(bindingFault);
        }
        return bindingOp;
    }
View Full Code Here

                    // add binding output element to bindings for this port type
                    for (Object bindObj : definition.getAllBindings().values()) {
                        Binding binding = (Binding)bindObj;
                        if (binding.getPortType().equals(portType)) {
                            BindingOperation op = binding.getBindingOperation(opName, null, null);
                            if (op != null && op.getBindingInput() != null && op.getBindingOutput() == null) {
                                BindingOutput bindingOut = definition.createBindingOutput();
                                for (Object extObj : op.getBindingInput().getExtensibilityElements()) {
                                    bindingOut.addExtensibilityElement((ExtensibilityElement)extObj);
                                }
                                op.setBindingOutput(bindingOut);
                            }
                        }
                    }
                }
            }
View Full Code Here

    @SuppressWarnings("unchecked")
    protected void createBindingOperations(Definition definition, Binding binding, PortType portType)
        throws WSDLException {
        for (Iterator oi = portType.getOperations().iterator(); oi.hasNext();) {
            Operation operation = (Operation)oi.next();
            BindingOperation bindingOperation = definition.createBindingOperation();
            bindingOperation.setOperation(operation);
            configureBindingOperation(bindingOperation, operation);
            SOAPOperation soapOperation =
                (SOAPOperation)definition.getExtensionRegistry()
                    .createExtension(BindingOperation.class, SOAP_OPERATION);
            soapOperation.setSoapActionURI("");
            bindingOperation.addExtensibilityElement(soapOperation);
            if (operation.getInput() != null) {
                BindingInput bindingInput = definition.createBindingInput();
                configureBindingInput(bindingInput, operation.getInput());
                SOAPBody soapBody =
                    (SOAPBody)definition.getExtensionRegistry().createExtension(BindingInput.class, SOAP_BODY);
                soapBody.setUse("literal");
                bindingInput.addExtensibilityElement(soapBody);
                bindingOperation.setBindingInput(bindingInput);
            }
            if (operation.getOutput() != null) {
                BindingOutput bindingOutput = definition.createBindingOutput();
                configureBindingOutput(bindingOutput, operation.getOutput());
                SOAPBody soapBody =
                    (SOAPBody)definition.getExtensionRegistry().createExtension(BindingOutput.class, SOAP_BODY);
                soapBody.setUse("literal");
                bindingOutput.addExtensibilityElement(soapBody);
                bindingOperation.setBindingOutput(bindingOutput);
            }
            for (Iterator fi = operation.getFaults().values().iterator(); fi.hasNext();) {
                Fault fault = (Fault)fi.next();
                BindingFault bindingFault = definition.createBindingFault();
                configureBindingFault(bindingFault, fault);
                bindingOperation.addBindingFault(bindingFault);
            }
            binding.addBindingOperation(bindingOperation);
        }
    }
View Full Code Here

    protected String getSOAPAction(String operationName) {
        Binding binding = wsBinding.getBinding();
        if (binding != null) {
            for (Object o : binding.getBindingOperations()) {
                BindingOperation bop = (BindingOperation)o;
                if (bop.getName().equalsIgnoreCase(operationName)) {
                    for (Object o2 : bop.getExtensibilityElements()) {
                        if (o2 instanceof SOAPOperation) {
                            return ((SOAPOperation)o2).getSoapActionURI();
                        }
                    }
                }
View Full Code Here

        pw.println("    static {");
        pw.println("        org.apache.axis.description.OperationDesc _oper;");
        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);
                    pw.println("            " +
                        "new org.apache.axis.description.ParameterDesc(" +
                        Utils.getNewQName(paramName) +
                        ", " + modeStr +
                        ", " + Utils.getNewQName(paramType) +
                        ", " + Utils.getParameterTypeName(p) + ".class), ");
                }

                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 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);
                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);");
            }
        }
        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

            boolean hasLiteral = false;
            HashMap attributes = new HashMap();
            List bindList = binding.getBindingOperations();
            Map mimeTypes = new HashMap();
            for (Iterator opIterator = bindList.iterator(); opIterator.hasNext();) {
                BindingOperation bindOp = (BindingOperation) opIterator.next();
                BindingInput bindingInput = bindOp.getBindingInput();
                BindingOutput bindingOutput = bindOp.getBindingOutput();
                String opName = bindOp.getName();

                // First, make sure the binding operation matches a portType operation
                String inputName = bindingInput == null ? null :
                        bindingInput.getName();
                String outputName = bindingOutput == null ? null :
                        bindingOutput.getName();
                if (binding.getPortType().getOperation(
                        opName, inputName, outputName) == null) {
                    throw new IOException(Messages.getMessage("unmatchedOp",
                            new String[] {opName, inputName, outputName}));
                }

                int inputBodyType = BindingEntry.USE_ENCODED;
                int outputBodyType = BindingEntry.USE_ENCODED;
                Map opMimeTypes = new HashMap();
                mimeTypes.put(opName, opMimeTypes);

                // input
                if (bindingInput != null) {
                    if (bindingInput.getExtensibilityElements() != null) {
                        Iterator inIter = bindingInput.getExtensibilityElements().iterator();
                        for (; inIter.hasNext();) {
                            Object obj = inIter.next();
                            if (obj instanceof SOAPBody) {
                                String use = ((SOAPBody) obj).getUse();
                                if (use == null) {
                                    throw new IOException(Messages.getMessage(
                                            "noUse", opName));
                                }
                                if (use.equalsIgnoreCase("literal")) {
                                    inputBodyType = BindingEntry.USE_LITERAL;
                                }
                                break;
                            }
                            else if (obj instanceof MIMEMultipartRelated) {
                                IntHolder holder = new IntHolder(inputBodyType);
                                opMimeTypes.putAll(collectMIMETypes(
                                        (MIMEMultipartRelated) obj, holder, bindOp));
                                inputBodyType = holder.value;
                            }
                        }
                    }
                }

                // output
                if (bindingOutput != null) {
                    if (bindingOutput.getExtensibilityElements() != null) {
                        Iterator outIter = bindingOutput.getExtensibilityElements().iterator();
                        for (; outIter.hasNext();) {
                            Object obj = outIter.next();
                            if (obj instanceof SOAPBody) {
                                String use = ((SOAPBody) obj).getUse();
                                if (use == null) {
                                    throw new IOException(Messages.getMessage(
                                            "noUse", opName));
                                }
                                if (use.equalsIgnoreCase("literal")) {
                                    outputBodyType = BindingEntry.USE_LITERAL;
                                }
                                break;
                            }
                            else if (obj instanceof MIMEMultipartRelated) {
                                IntHolder holder = new IntHolder(outputBodyType);
                                opMimeTypes.putAll(collectMIMETypes(
                                        (MIMEMultipartRelated) obj, holder, bindOp));
                                outputBodyType = holder.value;
                            }
                        }
                    }
                }

                // faults
                HashMap faultMap = new HashMap();
                Iterator faultMapIter = bindOp.getBindingFaults().values().iterator();
                for (; faultMapIter.hasNext(); ) {
                    BindingFault bFault = (BindingFault)faultMapIter.next();

                    // Set default entry for this fault
                    String faultName = bFault.getName();
                    int faultBodyType = BindingEntry.USE_ENCODED;

                    Iterator faultIter =
                            bFault.getExtensibilityElements().iterator();
                    for (; faultIter.hasNext();) {
                        Object obj = faultIter.next();
                        if (obj instanceof SOAPBody) {
                            String use = ((SOAPBody) obj).getUse();
                            if (use == null) {
                                throw new IOException(Messages.getMessage(
                                        "noUse", opName));
                            }
                            if (use.equalsIgnoreCase("literal")) {
                                faultBodyType = BindingEntry.USE_LITERAL;
                            }
                            break;
                        }
                    }
                    // Add this fault name and bodyType to the map
                    faultMap.put(faultName, new Integer(faultBodyType));
                }
                // Associate the portType operation that goes with this binding
                // with the body types.
                attributes.put(bindOp.getOperation(),
                        new BindingEntry.OperationAttr(inputBodyType, outputBodyType, faultMap));

                // If the input or output body uses literal, flag the binding as using literal.
                // NOTE:  should I include faultBodyType in this check?
                if (inputBodyType == BindingEntry.USE_LITERAL ||
View Full Code Here

            }
        }

        // Get the SOAPAction
        ////////////////////////////////////////////////////////////////////
        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 ;
                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){
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.