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 "David Taylor (Lowell)" <dk...@F5.com> on 2008/11/11 23:59:57 UTC

xs:any minOccurs Check is Wrong

I have a WSDL that I am using to generate ADB stubs.  This WSDL includes
a type with xs:any that is causing the stub to have code generated to
check for at least 1 element in the list, even though the element lists
minOccurs="0".  Here's the fragment of the WSDL:

 

 

            <complexType name="ItemListType">

                        <sequence maxOccurs="unbounded">

                                    <any namespace="##other"
processContents="lax" minOccurs="0" maxOccurs="unbounded" />

                        </sequence>

            </complexType>

 

Here is the erroneous check in the generated stub deserialize function:

 

                                   if (i < 1)

                                   {

                                     /* found element out of order */

                                     AXIS2_LOG_ERROR(env->log,
AXIS2_LOG_SI, "ItemListTypeSequence (@minOccurs = '1') only have %d
elements", i);

                                     if(element_qname)

                                     {

                                        axutil_qname_free(element_qname,
env);

                                     }

                                     if(arr_list)

                                     {

                                        axutil_array_list_free(arr_list,
env);

                                     }

                                     return AXIS2_FAILURE;

                                   }

 

The problem appears to be that the XSLT stylesheet is looking for an
@any attribute to be set, to avoid generating this section of code.  It
seems that the xs:any element should set this attribute.  However, I
can't figure out where that attribute should be set.  Any help would be
greatly appreciated.

Thanks,

-David

 


RE: xs:any minOccurs Check is Wrong

Posted by "David Taylor (Lowell)" <dk...@F5.com>.
I think I have figured out the problem.  In this case, there is an
anonymous complex type with a sequence.  That sequence has an implied
minOccurs of 1.  But, inside that sequence is only a single item, any,
with a minOccurs of 0.  The ADB deserializer didn't handle the case
where the any had nothing, since the sequence was expecting at least 1
item.  I worked around it by adding minOccurs=0 to the sequence.  I
don't know how the specification says to handle this, but it may be that
if all the subitems have minOccurs=0, then the parent should also be
treated as though minOccurs=0 as well.

Thanks,

-David

 

________________________________

From: Dimuthu Gamage [mailto:dimuthuc@gmail.com] 
Sent: Monday, November 17, 2008 10:04 PM
To: Apache AXIS C User List
Subject: Re: xs:any minOccurs Check is Wrong

 

Hi David,

>From the error message of your generated code, it looks like you are
checking "ItemListTypeSequence" instead of "ItemListType" property. Can
you check whether there is anther property named "ItemListType"?.

If it is no other property, then this should probably bugs for not
setting @any and @minOccurs. If so please report it to the Apache Jira.
https://issues.apache.org/jira/secure/Dashboard.jspa (select Axis2-C
project)

Thanks
Dimuthu

On Wed, Nov 12, 2008 at 4:29 AM, David Taylor (Lowell) <dk...@f5.com>
wrote:

I have a WSDL that I am using to generate ADB stubs.  This WSDL includes
a type with xs:any that is causing the stub to have code generated to
check for at least 1 element in the list, even though the element lists
minOccurs="0".  Here's the fragment of the WSDL:

 

 

            <complexType name="ItemListType">

                        <sequence maxOccurs="unbounded">

                                    <any namespace="##other"
processContents="lax" minOccurs="0" maxOccurs="unbounded" />

                        </sequence>

            </complexType>

 

Here is the erroneous check in the generated stub deserialize function:

 

                                   if (i < 1)

                                   {

                                     /* found element out of order */

                                     AXIS2_LOG_ERROR(env->log,
AXIS2_LOG_SI, "ItemListTypeSequence (@minOccurs = '1') only have %d
elements", i);

                                     if(element_qname)

                                     {

                                        axutil_qname_free(element_qname,
env);

                                     }

                                     if(arr_list)

                                     {

                                        axutil_array_list_free(arr_list,
env);

                                     }

                                     return AXIS2_FAILURE;

                                   }

 

The problem appears to be that the XSLT stylesheet is looking for an
@any attribute to be set, to avoid generating this section of code.  It
seems that the xs:any element should set this attribute.  However, I
can't figure out where that attribute should be set.  Any help would be
greatly appreciated.

Thanks,

-David

 




-- 
Thanks,
Dimuthu Gamage

http://www.dimuthu.org
http://www.wso2.org


Re: xs:any minOccurs Check is Wrong

Posted by Dimuthu Gamage <di...@gmail.com>.
Hi David,

>From the error message of your generated code, it looks like you are
checking "ItemListTypeSequence" instead of "ItemListType" property. Can you
check whether there is anther property named "ItemListType"?.

If it is no other property, then this should probably bugs for not setting
@any and @minOccurs. If so please report it to the Apache Jira.
https://issues.apache.org/jira/secure/Dashboard.jspa (select Axis2-C
project)

