Package javax.xml.rpc.soap

Examples of javax.xml.rpc.soap.SOAPFaultException


         return res;

      }
      catch (SubscriptionError e)
      {
         throw new SOAPFaultException(buildFaultQName(e.getSubcode()), e.getReason(), null, null);
      }
   }
View Full Code Here


    * Namely NotifyTo and EndTo need to be set.
    * @param request
    */
   private void assertSubscriberEndpoints(Subscribe request) {
      if(null == request.getDelivery().getNotifyTo() ||  null == request.getEndTo() )
         throw new SOAPFaultException( buildFaultQName(EventingConstants.CODE_INVALID_MESSAGE) ,
            "Subcriber endpoint information missing from request",
            null, null
         );
   }
View Full Code Here

         return response;
      }
      catch (SubscriptionError e)
      {
         throw new SOAPFaultException(buildFaultQName(e.getSubcode()), e.getReason(), null, null);
      }
   }
View Full Code Here

         return response;
      }
      catch (SubscriptionError e)
      {
         throw new SOAPFaultException(buildFaultQName(e.getSubcode()), e.getReason(), null, null);
      }
   }
View Full Code Here

      {
         getSubscriptionManager().unsubscribe(identifier);
      }
      catch (SubscriptionError e)
      {
         throw new SOAPFaultException(buildFaultQName(e.getSubcode()), e.getReason(), null, null);
      }

   }
View Full Code Here

      CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
      AddressingProperties addrProps = (AddressingProperties)msgContext.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND);

      if (null == addrProps)
      {
         throw new SOAPFaultException(
            Constants.SOAP11_FAULT_CODE_CLIENT,
            "The message is not valid and cannot be processed: " +
               "Cannot obtain addressing properties.",
            null, null
         );
      }

      ReferenceParameters refParams = addrProps.getReferenceParameters();
      if (refParams != null)
      {
         for (Object obj : refParams.getElements())
         {
            if (obj instanceof Element)
            {
               Element el = (Element)obj;
               QName qname = DOMUtils.getElementQName(el);
               if (qname.equals(IDQN))
               {
                  try
                  {
                     subscriptionId = new URI(DOMUtils.getTextContent(el));
                     break;
                  }
                  catch (URISyntaxException e)
                  {
                     throw new SOAPFaultException(
                        Constants.SOAP11_FAULT_CODE_CLIENT,
                        "The message is not valid and cannot be processed: " +
                           "Invalid subscription id.",
                        null, null
                     );
                  }
               }
            }
         }
      }

      if (null == subscriptionId)
      {
         throw new SOAPFaultException(
            buildFaultQName(EventingConstants.CODE_INVALID_MESSAGE),
            "The message is not valid and cannot be processed: "
               + "Cannot obtain subscription id.",
            null, null
         );
View Full Code Here

      QName faultCode = ((NameImpl)soapFault.getFaultCodeAsName()).toQName();
      String faultString = soapFault.getFaultString();
      String faultActor = soapFault.getFaultActor();
      Detail detail = soapFault.getDetail();

      SOAPFaultException faultEx = new SOAPFaultException(faultCode, faultString, faultActor, detail);

      CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
      if (detail != null && msgContext != null)
      {
         SerializationContext serContext = msgContext.getSerializationContext();
         TypeMapping typeMapping = serContext.getTypeMapping();

         Iterator it = detail.getDetailEntries();
         while (it.hasNext())
         {
            DetailEntry deElement = (DetailEntry)it.next();
            Name deName = deElement.getElementName();
            QName xmlName = new QName(deName.getURI(), deName.getLocalName());

            OperationMetaData opMetaData = msgContext.getOperationMetaData();
            FaultMetaData faultMetaData = opMetaData.getFault(xmlName);
            if (faultMetaData != null)
            {
               if (log.isDebugEnabled())
                  log.debug("Deserialize fault: " + faultMetaData);
               QName xmlType = faultMetaData.getXmlType();
               Class javaType = faultMetaData.getJavaType();

               // Get the deserializer from the type mapping
               AbstractDeserializerFactory desFactory = (AbstractDeserializerFactory)typeMapping.getDeserializer(javaType, xmlType);
               if (desFactory == null)
                  throw new JAXRPCException("Cannot obtain deserializer factory for: " + xmlType);

               // Try jaxb deserialization
               try
               {
                  // http://jira.jboss.org/jira/browse/JBWS-955
                  // Cannot deserialize fault detail
                  String prefix = deName.getPrefix();
                  if (prefix.length() > 0)
                  {
                     String nsURI = deName.getURI();
                     String attrValue = deElement.getAttribute("xmlns:" + prefix);
                     if (nsURI.length() > 0 && attrValue.length() == 0)
                        deElement.addNamespaceDeclaration(prefix, nsURI);
                  }

                  Source xmlFragment = new DOMSource(deElement);
                  DeserializerSupport des = (DeserializerSupport)desFactory.getDeserializer();
                  Object userEx = des.deserialize(xmlName, xmlType, xmlFragment, serContext);
                  if (userEx == null || (userEx instanceof Exception) == false)
                     throw new WSException("Invalid deserialization result: " + userEx);

                  faultEx.initCause((Exception)userEx);
               }
               catch (RuntimeException rte)
               {
                  throw rte;
               }
View Full Code Here

   /** Translate the request exception into a SOAPFault message.
    */
   public static SOAPMessageImpl exceptionToFaultMessage(Exception reqEx)
   {
      // Get or create the SOAPFaultException
      SOAPFaultException faultEx;
      if (reqEx instanceof SOAPFaultException)
      {
         faultEx = (SOAPFaultException)reqEx;
      }
      else if (reqEx instanceof CommonSOAPFaultException)
      {
         CommonSOAPFaultException soapEx = (CommonSOAPFaultException)reqEx;
         QName faultCode = soapEx.getFaultCode();
         String faultString = soapEx.getFaultString();
         Throwable cause = soapEx.getCause();
         faultEx = new SOAPFaultException(faultCode, faultString, null, null);
         faultEx.initCause(cause);
      }
      else
      {
         QName faultCode;
         if (isSOAP12() == false)
         {
            faultCode = Constants.SOAP11_FAULT_CODE_SERVER;
         }
         else
         {
            faultCode = SOAPConstants.SOAP_RECEIVER_FAULT;
         }
         String faultString = (reqEx.getMessage() != null ? reqEx.getMessage() : reqEx.toString());
         faultEx = new SOAPFaultException(faultCode, faultString, null, null);
         faultEx.initCause(reqEx);
      }

      Throwable faultCause = faultEx.getCause();
      log.error("SOAP request exception", faultCause != null ? faultCause : faultEx);

      try
      {
         SOAPMessageImpl faultMessage = toSOAPMessage(faultEx);
View Full Code Here

   private void handleException(Exception ex) throws Throwable
   {
      Throwable th = ex;
      if (ex instanceof RemoteException && ex.getCause() instanceof SOAPFaultException)
      {
         SOAPFaultException faultEx = (SOAPFaultException)ex.getCause();
         if (faultEx.getCause() != null)
            th = faultEx.getCause();
      }
      throw th;
   }
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

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.