⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 emitter.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    protected BindingOperation writeOperation(Definition def, Binding binding,                                              OperationDesc desc) {        Operation oper = def.createOperation();        QName elementQName = desc.getElementQName();        if(elementQName != null && elementQName.getLocalPart() != null) {            oper.setName(elementQName.getLocalPart());        } else {            oper.setName(desc.getName());        }        oper.setUndefined(false);        return writeBindingOperation(def, binding, oper, desc);    }    /**     * Create a Binding Operation     *      * @param def          * @param binding      * @param oper         * @param desc         * @return      */    protected BindingOperation writeBindingOperation(Definition def,                                                     Binding binding,                                                     Operation oper,                                                     OperationDesc desc) {        BindingOperation bindingOper = def.createBindingOperation();        BindingInput bindingInput = def.createBindingInput();        BindingOutput bindingOutput = null;                // TODO : Make this deal with all MEPs        if (OperationType.REQUEST_RESPONSE.equals(desc.getMep()))             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().equalsIgnoreCase("OPERATION")) {            soapAction = oper.getName();        } else if (getSoapAction().equalsIgnoreCase("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);        // Add soap:body element to the binding <input> element        ExtensibilityElement inputBody = writeSOAPBody(desc.getElementQName());        bindingInput.addExtensibilityElement(inputBody);        // add soap:headers, if any, to binding <input> element        // only when we write the Message and parts.        // Add soap:body element to the binding <output> element        if (bindingOutput != null) {            ExtensibilityElement outputBody = writeSOAPBody(desc.getReturnQName());            bindingOutput.addExtensibilityElement(outputBody);            bindingOper.setBindingOutput(bindingOutput);            // add soap:headers, if any, to binding <output> element            // only when we write the Message and parts.        }                // Add input to operation        bindingOper.setBindingInput(bindingInput);        // Faults clause        // Comment out the following part         // because it actually does the same thing as in writeMessages.        /*        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);        return bindingOper;    }    /**     * Create a SOAPHeader element     */    protected SOAPHeader writeSOAPHeader(ParameterDesc p, QName messageQName, String partName)    {        SOAPHeaderImpl soapHeader = new SOAPHeaderImpl();        // for now, if its document, it is literal use.        if (use == Use.ENCODED) {            soapHeader.setUse("encoded");            soapHeader.setEncodingStyles(encodingList);        } else {            soapHeader.setUse("literal");        }        // Set namespace        if (targetService == null) {            soapHeader.setNamespaceURI(intfNS);        } else {            soapHeader.setNamespaceURI(targetService);        }        QName headerQName = p.getQName();        if ((headerQName != null) && !headerQName.getNamespaceURI().equals("")) {            soapHeader.setNamespaceURI(headerQName.getNamespaceURI());        }        // Set the Message and Part information         soapHeader.setMessage(messageQName);         soapHeader.setPart(partName);        return soapHeader;    }    /**     * Method writeSOAPBody     *      * @param operQName      * @return      */    protected ExtensibilityElement writeSOAPBody(QName operQName) {        SOAPBody soapBody = new SOAPBodyImpl();        // for now, if its document, it is literal use.        if (use == Use.ENCODED) {            soapBody.setUse("encoded");            soapBody.setEncodingStyles(encodingList);        } else {            soapBody.setUse("literal");        }        if (style == Style.RPC) {            if (targetService == null) {                soapBody.setNamespaceURI(intfNS);            } else {                soapBody.setNamespaceURI(targetService);            }                if ((operQName != null) && !operQName.getNamespaceURI().equals("")) {                soapBody.setNamespaceURI(operQName.getNamespaceURI());            }        }        // The parts attribute will get set if we have headers.        // This gets done when the Message & parts are generated        // soapBody.setParts(...);        return soapBody;    }    // writeSOAPBody    /**     * Method writeSOAPFault     *      * @param faultDesc      * @return      */    protected SOAPFault writeSOAPFault(FaultDesc faultDesc) {        SOAPFault soapFault = new com.ibm.wsdl.extensions.soap.SOAPFaultImpl();        soapFault.setName(faultDesc.getName());        if (use != Use.ENCODED) {            soapFault.setUse("literal");            // no namespace for literal, gets it from the element        } else {            soapFault.setUse("encoded");            soapFault.setEncodingStyles(encodingList);            // Set the namespace from the fault QName if it exists            // otherwise use the target (or interface) namespace            QName faultQName = faultDesc.getQName();            if ((faultQName != null)                    && !faultQName.getNamespaceURI().equals("")) {                soapFault.setNamespaceURI(faultQName.getNamespaceURI());            } else {                if (targetService == null) {                    soapFault.setNamespaceURI(intfNS);                } else {                    soapFault.setNamespaceURI(targetService);                }            }        }        return soapFault;    }    // writeSOAPFault    /**     * Create a Request Message     *      * @param def       * @param oper      * @return      * @throws WSDLException      * @throws AxisFault          */    protected Message writeRequestMessage(Definition def, OperationDesc oper, BindingOperation bindop)            throws WSDLException, AxisFault    {        String partName;        ArrayList bodyParts = new ArrayList();        ArrayList parameters = oper.getAllInParams();        Message msg = def.createMessage();        QName qName = createMessageName(def,                getRequestQName(oper).getLocalPart() + "Request");        msg.setQName(qName);        msg.setUndefined(false);        // output all the parts for headers        boolean headers = writeHeaderParts(def, parameters, bindop, msg, true);        if (oper.getStyle() == Style.MESSAGE) {            // If this is a MESSAGE-style operation, just write out            // <xsd:any> for now.            // TODO: Support custom schema in WSDD for these operations            QName qname = oper.getElementQName();            types.writeElementDecl(qname, Object.class,                                   Constants.XSD_ANYTYPE, false, null);            Part part = def.createPart();            part.setName("part");            part.setElementName(qname);            msg.addPart(part);            bodyParts.add(part.getName());        } else if (oper.getStyle() == Style.WRAPPED) {            // If we're WRAPPED, write the wrapper element first, and then            // fill in any params.  If there aren't any params, we'll see            // an empty <complexType/> for the wrapper element.            partName = writeWrapperPart(def, msg, oper, true);            bodyParts.add(partName);        } else {        	//Now we're either DOCUMENT or RPC. If we're doing doc/lit, and in the        	//case of mulitple input params, we would warn user saying request        	//message's type information is being written out as multiple parts        	//than one single complexType and to interop with other soap stacks        	//that do doc/lit by default, user might want to publish his service        	//as a WRAPPED-LITERAL service instead.        	//see http://issues.apache.org/jira/browse/AXIS-2017        	if(oper.getStyle() == Style.DOCUMENT && parameters.size()>1 ) {         		System.out.println(Messages.getMessage("warnDocLitInteropMultipleInputParts"));         	}            // write a part for each non-header parameter            for (int i = 0; i < parameters.size(); i++) {                ParameterDesc parameter = (ParameterDesc) parameters.get(i);                if (!parameter.isInHeader() && !parameter.isOutHeader()) {                    partName = writePartToMessage(def, msg, true, parameter);                    bodyParts.add(partName);                }            }        }        // If we have headers, we must fill in the parts attribute of soap:body        // if not, we just leave it out (which means all parts)        if (headers) {            // Find soap:body in binding            List extensibilityElements = bindop.getBindingInput().getExtensibilityElements();            for (int i = 0; i < extensibilityElements.size(); i++)            {                Object ele = extensibilityElements.get(i);                if (ele instanceof SOAPBodyImpl)                {                    SOAPBodyImpl soapBody = (SOAPBodyImpl) ele;                    soapBody.setParts(bodyParts);                }            }        }        return msg;    }    /**     * Create parts of a Message for header parameters and write then in     * to the provided Message element. Also create a soap:header element     * in the binding     *     * @param parameters the list of parameters for the current operation     * @param bindop the current bindingOperation     * @param msg the message to add the parts to     * @param request true if we are do an input message, false if it is output     * @return true if we wrote any header parts     */    private boolean writeHeaderParts(Definition def,                                     ArrayList parameters,                                     BindingOperation bindop,                                     Message msg,                                     boolean request) throws WSDLException, AxisFault    {        boolean wroteHeaderParts = false;        String partName;        // Loop over all the parameters for this operation        for (int i = 0; i < parameters.size(); i++) {            ParameterDesc parameter = (ParameterDesc) parameters.get(i);            // write the input or output header parts in to the Message            if (request && parameter.isInHeader()) {                // put part in message                partName = writePartToMessage(def, msg, request, parameter);                // Create a soap:header element                SOAPHeader hdr = writeSOAPHeader(parameter, msg.getQName(), partName);                // put it in the binding <input> element                bindop.getBindingInput().addExtensibilityElement(hdr);                wroteHeaderParts = true;            }            else if (!request && parameter.isOutHeader()) {                // put part in message                partName = writePartToMessage(def, msg, request, parameter);                // Create a soap:header element                SOAPHeader hdr = writeSOAPHeader(parameter, msg.getQName(), partName);                // put it in the binding <output> element                bindop.getBindingOutput().addExtensibilityElement(hdr);                wroteHeaderParts = true;            }            else {                continue;   // body part            }        }        return wroteHeaderParts;    }    /**     * Method getRequestQName     *      * @param oper      * @return      */    protected QName getRequestQName(OperationDesc oper) {        qualifyOperation(oper);        QName qname = oper.getElementQName();        if (qname == null) {            qname = new QName(oper.getName());        }        return qname;    }    /**     * Method qualifyOperation     *      * @param oper      */    private void qualifyOperation(OperationDesc oper) {        if ((style == Style.WRAPPED) && (use == Use.LITERAL)) {            QName qname = oper.getElementQName();            if (qname == null) {                qname = new QName(intfNS, oper.getName());            } else if (qname.getNamespaceURI().equals("")) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -