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

📄 soapfault.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     *     *   <P>Fault codes, which given information about the fault,     *   are defined in the SOAP 1.1 specification.</P>     * @param   faultCode a <CODE>String</CODE> giving     *     the fault code to be set; must be one of the fault codes     *     defined in the SOAP 1.1 specification     * @throws  SOAPException if there was an error in     *     adding the <CODE>faultCode</CODE> to the underlying XML     *     tree.     */    public void setFaultCode(String faultCode) throws SOAPException {        fault.setFaultCodeAsString(faultCode);    }        /**     * Gets the fault code for this <CODE>SOAPFaultException</CODE>     * object.     * @return a <CODE>String</CODE> with the fault code     */    public String getFaultCode() {        return fault.getFaultCode().getLocalPart();    }        /**     *  Sets this <CODE>SOAPFaultException</CODE> object with the given     *   fault actor.     *     *   <P>The fault actor is the recipient in the message path who     *   caused the fault to happen.</P>     * @param   faultActor a <CODE>String</CODE>     *     identifying the actor that caused this <CODE>     *     SOAPFaultException</CODE> object     * @throws  SOAPException  if there was an error in     *     adding the <CODE>faultActor</CODE> to the underlying XML     *     tree.     */    public void setFaultActor(String faultActor) throws SOAPException {        fault.setFaultActor(faultActor);    }        /**     * Gets the fault actor for this <CODE>SOAPFaultException</CODE>     * object.     * @return  a <CODE>String</CODE> giving the actor in the message     *     path that caused this <CODE>SOAPFaultException</CODE> object     * @see #setFaultActor(java.lang.String) setFaultActor(java.lang.String)     */    public String getFaultActor() {        return fault.getFaultActor();    }        /**     * Sets the fault string for this <CODE>SOAPFaultException</CODE>     * object to the given string.     *     * @param faultString a <CODE>String</CODE>     *     giving an explanation of the fault     * @throws  SOAPException  if there was an error in     *     adding the <CODE>faultString</CODE> to the underlying XML     *     tree.     * @see #getFaultString() getFaultString()     */    public void setFaultString(String faultString) throws SOAPException {        fault.setFaultString(faultString);    }        /**     * Gets the fault string for this <CODE>SOAPFaultException</CODE>     * object.     * @return a <CODE>String</CODE> giving an explanation of the     *     fault     */    public String getFaultString() {        return fault.getFaultString();    }        /**     * Returns the detail element for this <CODE>SOAPFaultException</CODE>     *   object.     *     *   <P>A <CODE>Detail</CODE> object carries     *   application-specific error information related to <CODE>     *   SOAPBodyElement</CODE> objects.</P>     * @return  a <CODE>Detail</CODE> object with     *     application-specific error information     */    public javax.xml.soap.Detail getDetail() {        List children = this.getChildren();        if(children==null || children.size()<=0)            return null;        // find detail element        for (int i=0; i < children.size(); i++) {            Object obj = children.get(i);            if (obj instanceof javax.xml.soap.Detail) {                return (javax.xml.soap.Detail) obj;            }        }        return null;    }        /**     * Creates a <CODE>Detail</CODE> object and sets it as the     *   <CODE>Detail</CODE> object for this <CODE>SOAPFaultException</CODE>     *   object.     *     *   <P>It is illegal to add a detail when the fault already     *   contains a detail. Therefore, this method should be called     *   only after the existing detail has been removed.</P>     * @return the new <CODE>Detail</CODE> object     * @throws  SOAPException  if this     *     <CODE>SOAPFaultException</CODE> object already contains a valid     *     <CODE>Detail</CODE> object     */    public javax.xml.soap.Detail addDetail() throws SOAPException {        if(getDetail() != null){            throw new SOAPException(Messages.getMessage("valuePresent"));        }        Detail detail = convertToDetail(fault);        addChildElement(detail);        return detail;    }    public void setFaultCode(Name faultCodeQName) throws SOAPException {        String uri = faultCodeQName.getURI();        String local = faultCodeQName.getLocalName();        String prefix = faultCodeQName.getPrefix();        this.prefix = prefix;        QName qname = new QName(uri,local);        fault.setFaultCode(qname);    }    public Name getFaultCodeAsName() {        QName qname = fault.getFaultCode();        String uri = qname.getNamespaceURI();        String local = qname.getLocalPart();        return new PrefixedQName(uri, local, prefix);    }    public void setFaultString(String faultString, Locale locale) throws SOAPException {        fault.setFaultString(faultString);        this.locale = locale;    }    public Locale getFaultStringLocale() {        return locale;    }    /**     * Convert the details in an AxisFault to a Detail object     *     * @param fault source of the fault details     * @return a detail element contructed from the AxisFault details     * @throws SOAPException     */    private Detail convertToDetail(AxisFault fault)            throws SOAPException    {        detail = new Detail();        Element[] darray = fault.getFaultDetails();        fault.setFaultDetail(new Element[]{});        for (int i = 0; i < darray.length; i++)        {            Element detailtEntryElem = darray[i];            DetailEntry detailEntry = detail.addDetailEntry(                    new PrefixedQName(detailtEntryElem.getNamespaceURI(),                            detailtEntryElem.getLocalName(), detailtEntryElem.getPrefix()));            copyChildren(detailEntry, detailtEntryElem);        }        return detail;    }    /**     * Copy the children of a DOM element to a SOAPElement.     *     * @param soapElement target of the copy     * @param domElement source for the copy     * @throws SOAPException     */    private static void copyChildren(SOAPElement soapElement, Element domElement)            throws SOAPException    {        org.w3c.dom.NodeList nl = domElement.getChildNodes();        for (int j = 0; j < nl.getLength(); j++)        {            org.w3c.dom.Node childNode = nl.item(j);            if (childNode.getNodeType() == Node.TEXT_NODE)            {                soapElement.addTextNode(childNode.getNodeValue());                break; // only one text node assmed            }            if (childNode.getNodeType() == Node.ELEMENT_NODE)            {                String uri = childNode.getNamespaceURI();                SOAPElement childSoapElement = null;                if (uri == null)                {                    childSoapElement = soapElement.addChildElement(childNode.getLocalName                            ());                }                else                {                    childSoapElement = soapElement.addChildElement(                            childNode.getLocalName(),                            childNode.getPrefix(), uri);                }                copyChildren(childSoapElement, (Element) childNode);            }        }    }}

⌨️ 快捷键说明

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