Package javax.xml.soap

Examples of javax.xml.soap.SOAPFault


            }

            SOAPMessageContext soapContext = SOAPMessageContext.class.cast(context);
            SOAPMessage soapMessage = soapContext.getMessage();

            SOAPFault fault = soapMessage.getSOAPBody().getFault();
            DataReader<SOAPFault> reader = callback.createReader(SOAPFault.class);

            Object faultObj = null;
            if (null != reader) {
                LOG.log(Level.INFO, "SOAP_FAULT_NO_READER");
                faultObj = reader.read(null, 0, fault);
            }
            if (null == faultObj) {
                LOG.log(Level.INFO, "SOAP_FAULT_UNMARSHALLING_MSG", fault.getElementQName().toString());
                faultObj = new SOAPFaultException(fault);
            }
           
            objContext.setException((Throwable)faultObj);
        } catch (SOAPException se) {
View Full Code Here


    }
   
    public static SOAPFaultException createSOAPFaultEx(SOAPFactory soapFactory,
                                                       QName faultCode,
                                                       String message) {
        SOAPFault sf = null;
        try {
            sf = soapFactory.createFault();
            sf.setFaultCode(faultCode);
            sf.setFaultString(message);           
        } catch (SOAPException se) {
            se.printStackTrace();           
        }
        return new SOAPFaultException(sf);
    }
View Full Code Here

  private void serializeProtocolException()
    throws WebServiceException
  {
    if (_protocolException instanceof SOAPFaultException) {
      SOAPFaultException sfe = (SOAPFaultException) _protocolException;
      SOAPFault fault = sfe.getFault();

      try {
        MessageFactory factory = _soapContext.getMessageFactory();
        SOAPMessage message = factory.createMessage();
        message.getSOAPBody().addChildElement(fault);
View Full Code Here

        try {
            handlerTest.pingWithArgs("soapHandler3 inbound throw SOAPFaultExceptionWDetail");
            fail("did not get expected SOAPFaultException");
        } catch (SOAPFaultException e) {
            assertEquals("HandleMessage throws exception", e.getMessage());
            SOAPFault fault = e.getFault();
            assertNotNull(fault);
            assertEquals(new QName(SOAPConstants.URI_NS_SOAP_ENVELOPE, "Server"),
                         fault.getFaultCodeAsQName());
            assertEquals("http://gizmos.com/orders", fault.getFaultActor());
           
            Detail detail = fault.getDetail();
            assertNotNull(detail);
           
            QName nn = new QName("http://gizmos.com/orders/", "order");
            Iterator<Element> it = CastUtils.cast(detail.getChildElements(nn));
            assertTrue(it.hasNext());
View Full Code Here

       
        SOAPPart part = (SOAPPart)nd;
        assertEquals("S", part.getEnvelope().getPrefix());
        assertEquals("S2", part.getEnvelope().getHeader().getPrefix());
        assertEquals("S3", part.getEnvelope().getBody().getPrefix());
        SOAPFault fault = part.getEnvelope().getBody().getFault();
        assertEquals("S", fault.getPrefix());
       
        assertEquals("Authentication Failure", fault.getFaultString());
       
        SoapFault fault2 = (SoapFault)m.getContent(Exception.class);
        assertNotNull(fault2);
       
        assertEquals(Soap12.getInstance().getSender(), fault2.getFaultCode());
View Full Code Here

                        part.getEnvelope().addHeader();
                    }
                    setChild(adjustPrefix(part.getEnvelope().getHeader(), prefix), false);
                    return;
                } else if ("Fault".equals(local)) {
                    SOAPFault f = part.getEnvelope().getBody().getFault();
                    if (f == null) {
                        Element el = part.createElementNS(namespace,
                                             StringUtils.isEmpty(prefix) ? local : prefix + ":" + local);
                        part.getEnvelope().getBody().appendChild(el);
                        f = part.getEnvelope().getBody().getFault();
                        if (f == null) {
                            f = part.getEnvelope().getBody().addFault();
                        }
                    }
                    setChild(adjustPrefix(f, prefix), false);
                    return;
                }
            } else if (getCurrentNode() instanceof SOAPFault) {
                SOAPFault f = (SOAPFault)getCurrentNode();
                Node nd = f.getFirstChild();
                while (nd != null) {
                    if (nd instanceof Element) {
                        Element el = (Element)nd;
                        if (local.equals(nd.getLocalName())) {
                            setChild(el, false);
View Full Code Here

            faultStringLocale = null;
        }
        try {
          getSaajBody().removeContents();
          SOAPBody body = getSaajBody();
          SOAPFault result;
          if (faultStringLocale == null) {
            result = body.addFault(faultCode, faultString);
          }
          else {
            result = body.addFault(faultCode, faultString, faultStringLocale);
          }
          SOAPFault saajFault = result;
            return new SaajSoap11Fault(saajFault);
        }
        catch (SOAPException ex) {
            throw new SaajSoapFaultException(ex);
        }
View Full Code Here

        endpoint.invoke(messageContext);

        SOAPMessage response = ((SaajSoapMessage) messageContext.getResponse()).getSaajMessage();
        Assert.assertTrue("Response has no fault", response.getSOAPBody().hasFault());
        SOAPFault fault = response.getSOAPBody().getFault();
        Assert.assertEquals("Invalid fault code", new QName("http://schemas.xmlsoap.org/soap/envelope/", "Client"),
                fault.getFaultCodeAsQName());
        Assert.assertEquals("Invalid fault string", endpoint.getFaultStringOrReason(), fault.getFaultString());
        Detail detail = fault.getDetail();
        Assert.assertNotNull("No detail", detail);
        Iterator<?> iterator = detail.getDetailEntries();
        Assert.assertTrue("No detail entry", iterator.hasNext());
        DetailEntry detailEntry = (DetailEntry) iterator.next();
        Assert.assertEquals("Invalid detail entry name",
View Full Code Here

        super(body);
    }

    @Override
    public Soap12Fault getFault() {
      SOAPFault fault = getSaajBody().getFault();
        return fault != null ? new SaajSoap12Fault(fault) : null;
    }
View Full Code Here

        Assert.hasLength(faultCode.getLocalPart(), "faultCode's localPart cannot be empty");
        Assert.hasLength(faultCode.getNamespaceURI(), "faultCode's namespaceUri cannot be empty");
        try {
          getSaajBody().removeContents();
          SOAPBody body = getSaajBody();
          SOAPFault result;
          if (faultStringLocale == null) {
            result = body.addFault(faultCode, faultString);
          }
          else {
            result = body.addFault(faultCode, faultString, faultStringLocale);
          }
          SOAPFault saajFault = result;
            return new SaajSoap12Fault(saajFault);
        }
        catch (SOAPException ex) {
            throw new SaajSoapFaultException(ex);
        }
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.