Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
0.93
-
None
Description
Thanks, BTW, for the tcpmon tool – very helpful!
I have a need to return custom SOAP fault messages from an Axis2/C server. This turns out to require some patches in a few places. First, the code generated by the w2c tool always calls a local on_fault handler, named axis2_svc_skel_foo_on_fault() in the axis2_svc_skel_foo.c file. This function, as generated by w2c, creates a <fault> element and returns it in the SOAP body.
Changing axis2_svc_skel_foo_on_fault() to simply return NULL instead allows the
axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync() function in
modules/core/receivers/raw_xml_in_out_msg_recv.c to recognize that no body element
has been returned, and create a SOAP fault instead.
The actual business logic that one fills into the axis2_skel_foo.c file can then simply
do the following:
axis2_skel_foo_Foo(...) {
AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_FAILURE);
AXIS2_ERROR_SET_ERROR_NUMBER(env->error,
AXIS2_ERROR_FOO);
return NULL;
}
This almost works, and axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync()
now recognizes the fault condition and calls axiom_soap_fault_create_default_fault()
to create the SOAP fault element. Good, except that it then returns AXIS2_FAILURE,
so that its caller, axis2_raw_xml_in_out_msg_recv_receive_sync() in
modules/core/receivers/msg_recv.c, then does this:
status = AXIS2_MSG_RECV_INVOKE_IN_OUT_BUSINESS_LOGIC_SYNC(msg_recv, env,
msg_ctx, out_msg_ctx);
if(AXIS2_SUCCESS != status)
which destroys the nice SOAP fault and returns an empty body element instead to the client!
My current patch is to have axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync() return AXIS2C_SUCCESS instead – this makes sense to me, because although an fault
condition has been detected, the function has successfully handled it by creating
the SOAP fault element. Here's the patch:
====================================
— modules/core/receivers/raw_xml_in_out_msg_recv.c.orig 2006-10-07 13:31:17.801951262 -0400
+++ modules/core/receivers/raw_xml_in_out_msg_recv.c 2006-10-07 13:31:36.094847670 -0400
@@ -325,7 +325,7 @@
else if (soap_fault)
else
{