cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Pederson (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (CXF-1434) Better Fault handling demo
Date Mon, 19 Apr 2010 18:27:51 GMT

    [ https://issues.apache.org/jira/browse/CXF-1434?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12858373#action_12858373
] 

Eric Pederson edited comment on CXF-1434 at 4/19/10 2:26 PM:
-------------------------------------------------------------

My bad - you can set the faultcode and/or detail using org.apache.cxf.interceptor.Fault. 
 The detail will not appear in the WSDL.    To get the detail in the WSDL you need to use
@WebFault and a Java static inner class faultbean.

      var f = new Fault(new AuthorizationError("Error - Missing apiKey"), Fault.FAULT_CODE_CLIENT)
      var element = f.getOrCreateDetail().getOwnerDocument().createElementNS("http://ws.nyx.com",
"ae:errorCode")
      element.setTextContent("MissingApiKey");
      f.getDetail().appendChild(element)
      throw f

results in this response:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>Error - Missing apiKey</faultstring>
         <detail>
            <ae:errorCode xmlns:ae="http://ws.nyx.com">MissingApiKey</ae:errorCode>
            <ns1:AuthorizationError xmlns:ns1="http://ws.nyx.com/"/>
         </detail>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

      was (Author: ericacm):
          var f = new Fault(new AuthorizationError("Error - Missing apiKey"), Fault.FAULT_CODE_CLIENT)
      var element = f.getOrCreateDetail().getOwnerDocument().createElementNS("http://ws.nyx.com",
"ae:errorCode")
      element.setTextContent("MissingApiKey");
      f.getDetail().appendChild(element)
      throw f

results in this response:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>Error - Missing apiKey</faultstring>
         <detail>
            <ae:errorCode xmlns:ae="http://ws.nyx.com">MissingApiKey</ae:errorCode>
            <ns1:AuthorizationError xmlns:ns1="http://ws.nyx.com/"/>
         </detail>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>
  
> Better Fault handling demo
> --------------------------
>
>                 Key: CXF-1434
>                 URL: https://issues.apache.org/jira/browse/CXF-1434
>             Project: CXF
>          Issue Type: Wish
>          Components: Samples
>         Environment: this should run on any servlet container. Java >= 5
>            Reporter: David Castaneda
>            Priority: Minor
>         Attachments: CXFTest.rar, java_first_spring_support_fault.tar, java_first_spring_support_faults.zip
>
>
> Sample application showing how to create custom Soap Faults.
> The target is to show a functional example of how to transform Exceptions (Checked and
Unchecked) to SoapFaults, that can contain Server or Client fault and a custom detail part.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message