axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Samisa Abeysinghe <sam...@wso2.com>
Subject Re: custom error message with c server
Date Thu, 15 Nov 2007 14:49:50 GMT
Dimuthu Gamage wrote:
> Hi Michael,
>
> There is a bug in the codegen template in processing faults. 

Lets raise a Jira on this so we can track and fix it.

Samisa...
> It is calling 'on_fault' method explicitly, but the correct way is to 
> allow the engine to call that method.
>
> please check replacing explicit calls of
> 'return axis2_svc_skel_TestService_on_fault(....)'
> to
> 'return NULL'
> inside the axis2_svc_skel_TestService.c file.
>
> The idea is when you return NULL from the business logic, the engine 
> will create the fault element and insert you custom fault inside the 
> detail tag,
> So the response would look like,
>
>       <soapenv:Fault>
>          <faultcode>env:Sender</faultcode>
>          <faultstring>Undefined error returned by business logic 
> implementation</faultstring>
>          <detail>
>             your custom fault
>          </detail>
>       </soapenv:Fault>
>
> I will try to figure out the others issues and try to fix the tool to 
> support custom soap faults asap.
>
> Thanks
> Dimuthu
>
> On Nov 14, 2007 5:30 PM, Michael Sutter <Michael.Sutter@ipe.fzk.de 
> <mailto:Michael.Sutter@ipe.fzk.de>> wrote:
>
>     Hello Dimuthu,
>
>     thanks for your reply. I tested it - but it also throws no
>     exception in
>     the Java client. I only see the null return value in the client.
>     In the
>     service implementation I used:
>
>     AXIS2_ERROR_SET(...)
>     return NULL;
>
>     to use the on_fault method of axis2_svc_skel_TestService. Is this
>     right?
>     In the on fault method only
>     ns1 = axiom_namespace_create(env, "
>     http://www.w3.org/2003/05/soap-envelope", "ns1");
>     works. If I use the other way the server crashs with Segmentation
>     fault.
>     The soap message of the response is:
>
>     <soapenv:Envelope
>     xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope
>     <http://www.w3.org/2003/05/soap-envelope>"><soapenv:Header/><soapenv:Body><ns1:fault
>     xmlns:ns1=" http://www.w3.org/2003/05/soap-envelope">My error
>     message to
>     be thrown!</ns1:fault></soapenv:Body></soapenv:Envelope>
>
>     where I can see the fault - but maybe there is still something wrong?
>
>     But I have another question left. When I use this way I only can send
>     one exception to the client - defined in the on fault method? There is
>     no direct way to send different exceptions to the client depending on
>     the state of the service? When I want to do such I think I have to
>     use
>     the way Samisa told?
>
>     Regards Michael
>
>     Dimuthu Gamage wrote:
>     > Hi Micheal,
>     >
>     > Your set_custom_error function only write the error message to
>     the log
>     > file, and not to the soap message, so to send a custom soap
>     fault you
>     > have to manually edit the axis2_svc_skel_TestService_on_fault.
>     Please
>     > edit it as the following and test.
>     >
>     > Java doesn't throw exception because the fault element is in wrong
>     > namespace. So It is corrected here.
>     >
>     >     axiom_node_t* AXIS2_CALL
>     >     axis2_svc_skel_TestService_on_fault(axis2_svc_skeleton_t
>     > *svc_skeleton,
>     >                   const axutil_env_t *env, axiom_node_t *node)
>     >     {
>     >         axiom_node_t *error_node = NULL;
>     >         axiom_element_t *error_ele = NULL;
>     >         axiom_namespace_t *ns1 = NULL;
>     >
>     >         /* you can use either of following method to get the
>     namespace */
>     >         ns1 = axiom_namespace_create(env, "
>     > http://www.w3.org/2003/05/soap-envelope",
>     >                                                    "ns1");
>     >
>     >         /* or extract the samenmespace as the parent */
>     >
>     >         ns1 = axiom_element_get_namespace(
>     >                     axiom_node_get_data_element(node, env),
>     >                     env,
>     >                     node);
>     >
>     >         error_ele = axiom_element_create(env, node, "fault", ns1,
>     >                         &error_node);
>     >         axiom_element_set_text(error_ele, env, "*Whatever your
>     custom
>     > faul*t",
>     >                         error_node);
>     >         return error_node;
>     >     }
>     >
>     > Thanks
>     > Dimuthu
>     >
>     >
>     > On Nov 13, 2007 4:33 PM, Michael Sutter <
>     Michael.Sutter@ipe.fzk.de <mailto:Michael.Sutter@ipe.fzk.de>
>     > <mailto:Michael.Sutter@ipe.fzk.de
>     <mailto:Michael.Sutter@ipe.fzk.de>>> wrote:
>     >
>     >     Hello,
>     >
>     >     I read your links but they don't solved my problem. Maybe
>     I've done
>     >     something wrong - so I explain exactly what I'm doing. In the
>     >     service I
>     >     implemented what I've found in Jira AXIS2C-678
>     >    
>     (https://issues.apache.org/jira/browse/AXIS2C-678?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
>     <https://issues.apache.org/jira/browse/AXIS2C-678?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel>
>     >    
>     <https://issues.apache.org/jira/browse/AXIS2C-678?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
>     <https://issues.apache.org/jira/browse/AXIS2C-678?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel>>)
>     >     and the echo example of the c server implementation. I
>     implemented a
>     >     custom error message method:
>     >
>     >      void set_custom_error(const axutil_env_t *env, axis2_char_t
>     >     *error_message)
>     >            {
>     >              axutil_error_set_error_message(env->error,
>     error_message);
>     >              AXIS2_ERROR_SET(env->error, AXIS2_ERROR_LAST + 1,
>     >     AXIS2_FAILURE);
>     >            }
>     >
>     >     and call it from the service method. But then there is no
>     custom error
>     >     message delivered to the client. I only found the custom message
>     >     in the
>     >     log file of the axis server where it is not reachable from the
>     >     client. I
>     >     also monitored the SOAP messages and the custom error
>     message is not
>     >     inside the response:
>     >
>     >     <soapenv:Envelope
>     >     xmlns:soapenv="
>     >    
>     http://www.w3.org/2003/05/soap-envelope"><soapenv:Header/><soapenv:Body><fault>TestService|http://auger.fzk.org
>     >     failed</fault></soapenv:Body></soapenv:Envelope>
>     >
>     >     With this response message the java client throws no
>     exception. I
>     >     found
>     >     that the response is exactly what the on_fault method of the
>     service
>     >     creates.
>     >
>     >     I also read the link from Samisa
>     >     (
>     >    
>     http://www.nabble.com/Help-needed-on-building-custom-soap-fault-in-axis2c-tf4538948.html#a13053097
>     <http://www.nabble.com/Help-needed-on-building-custom-soap-fault-in-axis2c-tf4538948.html#a13053097>)
>     >     but it has another content - I think. In the link the wsdl
>     has defined
>     >     two exceptions and the author wanted to know how to use
>     them. The
>     >     solution was to implement them in the on_fault method.
>     >
>     >     Now to my questions: Have I done something wrong in the
>     implementation
>     >     of the service or is it not possible to send custom error
>     messages to
>     >     the client with my custom error method? Or have I always to
>     define
>     >     the
>     >     exceptions in the wsdl and implement them in the on_fault method
>     >     of the
>     >     service?
>     >
>     >     I have attached my service - maybe someone can help me.
>     >
>     >     Kind regards
>     >     Michael
>     >
>     >     Samisa Abeysinghe wrote:
>     >     > Subra A Narayanan wrote:
>     >     >> Michael,
>     >     >>
>     >     >> If you are setting the soap fault correctly on your server
>     >     side, your
>     >     >> java client when it receives the soap response back with
>     the soap
>     >     >> fault in it, should automatically throw an exception. You
>     can then
>     >     >> retrieve the exception using ex.message.
>     >     >>
>     >     >> May be someone from the Axis2 team can correct me if I am
>     wrong.
>     >     >>
>     >     > You are absolutely correct.
>     >     > BTW, please follow this thread for further information:
>     >     >
>     >    
>     http://www.nabble.com/Help-needed-on-building-custom-soap-fault-in-axis2c-tf4538948.html#a13053097
>     <http://www.nabble.com/Help-needed-on-building-custom-soap-fault-in-axis2c-tf4538948.html#a13053097>
>     >     >
>     >     >
>     >     > Thanks,
>     >     > Samisa...
>     >     >
>     >     >
>     >     >
>     >    
>     ---------------------------------------------------------------------
>     >     > To unsubscribe, e-mail:
>     axis-c-user-unsubscribe@ws.apache.org
>     <mailto:axis-c-user-unsubscribe@ws.apache.org>
>     >     <mailto: axis-c-user-unsubscribe@ws.apache.org
>     <mailto:axis-c-user-unsubscribe@ws.apache.org>>
>     >     > For additional commands, e-mail:
>     axis-c-user-help@ws.apache.org <mailto:axis-c-user-help@ws.apache.org>
>     >     <mailto: axis-c-user-help@ws.apache.org
>     <mailto:axis-c-user-help@ws.apache.org>>
>     >     >
>     >
>     >    
>     ---------------------------------------------------------------------
>     >     To unsubscribe, e-mail:
>     axis-c-user-unsubscribe@ws.apache.org
>     <mailto:axis-c-user-unsubscribe@ws.apache.org>
>     >     <mailto:axis-c-user-unsubscribe@ws.apache.org
>     <mailto:axis-c-user-unsubscribe@ws.apache.org> >
>     >     For additional commands, e-mail:
>     axis-c-user-help@ws.apache.org <mailto:axis-c-user-help@ws.apache.org>
>     >     <mailto: axis-c-user-help@ws.apache.org
>     <mailto:axis-c-user-help@ws.apache.org>>
>     >
>     >
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
>     <mailto:axis-c-user-unsubscribe@ws.apache.org>
>     For additional commands, e-mail: axis-c-user-help@ws.apache.org
>     <mailto:axis-c-user-help@ws.apache.org>
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition. 
> Version: 7.5.503 / Virus Database: 269.15.32/1131 - Release Date: 11/14/2007 4:54 PM
>   


---------------------------------------------------------------------
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