Package javax.xml.soap

Examples of javax.xml.soap.SOAPFault


       * Step 4.1: If message is fault message, set status to false and send fault information.
       */
      if (message.isFault()) {
        // Access SOAP fault.
        try {
          SOAPFault faultObj = message.readAsSOAPMessage().getSOAPBody().getFault();
          HashMap<String,Object> detail = new HashMap<String, Object>();
          try {
            fillChildElementInfo(faultObj.getDetail().getChildNodes(),4,detail);
          } catch(Throwable th){/*Dont mind about custom message set fail*/}
          responseJSONMap.put(FAULT,new JSONFault(faultObj.getFaultCodeAsQName().getLocalPart().toUpperCase(),
              faultObj.getFaultString(),faultObj.getFaultActor(),detail));
         
        } catch (SOAPException e) {
          LOG.log(Level.WARNING, "Failed to read soap fault message", e);
          responseJSONMap.put(FAULT, new JSONFault("Server.json",
              "Failed to read soap fault message","Codec",null));
View Full Code Here


                                                        String prefix,
                                                        String namespace,
                                                        String reason)
        throws SOAPException {
        SOAPFactory factory = getSOAPFactory();
        SOAPFault fault = factory.createFault();
        Name qname = factory.createName(localName, prefix, namespace);
        fault.setFaultCode(qname);
        fault.setFaultString(reason);
        return new SOAPFaultException(fault);
    }
View Full Code Here

        assertNotNull(xmlNode);
        assertEquals(1, xmlNode.getChildNodes().getLength());
       
        assertTrue(msg.getSOAPBody().hasFault());
       
        SOAPFault fault = msg.getSOAPBody().getFault();
        assertNotNull(fault);
        assertTrue(fault.hasChildNodes());
       
        //For Celtix Runtime Exceptions - SOAPFault will not have a Detail Node
        Detail detail = fault.getDetail();
        if (detail != null) {
            assertFalse("Detail should be non-existent or empty", detail.hasChildNodes());
        }
    }
View Full Code Here

                              String faultString) throws Exception {
       
        SOAPMessage msg = MessageFactory.newInstance().createMessage(null,  bais);
        assertNotNull(msg);
        assertTrue(msg.getSOAPBody().hasFault());
        SOAPFault fault = msg.getSOAPBody().getFault();
        assertNotNull(fault);
       
        StringBuffer str = new StringBuffer(clazz.getName());
        str.append(": ");
        str.append(faultString);
        assertEquals(str.toString(), fault.getFaultString());
        assertTrue(fault.hasChildNodes());
        Detail detail = fault.getDetail();
        assertNotNull(detail);
       
        NodeList list = detail.getChildNodes();
        assertEquals(1, list.getLength());
       
View Full Code Here

        inCtx.setInputStream(is);
        try {
            binding.read(inCtx, soapContext);
            fail("Should have received a SOAP FaultException");
        } catch (SOAPFaultException sfe) {
            SOAPFault sf = sfe.getFault();
            assertNotNull("Should have a non null soap fault", sf);
            assertEquals(SOAPConstants.FAULTCODE_VERSIONMISMATCH, sf.getFaultCodeAsQName());
        }
    }
View Full Code Here

        assertNotNull(msg);
        Node xmlNode = msg.getSOAPBody();
        assertNotNull(xmlNode);
        assertEquals(1, xmlNode.getChildNodes().getLength());
        assertTrue(msg.getSOAPBody().hasFault());
        SOAPFault fault = msg.getSOAPBody().getFault();
        assertNotNull(fault);
        assertEquals(
                     getExceptionString(ex, exMessage),
                     fault.getFaultString());
        assertTrue(fault.hasChildNodes());
        Detail detail = fault.getDetail();
        assertNotNull(detail);
       
        NodeList list = detail.getChildNodes();
        assertEquals(1, list.getLength());
       
View Full Code Here

        Node xmlNode = msg.getSOAPBody();
        assertNotNull(xmlNode);
        assertEquals(1, xmlNode.getChildNodes().getLength());

        assertTrue(msg.getSOAPBody().hasFault());
        SOAPFault fault = msg.getSOAPBody().getFault();
        assertNotNull(fault);
        assertEquals(
                     getExceptionString(se, se.getMessage()),
                     fault.getFaultString());
        assertTrue(fault.hasChildNodes());
        NodeList list = fault.getChildNodes();
        assertEquals(2, list.getLength());        
    }
View Full Code Here

        assertNotNull(objContext.getException());
        faultEx = objContext.getException();
        assertTrue("Should be a SOAPFaultException",
                   SOAPFaultException.class.isAssignableFrom(faultEx.getClass()));
        SOAPFaultException sfe = (SOAPFaultException)faultEx;
        SOAPFault sf = sfe.getFault();
        assertNotNull(sf);
    }
View Full Code Here

   
    public SOAPFaultDataReader(JAXBDataBindingCallback cb) {
        callback = cb;
    }
    public Object read(QName name, int idx, T input) {
        SOAPFault fault = (SOAPFault)input;
        if (fault.getDetail() != null) {
            NodeList list = fault.getDetail().getChildNodes();

            QName faultName;
            for (int i = 0; i < list.getLength(); i++) {
                Node entry = list.item(i);
                if (entry.getNodeType() != Node.ELEMENT_NODE) {
                    continue;
                }
               
                faultName = new QName(entry.getNamespaceURI(),
                                      entry.getLocalName());
       
                Class<?> clazz = callback.getWebFault(faultName);
                try {
                    if (clazz != null) {
                        Class<?> faultInfo = clazz.getMethod("getFaultInfo").getReturnType();
                        Object obj = JAXBEncoderDecoder.unmarshall(callback.getJAXBContext(),
                                                                   callback.getSchema(),
                                                                   entry,
                                                                   faultName,
                                                                   faultInfo);
                        Constructor<?> ctor = clazz.getConstructor(String.class,
                                                                   obj.getClass());
                        return ctor.newInstance(fault.getFaultString(), obj);
                    }
                } catch (Exception ex) {
                    throw new WebServiceException("error in unmarshal of SOAPFault", ex);
                }
            }
View Full Code Here

                        str.append(s.toString());
                        str.append("\n");
                    }
                }

                SOAPFault fault = msg.getSOAPBody().addFault(faultCode, str.toString());

                DataWriter<Detail> writer = callback.createWriter(Detail.class);
                if (writer != null) {
                    writer.write(t, fault.addDetail());
                    if (!fault.getDetail().hasChildNodes()) {
                        fault.removeChild(fault.getDetail());
                    }
                }
            }
        } catch (SOAPException se) {
            LOG.log(Level.SEVERE, "FAULT_MARSHALLING_FAILURE_MSG", se);
View Full Code Here

TOP

Related Classes of javax.xml.soap.SOAPFault

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.