Hi Subra,

To send a fault from the service you can do the following.
In the invoke function of the service skeleton set an the error status to
AXIS2_FALSE
and return NULL. You can use the AXIS2_ERROR_SET macro to set the error
status.

Then implement the on_fault function in the skeleton to return the error
message you want to return. This will be added to the fault detail section.

When axis2 calls invoke function and finds that it returned null, it will
check the error status.
If the error status if AXIS2_FALSE , then a fault is returned.

You do not have to be concerned about the soap version of the fault.
Depending on the received
message's soap version an appropriate  soap fault will be returned.

You can have a look at
axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync function
in raw_xml_in_out_msg_recv.c file to understand how the fault is processed.

Regards,
Nandika


On 8/21/07, Subra A Narayanan <[EMAIL PROTECTED]> wrote:
>
> Hey Nandika,
>
> Did you get a chance to look at my questions? I would really appreciate ur
> input on these.
>
> Thanks so much!
>
> Subra
>
> On 8/17/07, Subra A Narayanan <[EMAIL PROTECTED]> wrote:
> >
> > Hey Nandika,
> >
> > So I tried your suggestion but I have a doubt. I am just modifying the
> > 'math' webservice from the samples folder.
> >
> > The 'add' operation returns a axiom_node_t * on success, which is
> > nothing but the soap message. But I want to return a soap fault from the
> > 'add' operation if lets say one of the parameters was missing from the
> > request or it was a decimal number. If I follow what you asked me to do,
> > what do I return from the add function? I have to return a axiom_node_t
> > *? But from your email I thought you meant that if I set the soap fault
> > to the message context, the soap fault will automatically be returned to the
> > client. I dont understand how do I stop further processing and return a soap
> > fault to the client.
> >
> > So I did some further digging in to the axis code and found this
> > function in axiom_soap_envelope.h:
> >
> > AXIS2_EXTERN axiom_node_t* AXIS2_CALL
> > axiom_soap_envelope_get_base_node(axiom_soap_envelope_t *envelope, 
> > constaxutil_env_t *env);
> >
> >
> > so this gives me access to the soap fault message as a axiom_node_t*.
> > And upon error in the 'add' operation, I just return it to the client. Is
> > this the right way to do it? I am missing something here.
> >
> > Now one more important thing. When I call
> > axiom_soap_envelope_get_base_node, it seems to returning a soap1.2 fault
> > message rather than a soap1.1 message even though I set *
> >
> > *soapVersion = AXIOM_SOAP11;
> >
> > Why is that? Is there a way to get soap1.1 fault message?
> >
> >
> > I hope my questions are clear. Thanks so much for your help!
> >
> >
> > Subra
> >
> >
> >
> > On 8/17/07, Subra A Narayanan <[EMAIL PROTECTED]> wrote:
> > >
> > > Thanks Nandika. I will give it a shot.
> > >
> > > Have a good weekend!
> > >
> > > On 8/17/07, Nandika Jayawardana < [EMAIL PROTECTED] > wrote:
> > > >
> > > > Hi Subra,
> > > >
> > > > You can create a soap11 fault using following lines.
> > > >
> > > > int soap_version = AXIOM_SOAP11;
> > > >
> > > > soap_envelope = axiom_soap_envelope_create_default_soap_envelope
> > > > (env, soap_version);
> > > >
> > > > soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
> > > >
> > > > soap_fault = axiom_soap_fault_create_default_fault (env,
> > > > soap_body, "fault code" , "fault reason"
> > > > , soap_version);
> > > >
> > > > axis2_msg_ctx_set_fault_soap_envelope(msg_ctx, env, soap_envelope);
> > > >
> > > > You can set the fault to the msg_ctx and it will be returned to the
> > > > client.
> > > >
> > > > Regards
> > > >
> > > > Nandika
> > > >
> > > >
> > > >
> > > > On 8/17/07, Subra A Narayanan <[EMAIL PROTECTED] > wrote:
> > > > >
> > > > > Hello folks,
> > > > >
> > > > > I am trying ti build a SOAP1.1 fault and return to the ws client.
> > > > > I am having some difficulty understanding how to go about this. I 
> > > > > have tryng
> > > > > to dig through the source code but was wondering if you guys have some
> > > > > sample code. If you have it that would be very helpful in 
> > > > > understanding the
> > > > > usage.
> > > > >
> > > > > In the meantime I will continue to dig through the source code to
> > > > > try to understand.
> > > > >
> > > > > Thanks as usual!
> > > > >
> > > > > Subra
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > [EMAIL PROTECTED]
> > > > WSO2 Inc: http://www.wso2.com
> > >
> > >
> > >
> >
>


-- 
[EMAIL PROTECTED]
WSO2 Inc: http://www.wso2.com

Reply via email to