[
https://issues.apache.org/jira/browse/AXIS2C-1344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dimuthu Gamage updated AXIS2C-1344:
-----------------------------------
Attachment: case45.zip
Fixed (in commit 741901). attached a test case. The idea is taken from the
discussion http://www.biglist.com/lists/xsl-list/archives/200311/msg00604.html
API Explanation,
Server Side:
If faults are associated with a method, the faults are put in a union and users
are expected to set one in a fault case, in the last parameter of the function.
typedef union
{
adb_MyFirstException_t* MyFirstException;
adb_MySecondException_t* MySecondException;
} axis2_skel_MyService_myNextOperation_fault;
adb_myNextOperationResponse_t*
axis2_skel_MyService_myNextOperation(const axutil_env_t *env,
adb_myNextOperation_t*
_myNextOperation,
axis2_skel_MyService_myNextOperation_fault *fault);
And constants corrosponding to the faults are also generated,
#define AXIS2_SKEL_MYSERVICE_ERROR_CODES_START (AXIS2_ERROR_LAST + 2000)
typedef enum
{
AXIS2_SKEL_MYSERVICE_ERROR_NONE =
AXIS2_SKEL_MYSERVICE_ERROR_CODES_START,
AXIS2_SKEL_MYSERVICE_MYNEXTOPERATION_FAULT_MYFIRSTEXCEPTION,
AXIS2_SKEL_MYSERVICE_MYNEXTOPERATION_FAULT_MYSECONDEXCEPTION,
AXIS2_SKEL_MYSERVICE_MYOPERATION_FAULT_MYFIRSTEXCEPTION,
AXIS2_SKEL_MYSERVICE_MYOPERATION_FAULT_MYSECONDEXCEPTION,
AXIS2_SKEL_MYSERVICE_ERROR_LAST
} axis2_skel_MyService_error_codes;
So in a fault case, user can write a code similar to the following to throw the
custom soap fault (note that they have to set both the adb fault object and the
error constant)
adb_MyFirstException_t *exp = NULL;
exp = adb_MyFirstException_create(env);
adb_MyFirstException_set_text(exp, env, "this is the exception 3");
/* here we are setting the exception, the fault is the last
parameter of the method definition */
fault->MyFirstException = exp;
AXIS2_ERROR_SET(env->error,
AXIS2_SKEL_MYSERVICE_MYNEXTOPERATION_FAULT_MYFIRSTEXCEPTION,
AXIS2_FAILURE);
axutil_error_set_error_message(env->error, "Test exception3");
return NULL;
client side:
Similar to the server side, both the unions and enum of constants are
generated. Here is how user should handle the soap faults,
/* doing the request */
op_response = axis2_stub_op_MyService_myOperation(stub, env, op, &fault);
if(op_response == NULL)
{
/* fault is received */
error_code = env->error->error_number;
if(error_code ==
AXIS2_STUB_MYSERVICE_MYOPERATION_FAULT_MYFIRSTEXCEPTION) {
printf("My First Exception called: with param %s\n",
adb_MyFirstException_get_text(fault.MyFirstException, env));
adb_MyFirstException_free(fault.MyFirstException, env);
fault.MyFirstException = NULL;
}
else if(error_code ==
AXIS2_STUB_MYSERVICE_MYOPERATION_FAULT_MYSECONDEXCEPTION) {
printf("My Second Exception called: with param %d\n",
adb_MySecondException_get_number(fault.MySecondException,
env));
adb_MySecondException_free(fault.MySecondException, env);
fault.MySecondException = NULL;
}
}
> Support Custom Fault in ADB generated code
> ------------------------------------------
>
> Key: AXIS2C-1344
> URL: https://issues.apache.org/jira/browse/AXIS2C-1344
> Project: Axis2-C
> Issue Type: Improvement
> Components: code generation
> Environment: Linux + windows
> Reporter: Dimuthu Gamage
> Assignee: Dimuthu Gamage
> Attachments: case45.zip
>
>
> Support Custom Fault in ADB generated code
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.