Package javax.xml.soap

Examples of javax.xml.soap.SOAPFault


      // the SOAPFault so lets piece it together and
      // send it on it's way.
     
      try {
        SOAPBody soapResBody = soapRes.getSOAPBody();    
        SOAPFault soapFault = soapResBody.addFault();
        soapFault.setFaultCode(faultCode);
        soapFault.setFaultString(faultString);
        soapFault.setFaultActor(faultActor);
       
        // We're always going to include a DispositionReport (for
        // the hell of it) so that's what we're doing here.
      
        Detail faultDetail = soapFault.addDetail();
       
        SOAPElement dispRpt = faultDetail.addChildElement("dispositionReport","",IRegistry.UDDI_V2_NAMESPACE);       
        dispRpt.setAttribute("generic",IRegistry.UDDI_V2_GENERIC);
        dispRpt.setAttribute("operator",Config.getOperator());
       
View Full Code Here


            if (getBinding() instanceof HTTPBinding) {
                HTTPException exception = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR);
                exception.initCause(ex);
                throw exception;
            } else if (getBinding() instanceof SOAPBinding) {
                SOAPFault soapFault = createSoapFault((SOAPBinding)getBinding(), ex);
                if (soapFault == null) {
                    throw new WebServiceException(ex);
                }
                SOAPFaultException  exception = new SOAPFaultException(soapFault);
                if (ex instanceof Fault && ex.getCause() != null) {
View Full Code Here

            && (Future.class.equals(m.getReturnType())
                || Response.class.equals(m.getReturnType()));
    }
   
    static SOAPFault createSoapFault(SOAPBinding binding, Exception ex) throws SOAPException {
        SOAPFault soapFault;
        try {
            soapFault = binding.getSOAPFactory().createFault();
        } catch (Throwable t) {
            //probably an old version of saaj or something that is not allowing createFault
            //method to work.  Try the saaj 1.2 method of doing this.
            try {
                soapFault = binding.getMessageFactory().createMessage()
                    .getSOAPPart().getEnvelope().getBody().addFault();
            } catch (Throwable t2) {
                //still didn't work, we'll just throw what we have
                return null;
            }                       
        }
       
        if (ex instanceof SoapFault) {
            if (!soapFault.getNamespaceURI().equals(((SoapFault)ex).getFaultCode().getNamespaceURI())
                && SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE
                    .equals(((SoapFault)ex).getFaultCode().getNamespaceURI())) {
                //change to 1.1
                try {
                    soapFault = SAAJFactoryResolver.createSOAPFactory(null).createFault();
                } catch (Throwable t) {
                    //ignore
                }
            }
            soapFault.setFaultString(((SoapFault)ex).getReason());
            SAAJUtils.setFaultCode(soapFault, ((SoapFault)ex).getFaultCode());
            String role = ((SoapFault)ex).getRole();
            if (role != null) {
                soapFault.setFaultActor(role);
            }
            if (((SoapFault)ex).getSubCode() != null) {
                soapFault.appendFaultSubcode(((SoapFault)ex).getSubCode());
            }

            if (((SoapFault)ex).hasDetails()) {
                Node nd = soapFault.getOwnerDocument().importNode(((SoapFault)ex).getDetail(),
                                                                  true);
                nd = nd.getFirstChild();
                soapFault.addDetail();
                while (nd != null) {
                    Node next = nd.getNextSibling();
                    soapFault.getDetail().appendChild(nd);
                    nd = next;
                }
            }
        } else {
            String msg = ex.getMessage();
            if (msg != null) {
                soapFault.setFaultString(msg);
            }
        }     
        return soapFault;
    }
View Full Code Here

                        final String faultDetail = (String)body.get(Fault.DETAIL_DETAIL_CONTENT) ;

                        if (faultCode != null)
                        {
                            faultMsg = SOAP_MESSAGE_FACTORY.createMessage() ;
                            final SOAPFault fault = faultMsg.getSOAPBody().addFault(faultCode, faultDescription) ;
                            if (faultDetail != null)
                            {
                                try
                                {
                                    final Document detailDoc = parseAsDom(faultDetail) ;
                                    final Detail detail = fault.addDetail() ;
                                    detail.appendChild(detailDoc.getDocumentElement()) ;
                                }
                                catch (final Exception ex2)
                                {
                                    LOGGER.warn("Failed to parse fault detail", ex2) ;
View Full Code Here

                MessageFactory.newInstance();
        SOAPMessage msg = msgFactory.createMessage();
        SOAPEnvelope envelope =
                msg.getSOAPPart().getEnvelope();
        SOAPBody body = envelope.getBody();
        SOAPFault fault = body.addFault();

        fault.setFaultCode("Client");
        fault.setFaultString(
                "Message does not have necessary info");
        fault.setFaultActor("http://gizmos.com/order");

        Detail detail = fault.addDetail();

        Name entryName = envelope.createName("order", "PO",
                "http://gizmos.com/orders/");
        DetailEntry entry = detail.addDetailEntry(entryName);
        entry.addTextNode(
                "quantity element does not have a value");

        Name entryName2 = envelope.createName("confirmation",
                "PO", "http://gizmos.com/confirm");
        DetailEntry entry2 = detail.addDetailEntry(entryName2);
        entry2.addTextNode("Incomplete address: no zip code");

        msg.saveChanges();

        // Now retrieve the SOAPFault object and its contents
        //after checking to see that there is one

        if (body.hasFault()) {
            fault = body.getFault();
            String code = fault.getFaultCode();
            String string = fault.getFaultString();
            String actor = fault.getFaultActor();

            System.out.println("SOAP fault contains: ");
            System.out.println("    fault code = " + code);
            System.out.println("    fault string = " + string);
            if (actor != null) {
                System.out.println("    fault actor = " + actor);
            }

            detail = fault.getDetail();
            if (detail != null) {
                Iterator it = detail.getDetailEntries();
                while (it.hasNext()) {
                    entry = (DetailEntry) it.next();
                    String value = entry.getValue();
View Full Code Here

    throws IOException, XMLStreamException, JAXBException, SOAPException
  {
    Throwable fault = null;
    String message = null;
    String actor = null;
    SOAPFault soapFault = createSOAPFault();

    while (in.nextTag() == XMLStreamReader.START_ELEMENT) {
      if ("faultcode".equals(in.getLocalName())) {
        if (in.next() == XMLStreamReader.CHARACTERS) {
          String code = in.getText();
          int colon = code.indexOf(':');

          if (colon >= 0)
            code = code.substring(colon + 1);

          if ("Server".equalsIgnoreCase(code)) {
            // XXX Do anything with this?
          }
          else if ("Client".equalsIgnoreCase(code)) {
            // XXX Do anything with this?
          }
          else if ("VersionMismatch".equalsIgnoreCase(code)) {
            // XXX Do anything with this?
          }
          else if ("MustUnderstand".equalsIgnoreCase(code)) {
            // XXX Do anything with this?
          }

          soapFault.setFaultCode(code);
        }

        while (in.nextTag() != XMLStreamReader.END_ELEMENT) {}
      }
      else if ("faultstring".equals(in.getLocalName())) {
        if (in.next() == XMLStreamReader.CHARACTERS)
          message = in.getText();

        soapFault.setFaultString(message);

        while (in.nextTag() != XMLStreamReader.END_ELEMENT) {}
      }
      else if ("faultactor".equals(in.getLocalName())) {
        if (in.next() == XMLStreamReader.CHARACTERS)
          actor = in.getText();

        soapFault.setFaultActor(actor);

        while (in.nextTag() != XMLStreamReader.END_ELEMENT) {}
      }
      else if ("detail".equals(in.getLocalName())) {
        if (in.nextTag() == XMLStreamReader.START_ELEMENT) {
View Full Code Here

    }

    private void checkError() {
        if (error != null) {
            if (getBinding() instanceof SOAPBinding) {
                SOAPFault soapFault = null;
                try {
                    soapFault = JaxWsClientProxy.createSoapFault((SOAPBinding)getBinding(),
                                                                 new Exception(error.toString()));
                } catch (SOAPException e) {
                    //ignore
View Full Code Here

        if (getBinding() instanceof HTTPBinding) {
            HTTPException exception = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR);
            exception.initCause(ex);
            return exception;
        } else if (getBinding() instanceof SOAPBinding) {
            SOAPFault soapFault = null;
            try {
                soapFault = JaxWsClientProxy.createSoapFault((SOAPBinding)getBinding(), ex);
            } catch (SOAPException e) {
                //ignore
            }
View Full Code Here

    public GreetMeResponse greetMe(GreetMeRequest gmr) {
        if ("fault".equals(gmr.getName())) {
            try {
                SOAPFactory factory = SOAPFactory.newInstance();
                SOAPFault fault = factory.createFault("this is a fault string!",
                                                      new QName("http://foo", "FooCode"));
                fault.setFaultActor("mr.actor");
                fault.addDetail().addChildElement("test").addTextNode("TestText");
                throw new SOAPFaultException(fault);
            } catch (SOAPException ex) {
                throw new WebServiceException(ex);
            }
        } else if ("emptyfault".equals(gmr.getName())) {
View Full Code Here

            }
           
            XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);

            if (hasFault(message, xmlReader)) {
                SOAPFault soapFault =
                    soapMessage.getSOAPPart().getEnvelope().getBody().addFault();
                SoapFault fault =
                    message.getVersion() instanceof Soap11
                    ? Soap11FaultInInterceptor.unmarshalFault(message, xmlReader)
                    : Soap12FaultInInterceptor.unmarshalFault(message, xmlReader);
                if (fault.getFaultCode() != null) {
                    soapFault.setFaultCode(fault.getFaultCode());
                }
                if (fault.getMessage() != null) {
                    soapFault.setFaultString(fault.getMessage());
                }
                if (fault.getRole() != null) {
                    soapFault.setFaultActor(fault.getRole());
                }
                if (fault.getDetail() != null
                    && fault.getDetail().getFirstChild() != null) {
                   
                    Detail detail = null;
                    Node child = fault.getDetail().getFirstChild();
                    while (child != null) {
                        if (Node.ELEMENT_NODE == child.getNodeType()) {
                            if (detail == null) {
                                detail = soapFault.addDetail();
                            }
                            Node importedChild = soapMessage.getSOAPPart().importNode(child, true);
                            detail.appendChild(importedChild);
                        }
                        child = child.getNextSibling();
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.