Package javax.xml.rpc.soap

Examples of javax.xml.rpc.soap.SOAPFaultException


/*    */
/*    */   protected static void assertAddrProperties(AddressingProperties inProps)
/*    */     throws SOAPFaultException
/*    */   {
/* 85 */     if (null == inProps)
/* 86 */       throw new SOAPFaultException(Constants.SOAP11_FAULT_CODE_CLIENT, "Addressing headers missing from request", "wse:InvalidMessage", null);
/* 87 */     if (null == inProps.getTo())
/* 88 */       throw new SOAPFaultException(Constants.SOAP11_FAULT_CODE_CLIENT, "Event source URI missing from request (wsa:To)", "wse:InvalidMessage", null);
/*    */   }
View Full Code Here


/*  97 */     QName faultCode = ((NameImpl)soapFault.getFaultCodeAsName()).toQName();
/*  98 */     String faultString = soapFault.getFaultString();
/*  99 */     String faultActor = soapFault.getFaultActor();
/* 100 */     Detail detail = soapFault.getDetail();
/*     */
/* 102 */     SOAPFaultException faultEx = new SOAPFaultException(faultCode, faultString, faultActor, detail);
/*     */
/* 104 */     CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
/* 105 */     if ((detail != null) && (msgContext != null))
/*     */     {
/* 107 */       SerializationContext serContext = msgContext.getSerializationContext();
/* 108 */       TypeMapping typeMapping = serContext.getTypeMapping();
/*     */
/* 110 */       Iterator it = detail.getDetailEntries();
/* 111 */       while (it.hasNext())
/*     */       {
/* 113 */         DetailEntry deElement = (DetailEntry)it.next();
/* 114 */         Name deName = deElement.getElementName();
/* 115 */         QName xmlName = new QName(deName.getURI(), deName.getLocalName());
/*     */
/* 117 */         OperationMetaData opMetaData = msgContext.getOperationMetaData();
/* 118 */         FaultMetaData faultMetaData = opMetaData.getFault(xmlName);
/* 119 */         if (faultMetaData != null)
/*     */         {
/* 121 */           if (log.isDebugEnabled())
/* 122 */             log.debug("Deserialize fault: " + faultMetaData);
/* 123 */           QName xmlType = faultMetaData.getXmlType();
/* 124 */           Class javaType = faultMetaData.getJavaType();
/*     */
/* 127 */           AbstractDeserializerFactory desFactory = (AbstractDeserializerFactory)typeMapping.getDeserializer(javaType, xmlType);
/* 128 */           if (desFactory == null) {
/* 129 */             throw new JAXRPCException("Cannot obtain deserializer factory for: " + xmlType);
/*     */           }
/*     */
/*     */           try
/*     */           {
/* 136 */             String prefix = deName.getPrefix();
/* 137 */             if (prefix.length() > 0)
/*     */             {
/* 139 */               String nsURI = deName.getURI();
/* 140 */               String attrValue = deElement.getAttribute("xmlns:" + prefix);
/* 141 */               if ((nsURI.length() > 0) && (attrValue.length() == 0)) {
/* 142 */                 deElement.addNamespaceDeclaration(prefix, nsURI);
/*     */               }
/*     */             }
/* 145 */             Source xmlFragment = new DOMSource(deElement);
/* 146 */             DeserializerSupport des = desFactory.getDeserializer();
/* 147 */             Object userEx = des.deserialize(xmlName, xmlType, xmlFragment, serContext);
/* 148 */             if ((userEx == null) || (!(userEx instanceof Exception))) {
/* 149 */               throw new WSException("Invalid deserialization result: " + userEx);
/*     */             }
/* 151 */             faultEx.initCause((Exception)userEx);
/*     */           }
/*     */           catch (RuntimeException rte)
/*     */           {
/* 155 */             throw rte;
/*     */           }
View Full Code Here

/* 170 */     return faultEx;
/*     */   }
/*     */
/*     */   public static SOAPMessageImpl exceptionToFaultMessage(Exception reqEx)
/*     */   {
/*     */     SOAPFaultException faultEx;
/*     */     SOAPFaultException faultEx;
/* 179 */     if ((reqEx instanceof SOAPFaultException))
/*     */     {
/* 181 */       faultEx = (SOAPFaultException)reqEx;
/*     */     }
/* 183 */     else if ((reqEx instanceof CommonSOAPFaultException))
/*     */     {
/* 185 */       CommonSOAPFaultException soapEx = (CommonSOAPFaultException)reqEx;
/* 186 */       QName faultCode = soapEx.getFaultCode();
/* 187 */       String faultString = soapEx.getFaultString();
/* 188 */       Throwable cause = soapEx.getCause();
/* 189 */       SOAPFaultException faultEx = new SOAPFaultException(faultCode, faultString, null, null);
/* 190 */       faultEx.initCause(cause);
/*     */     }
/*     */     else
/*     */     {
/* 194 */       QName faultCode = Constants.SOAP11_FAULT_CODE_SERVER;
/* 195 */       String faultString = reqEx.getMessage() != null ? reqEx.getMessage() : reqEx.toString();
/* 196 */       faultEx = new SOAPFaultException(faultCode, faultString, null, null);
/* 197 */       faultEx.initCause(reqEx);
/*     */     }
/*     */
/* 200 */     Throwable faultCause = faultEx.getCause();
/* 201 */     log.error("SOAP request exception", faultCause != null ? faultCause : faultEx);
/*     */     try
/*     */     {
/* 205 */       SOAPMessageImpl faultMessage = toSOAPMessage(faultEx);
/* 206 */       return faultMessage;
View Full Code Here

   
    public void throwSOAPFaultException(String faultString,
                                        SOAPMessage soapMessage)
        throws SOAPFaultException {

        SOAPFaultException sfe = null;

        try {

            SOAPPart sp = soapMessage.getSOAPPart();
            SOAPEnvelope se = sp.getEnvelope();

            // Consume the request
            SOAPBody sb = se.getBody();

            // Access the child elements of body
            Iterator iter = sb.getChildElements();

            // Response should only include the fault, so remove
            // any request body nodes.
            if (iter.hasNext()) {
                SOAPBodyElement requestBody = (SOAPBodyElement)iter.next();
                // detach this node from the tree
                requestBody.detachNode();
            }


            SOAPFault soapFault = sb.addFault();

            se.setEncodingStyle(SOAPConstants.URI_ENCODING);

            String faultActor = "http://schemas.xmlsoap.org/soap/actor/next";
            QName faultCode = SOAPConstants.FAULT_CODE_SERVER;

            soapFault.setFaultCode("env:" + faultCode.getLocalPart());
            soapFault.setFaultString(faultString);
            soapFault.setFaultActor(faultActor);

            sfe = new SOAPFaultException(faultCode, faultActor, faultString,
                                         null);
        } catch(SOAPException se) {
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, LogUtils.EXCEPTION_THROWN, se);
            }
View Full Code Here

    /**
     * Tests the defaults generated from a SOAPFaultException
     */
    public void testDefaults() {
        SOAPFaultException soapFaultException = new SOAPFaultException(null, null, null, null);

        AxisFault axisFault = AxisFault.makeFault(soapFaultException);

        assertEquals(QNAME_FAULT_SERVER_USER, axisFault.getFaultCode());
        assertNotNull(axisFault.getFaultString());
View Full Code Here

     */
    public void testMakeFaultOutOfSOAPFaultException() {

        QName faultcode = new QName(soapConsts.getEnvelopeURI(), "Server.MySubClass");

        SOAPFaultException soapFaultException = new SOAPFaultException(faultcode, "MyFaultString", "http://myactor", null);

        AxisFault axisFault = AxisFault.makeFault(soapFaultException);

        assertEquals(faultcode, axisFault.getFaultCode());
    }
View Full Code Here

    /**
     * Tests if SOAP fault details are passed to AxisFault objects
     */
    public void testDetails() {
        SOAPFaultException soapFaultException = new SOAPFaultException(QNAME_FAULT_SERVER_USER, "MyFaultString", "http://myactor", getTestDetail());

        AxisFault axisFault = AxisFault.makeFault(soapFaultException);

        assertNotNull(axisFault.getFaultDetails());

View Full Code Here

     * can throw an SOAPFaultException and all the information as faultcode and faultactor
     * is passed to the caller
     * @throws Exception
     */
    public void doSth() throws Exception {
        throw new SOAPFaultException(QNAME_FAULT_SERVER_USER, "MyFaultString", "http://myactor", getTestDetail());
    }
View Full Code Here

            }
        }
    }

    public SOAPFaultException getSOAPFaultException (WssSoapFaultException sfe) {
        return new SOAPFaultException(
            sfe.getFaultCode(),
            sfe.getFaultString(),
            sfe.getFaultActor(),
            sfe.getDetail());
    }
View Full Code Here

TOP

Related Classes of javax.xml.rpc.soap.SOAPFaultException

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.