Thanks
Dimuthu

On Wed, Nov 12, 2008 at 4:29 AM, David Taylor (Lowell) <dk...@f5.com>wrote:

>  I have a WSDL that I am using to generate ADB stubs.  This WSDL includes
> a type with xs:any that is causing the stub to have code generated to check
> for at least 1 element in the list, even though the element lists
> minOccurs="0".  Here's the fragment of the WSDL:
>
>
>
>
>
>             <complexType name="ItemListType">
>
>                         <sequence maxOccurs="unbounded">
>
>                                     <any namespace="##other"
> processContents="lax" minOccurs="0" maxOccurs="unbounded" />
>
>                         </sequence>
>
>             </complexType>
>
>
>
> Here is the erroneous check in the generated stub deserialize function:
>
>
>
>                                    if (i < 1)
>
>                                    {
>
>                                      /* found element out of order */
>
>                                      AXIS2_LOG_ERROR(env->log,
> AXIS2_LOG_SI, "ItemListTypeSequence (@minOccurs = '1') only have %d
> elements", i);
>
>                                      if(element_qname)
>
>                                      {
>
>                                         axutil_qname_free(element_qname,
> env);
>
>                                      }
>
>                                      if(arr_list)
>
>                                      {
>
>                                         axutil_array_list_free(arr_list,
> env);
>
>                                      }
>
>                                      return AXIS2_FAILURE;
>
>                                    }
>
>
>
> The problem appears to be that the XSLT stylesheet is looking for an @any
> attribute to be set, to avoid generating this section of code.  It seems
> that the xs:any element should set this attribute.  However, I can't figure
> out where that attribute should be set.  Any help would be greatly
> appreciated.
>
> Thanks,
>
> -David
>
>
>



-- 
Thanks,
Dimuthu Gamage

http://www.dimuthu.org
http://www.wso2.org

Re: Custom Error Messages

Posted by Tony Hoyt <gm...@yahoo.com>.
--- On Wed, 11/12/08, Dinesh Premalal <xy...@gmail.com> wrote:
> http://nethu.org/2008/01/18/axis2c-custom-error-handling/

I tried your example and it wouldn't work for me, namely because the compiler could not link up the axutil_error_messages array in src\error.c. I figure this might be a C++ issue, since that's the platform I'm working on, but that's not important at the moment.

I did manage to get the following three lines to work..

axutil_error_set_error_message( env->error, 
  "This is my custom error message..." );
AXIS2_ERROR_SET(env->error, 
  (enum axutil_error_codes)(AXUTIL_ERROR_MAX + 1), AXIS2_FAILURE);
return NULL;

BUT, to do this with code generated by WSDL2C, I had to edit the axis2_svc_skel_myService_invoke() generated function.  In this invoke function, it calls all the operations and looks to see if the return value is NULL.  If it is NULL, it sets it's OWN error message, and returns that to the user.  This is undesirable behavior for me,  I would like it if the invoke() call could check to see if the user has already set an error message.  If not, then set it's own error message, else, it would pass the user generated error message down and eventually back to the user.

As such, their should be some kind of axutil_error_get_error_number() function, that allows the user to see if an error code has been set.

Otherwise, I can hack the generated code for now, but in the future, I would have rather had the system just allow me to specify my own error messages back to the user.

  Tony

"Opportunities multiply as they are seized." - Sun Tzu





      

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


Re: Custom Error Messages

Posted by Dinesh Premalal <xy...@gmail.com>.
Tony Hoyt <gm...@yahoo.com> writes:

> How do I send a custom error message back to the client to warn the
> user of a potential error in Axis2/C?
http://nethu.org/2008/01/18/axis2c-custom-error-handling/

thanks,
Dinesh

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


Custom Error Messages

Posted by Tony Hoyt <gm...@yahoo.com>.
This is a topic that seems to come up every now and then but, I haven't seen a solution posted that works with the more recent 1.5.0 release of Axis2/C.  Using wsdl2c generated code, I want to send back to clients a custom error message but, I haven't found a way to do so yet.  Currently, It appears that I could use the following functions, but when I set the values and return NULL in my custom operation code, the client doesn't get the error I've been expecting.

== Code Start ==
adb_myResponse_t *axis2_skel_myService_myOp 
  (const axutil_env_t *env, adb_myRequest_t* myRequest )
{
 axutil_error_set_error_message( env->error, 
  "This is my custom error message..." );
 AXIS2_ERROR_SET( env->error,  
  (enum axutil_error_codes)(AXIS2_ERROR_LAST + 1), AXIS2_FAILURE );
 return NULL;
}
== Code End ==

How do I send a custom error message back to the client to warn the user of a potential error in Axis2/C?

  Tony



"Opportunities multiply as they are seized." - Sun Tzu



      

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