[ 
http://issues.apache.org/jira/browse/AXIS2-917?page=comments#action_12434048 ] 
            
Davanum Srinivas commented on AXIS2-917:
----------------------------------------

Ok William.  Let me give you the example that you can try and flesh out for our 
documentation.

1) Get the bank.wsdl, which is deep inside the ws-tip-jacrpc.ear example from 
http://www-128.ibm.com/developerworks/xml/library/ws-tip-jaxrpc.html
2) Generate the server side code with "-ss -sd" in a separate directory for the 
server side sample.
3) In the generated BankServiceSkeleton.java implement the withdraw method:

    public example.WithdrawResponse withdraw(example.Withdraw param0)
            throws 
example.BankServiceSkeleton.InsufficientFundFaultMessageException, 
example.BankServiceSkeleton.AccountNotExistFaultMessageException {
        String account = param0.getAccount();
        if (account.equals("13")) {
            AccountNotExistFault fault = new AccountNotExistFault();
            throw new AccountNotExistFaultMessageException("Account does not 
exist!", fault);
        }
        InsufficientFundFault fault = new InsufficientFundFault();
        InsufficientFundFaultType faultType = new InsufficientFundFaultType();
        faultType.setBalance(1000);
        faultType.setRequestedFund(2000);
        fault.setInsufficientFundFault(faultType);
        throw new InsufficientFundFaultMessageException("Insufficient funds", 
fault);
    }

4) build the aar and deploy it.
5) Generate a client from the wsdl of the deployed service.
6) Test it using the following snippet:

        try {
            BankServiceStub stub = new BankServiceStub();
            Withdraw param4 = new Withdraw();
            param4.setAccount("13");
            param4.setAmount(34355);
            stub.withdraw(param4)
        } catch (BankServiceStub.AccountNotExistFaultMessageException e) {
            System.out.println(e.getFaultMessage());
        } catch (BankServiceStub.InsufficientFundFaultMessageException e) {
            System.out.println(e.getFaultMessage());
        } catch (RemoteException e) {
            e.printStackTrace();  
        } catch (Exception e) {
            e.printStackTrace(); 
        }

if you sent 13 as the account #, then you will get a AccountNotExistFault. Any 
other account #, you will get a InsufficientFundFaultMessageException. 

thanks,
dims

> User guide should give explanation and examples of fault handling
> -----------------------------------------------------------------
>
>                 Key: AXIS2-917
>                 URL: http://issues.apache.org/jira/browse/AXIS2-917
>             Project: Apache Axis 2.0 (Axis2)
>          Issue Type: Wish
>          Components: samples, build,site  & docs
>    Affects Versions: 1.0
>            Reporter: Derek Foster
>         Assigned To: Eran Chinthaka
>            Priority: Blocker
>         Attachments: sampleService-wsdl.rar
>
>
> The Axis2 user guide provides no examples of:
>   1) The WSDL to declare that a fault may be thrown from an operation 
> (suitable for passing into WSDL2Java)
>   2) The server-side code for a fault exception, as generated by WSDL2Java 
> and modified as a user might be expected to modify it.
>   3) The server-side code to throw the fault exception, including a tested 
> example of passing on a custom error message to be transmitted as part of a 
> SOAP fault (in the faultDetail) and received by the client.
>   4) The client-side code for receiving and handling a fault.
> Furthermore, what discussion of faults that there is seems fairly 
> contradictory. For instance, there are various suggestions that throwing an 
> AxisFault exception from a service is the way to issue a fault. However, 
> WSDL2Java does not generate service methods that are declared to throw 
> AxisFault, and there seems to be no way to declare such a fault in WSDL. (at 
> least, none that I can find). Fault generation from a service that was not 
> generated by WSDL2Java should be treated as a separate section, since it is 
> handled in a totally different manner by server code. I think that both kinds 
> of fault handling need to be documented clearly in the user guide.
> I have been trying for weeks to figure out how this is supposed to work, and 
> still haven't gotten it to work quite right (my custom error message included 
> in the thrown fault exception is getting lost somewhere before the SOAP fault 
> is transmitted). This is a basic feature that should be documented clearly.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to