axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Nüßler <mark.nuess...@9elements.com>
Subject Re: [AXIS2C] throwing an exception from the server to the Java-client
Date Mon, 25 Jun 2007 15:09:39 GMT
hello Flori,

first let me say, that i am not very skilled in c,
so perhaps this approach is complete nonsense.

in java a method which can throw an Exception
of the type "RaiseErrorFault" cancels the current
action and steps back to the point where the method
was called. it doesn't return the Exception as
return-value of the funktion, this is clear :

public RaiseErrorResponse raiseError(RaiseError raiseError)
     throws RaiseErrorFault
{
     (...)
     // throw Exception
     throw new RaiseErrorFault("anything happend");
     (...)
     return myRaiseErrorResponse;
}

the only workaround i could think about is
to extend the method with an extra param that has
the type of the Exception "axis2_raiseErrorFault_t"


axis2_raiseErrorResponse_t* axis2_skel_Fehler_raiseError(const
     axutil_env_t *env,
     axis2_raiseError_t* raiseError,
     axis2_raiseErrorFault_t *raiseErrorFault)
{
     (...)
     // throw Exception
     axiom_node_t*  param_raiseErrorFault = NULL;
     param_raiseErrorFault = axiom_node_create(env);

     // ... build up the fault node with axiom ...
     //

     axis2_raiseErrorFault_set_raiseErrorFault(raiseErrorFault,
         env, param_raiseErrorFault);
     return NULL;
     (...)
     return my_raiseErrorResponse;
}

after calling the method from "axis2_svc_skel_Fehler_invoke"
you can pass the "raiseErrorFault" which was filled during the
method. i think after this you just have to convert the
"raiseErrorFault" into an axiom_node_t to pass the exception-info,
so axis2_svc_skel_Fehler_on_fault and process it here again
or you can send this node back as fault itself.


axis2_raiseErrorFault_t *raiseErrorFault = NULL;
raiseErrorFault = axis2_raiseErrorFault_create(env);

ret_val1 = axis2_skel_Fehler_raiseError(env,
     input_val1_1, raiseErrorFault);
if (NULL == ret_val1)
{
     axiom_node_t* raiseErrorFault_as_node = NULL;
     AXIS2_LOG_ERROR(...);
     raiseErrorFault_as_node = raiseErrorFault2node(env, )

     // send back instantly
     return raiseErrorFault_as_node;

     // or

     // procces with a more general method
     // which could accept any type of your Exception
     // that are convertet into an axiom_node_t
     return axis2_svc_skel_Fehler_on_fault(svc_skeleton,
         env, raiseErrorFault_as_node);
}


its just an idea, i have not implemented this!


another approach could be to extend the "env" with
another member, "env->exception" as an container
for any exception, the advantage is, that you do
not have to pass another param as in the first approach ;-)


mfg derMark



Dr. Florian Steinborn schrieb:
> Hi Mark,
> 
> no problem at all.
> 
> Attached you find a "Fehler.java", that I used to generate the 
> "Fehler.wsdl" that is attached as well. When you generate c-server stubs 
> you will find the "axis2_raiseErrorFault.[ch]" files. In my 
> understanding the error should be raised in 
> "axis2_skel_Fehler_raiseError()" function - that is the place where the 
> business logic registers the error and wants to raise it. This function 
> usually returns an "int" (as it is defined), but how has it have to look 
> like, when we do not return the int but the fault? The return type of 
> the function is "axis2_raiseErrorResponse_t*" - sure, you can return a 
> NULL, but what about the raiseErrorFault?
> 
> Thanks for your patience,
> Flori
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
> 
> 
> ------------------------------------------------------------------------
> 
> No virus found in this incoming message.
> Checked by AVG Free Edition. 
> Version: 7.5.472 / Virus Database: 269.9.6/865 - Release Date: 24.06.2007 08:33

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


Mime
View raw message