You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by ma...@9elements.com on 2007/06/25 11:45:53 UTC
Re: [AXIS2C] throwing an exception from the server to the
Java-client
hello flori,
sry, when i start to write the mail, i took yours to reply but
started a new thread - because i was just to lazy to search
for the mailinglist-email in my contactlist - sorry about this.
to your prob, i don't know if i understand it correctly.
do you have the wsdl file for me where you have defined the fault and
from which you have generated the file axis2_<function>Fault.[ch.] ?
because in my own examples i havend used a fault till now and
i don't know what was generated in this file.
i tried to generate code from /test/resources/wsdl/FaultMapping.wsdl,
but here 2 other problem came up
[1. encoding not supportet]
[2. more than one part for message divRequest]
if you want to raise an Exception like in java, when you write :
throw new java.lang.UnsupportedOperationException("Please implement " +
this.getClass().getName() + "#myOperation");
i think you can do it this way in c :
axiom_node_t *ret_node = NULL;
axiom_soap_envelope_t *soap_envelope = NULL;
axiom_soap_body_t *soap_body = NULL;
axiom_soap_fault_t *soap_fault = NULL;
soap_envelope = axiom_soap_envelope_create_default_soap_envelope(
env, AXIOM_SOAP11);
soap_body = axiom_soap_body_create_with_parent(env, soap_envelope);
soap_fault = axiom_soap_fault_create_default_fault(
env, soap_body, "fault-code", "fault-reason",
AXIOM_SOAP11);
ret_node = axiom_soap_fault_get_base_node(soap_fault, env);
return ret_node;
but i think i misunderstood your prob.
mfg derMark
P.S. sry this time i have to use a webmailer ;-)
Dr. Florian Steinborn schrieb:
> Hello experts,
>
> unfortunately Marc replied to my mail with a different contect (at least
> my mailer shows that) - people could tend to thinking my subject is
> answered. Just wanted to say, that it is not. Still do not know how to
> generate the fault from inside the server stubs...
>
> Thanks,
> Flori
>
> On Sat, 23 Jun 2007 01:00:12 +0200, Dr. Florian Steinborn
> <fp...@gmx.de> wrote:
>
>> Hi folks,
>>
>> someone has a code piece that shows how to generate an exception in
>> the AXIS2C server?
>>
>> I can see that code was generated , the files are named
>> axis2_<function>Fault.[ch.] but I don't know how to use the functions
>> in the modules from inside axis2_svc_skel_<service>_invoke() function,
>> where the operation is called that has to issue the exception...
>>
>> Thanks,
>> Flori
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-c-user-help@ws.apache.org
>
>
>
> ---------------------------------------------------------------------
> 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
Re: [AXIS2C] throwing an exception from the server to the Java-client
Posted by Samisa Abeysinghe <sa...@wso2.com>.
Dr. Florian Steinborn wrote:
> Hi Mark,
>
> thanks for your ideas - I will give them a try. Anyway I thought that
> returning a fault would be a very standard way that is supported by
> the generated functions (and not to be implemented by extending given
> structs or function parameters...)
There are some improvements that we need to do to the fault handling
model. Specially with codegen we have to look into that.
As far as sending a custom fault to a customer is concerned, there are
multiple ways of doing that:
1. Return null form invoke method in case of fault and define the
on_fault method to return a fault node
2. In case of an error, create a fault SOAP envelope and set it on the
message context prameter
3. Use the technique explained by Mark
Thanks,
Samisa...
>
> Maybe one of the chiefs here can add something or give an example...
>
> Regards,
> Flori
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
>
>
--
Samisa Abeysinghe : http://www.wso2.org/ (WSO2 Oxygen Tank - Web Services Developers' Portal)
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org
Re: [AXIS2C] throwing an exception from the server to the Java-client
Posted by "Dr. Florian Steinborn" <fl...@drb.insel.de>.
Hi Mark,
thanks for your ideas - I will give them a try. Anyway I thought that
returning a fault would be a very standard way that is supported by the
generated functions (and not to be implemented by extending given structs
or function parameters...)
Maybe one of the chiefs here can add something or give an example...
Regards,
Flori
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org
Re: [AXIS2C] throwing an exception from the server to the Java-client
Posted by Mark Nüßler <ma...@9elements.com>.
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
Re: [AXIS2C] throwing an exception from the server to the Java-client
Posted by "Dr. Florian Steinborn" <fl...@drb.insel.de>.
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