Package javax.xml.soap

Examples of javax.xml.soap.SOAPFault


          
           SOAPBody soapBody = soapResponse.getSOAPBody();
           boolean hasFault = soapBody.hasFault();
           if(hasFault)
           {
              SOAPFault soapFault = soapBody.getFault();
              String faultStr = soapFault.getFaultCode() + "::" + soapFault.getFaultString();
              throw new RegistryException(faultStr);
           }
           response = getFirstChildElement(soapBody);
        } catch (Exception ex)
        {
View Full Code Here


          
           SOAPBody soapBody = soapResponse.getSOAPBody();
           boolean hasFault = soapBody.hasFault();
           if(hasFault)
           {
              SOAPFault soapFault = soapBody.getFault();
              String faultStr = soapFault.getFaultCode() + "::" + soapFault.getFaultString();
              throw new RegistryException(faultStr);
           }
           response = getFirstChildElement(soapBody);
        } catch (Exception ex)
        {
View Full Code Here

            else if (body != null && body.hasFault()) {
                if (log.isDebugEnabled()) {
                  log.debug("A fault was found.  Converting the fault child elements to SOAP 1.1 format");
                }
             
              SOAPFault fault = body.getFault();
               
                Iterator itr = fault.getChildElements();
                while (itr.hasNext()) {
                    SOAPElement se = (SOAPElement) itr.next();
                    if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME)) {
                      if (log.isDebugEnabled()) {
                        log.debug("Converting: faultcode");
                      }
                      // Axis2 SAAJ stores the acutal faultcode text under a SOAPFaultValue object, so we have to
                        // get that and add it as a text node under the original element.
                        Node value = se.getFirstChild();
                        if (value != null && value instanceof org.apache.axis2.saaj.SOAPElementImpl) {
                            org.apache.axis2.saaj.SOAPElementImpl<?> valueElement = (org.apache.axis2.saaj.SOAPElementImpl<?>) value;
                            OMElement e = valueElement.getOMTarget();
                            String content = e.getText();
                           
                            SOAPElement child = fault.addChildElement(new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_CODE_LOCAL_NAME));
                            child.addTextNode(content);
                           
                            se.detachNode();
                        }
                    }
                    else if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)) {
                      if (log.isDebugEnabled()) {
                        log.debug("Converting: detail");
                      }
                        se.setElementQName(new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_DETAIL_LOCAL_NAME));
                    }
                    else if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME)) {
                      if (log.isDebugEnabled()) {
                        log.debug("Converting: faultstring");
                      }
                        se.setElementQName(new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME));
                        // Axis2 SAAJ stores the acutal faultstring text under a SOAPFaultValue object, so we have to
                        // get that and add it as a text node under the original element.
                        Node value = se.getFirstChild();
                        if (value != null && value instanceof org.apache.axis2.saaj.SOAPElementImpl) {
                            org.apache.axis2.saaj.SOAPElementImpl<?> valueElement = (org.apache.axis2.saaj.SOAPElementImpl<?>) value;
                            OMElement e = valueElement.getOMTarget();
                            String content = e.getText();
                          
                            SOAPElement child = fault.addChildElement(new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME));
                            child.addTextNode(content);
                           
                            se.detachNode();
                        }
                    }
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

                // some unimplemented methods in the Axis2 SAAJ implementation
                XMLFault xmlFault = MethodMarshallerUtils.createXMLFaultFromSystemException(e);
                javax.xml.soap.MessageFactory mf = SAAJFactory.createMessageFactory(protocolNS);
                SOAPMessage message = mf.createMessage();
                SOAPBody body = message.getSOAPBody();
                SOAPFault soapFault = XMLFaultUtils.createSAAJFault(xmlFault, body);

                MessageFactory msgFactory = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
                Message msg = msgFactory.createFrom(message);
                mepCtx.setMessage(msg);
View Full Code Here

                    log.debug("Marshal SOAPFaultException");
                }
                // Category C: SOAPFaultException
                // Construct the xmlFault from the SOAPFaultException's Fault
                SOAPFaultException sfe = (SOAPFaultException)t;
                SOAPFault soapFault = sfe.getFault();
                if (soapFault == null) {
                    // No fault ?  I will treat this like category E
                    xmlfault =
                        new XMLFault(null,       // Use the default XMLFaultCode
                                     new XMLFaultReason(
View Full Code Here

            try {
                // The following set of instructions is used to avoid
                // some unimplemented methods in the Axis2 SAAJ implementation
                javax.xml.soap.MessageFactory mf = SAAJFactory.createMessageFactory(protocolNS);
                SOAPBody body = mf.createMessage().getSOAPBody();
                SOAPFault soapFault = XMLFaultUtils.createSAAJFault(xmlFault, body);
                e = new SOAPFaultException(soapFault);
            } catch (Exception ex) {
                // Exception occurred during exception processing.
                // TODO Probably should do something better here
                if (log.isDebugEnabled()) {
View Full Code Here

      SOAPMessage soapResponse = messageFactory.createMessage();
      soapBody = soapResponse.getSOAPBody();
     
      if (authResponse == null)
      {
        SOAPFault fault = soapBody.addFault();
        fault.setFaultString("Missing authetication data");
        return soapResponse;
       
      } else if (!authResponse.isReturn())
      {
        SOAPFault fault = soapBody.addFault();
        fault.setFaultString("Failed authentication");
        return soapResponse;
      }
       
      if (responsePojo != null) {
        JAXB.marshal(responsePojo, new SAAJResult(soapBody));
      } else {
        SOAPFault fault = soapBody.addFault();
        fault.setFaultString("Unrecognized SOAP request.");
      }
      return soapResponse;
    }
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()
                    .getSOAPBody().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());
            soapFault.setFaultCode(((SoapFault)ex).getFaultCode());
            String role = ((SoapFault)ex).getRole();
            if (role != null) {
                soapFault.setFaultActor(role);
            }
            if (((SoapFault)ex).getSubCodes() != null
                && !SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(soapFault.getNamespaceURI())) {
                // set the subcode only if it is supported (e.g, 1.2)
                for (QName fsc : ((SoapFault)ex).getSubCodes()) {
                    soapFault.appendFaultSubcode(fsc);   
                }
            }

            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

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.