axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chuck Williams <ch...@manawiz.com>
Subject Re: [Axis2-0.94] WSDL2Java generates bad code for <choice> complex types
Date Thu, 09 Feb 2006 10:36:00 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Ajith,<br>
<br>
Thre was another problem in the patch I submitted to handle
&lt;choice&gt;:&nbsp; the generated adb bean parse() methods used an
incorrect value for the argumentCount.&nbsp; They assumed all arguments were
required, rather than precisely 1. Fixing this required one more simple
change to ADBBeanTemplate.xsl.&nbsp; The updated version of the complete
patch (relative to 0.94 release) is attached.<br>
<br>
Chuck<br>
<br>
<span>
<div
 style="font-size: smaller; font-style: italic; margin-bottom: -2.4em;"><br>
<span>Chuck Williams <a class="moz-txt-link-rfc2396E" href="mailto:chuck@manawiz.com">&lt;chuck@manawiz.com&gt;</a></span>
wrote on <span>01/26/2006
08:23:24 AM</span>:<br>
</div>
</span><br>
<blockquote cite="mid43D9139C.6010301@manawiz.com" type="cite">
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
Hi Ajith<br>
  <br>
I think the validation is a good idea, but the issues I listed below
all generated NullPointerException's on valid wsdl.&nbsp; I have been
validating the wsdl with my ide (Netbeans) prior to submitting it to
the code generator.&nbsp; That did help to diagnose some problems, but not
all.&nbsp; The code generator has many constraints that go beyond validation
(e.g., names in many places they are not required due to the way the
data structures work, valid references of course, and one I don't
understand yet:&nbsp; messages with multiple parts are only supported if the
part constraints are type=, not if they are element=).<br>
  <br>
Thanks,<br>
  <br>
Chuck<br>
  <br>
  <span>
  <div
 style="font-size: smaller; font-style: italic; margin-bottom: -2.4em;"><br>
  <span>Ajith Ranabahu <a class="moz-txt-link-rfc2396E"
 href="mailto:ajith.ranabahu@gmail.com">&lt;ajith.ranabahu@gmail.com&gt;</a></span>
wrote on <span>01/26/2006
03:13:00 AM</span>:<br>
  </div>
  </span><br>
  <blockquote
 cite="midf43ea5790601260513w40de9e7fq5e9717c4db82a696@mail.gmail.com"
 type="cite">Hi Chuck,<br>
Thanks for pointing out the issues. <br>
Yes, the code generator being non-validating&nbsp; is the problem here.
We do not check whether the WSDL is valid before attempting to generate
code. IMHO I think we should have a WOM validator as one of the
extensions in the codegenerator - the user can switch off validation if
needed.<br>
My guess is if we have the WSDL validator then we may overcome a number
of issues<br>
    <br>
    <div><span class="gmail_quote">On 1/26/06, <b
 class="gmail_sendername">Chuck Williams</b> &lt;<a
 href="mailto:chuck@manawiz.com" target="_blank"
 onclick="return top.js.OpenExtLink(window,event,this)">
chuck@manawiz.com</a>&gt; wrote:</span>
    <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:
1ex;">Ajith,<br>
      <br>
You probably already saw the second issue in the xsl (an unintended
side effect on optional and array-valued properties).&nbsp; Just in case you
didn't notice<br>
that one, please see the difference in the new version of the patch
(still against 0.94).&nbsp; I've now created and generated code for a large
wsdl and so have growing confidence in the patch.<br>
      <br>
The biggest issue I've seen in using the code generator is the lack of
error detection.&nbsp; E.g., missing name attributes where axis2 expects
them (even if<br>
they are not required by the wsdl spec), multiple parts in messages
that take elements rather than types (element= as opposed to type=),
typos in certain references, all generally yield NullPointerException.&nbsp;
With a large wsdl especially, the problems can be a challenge to find.&nbsp;
Are there plans<br>
to beef up the error checking?<br>
      <br>
Thanks,<br>
      <br>
Chuck<br>
      <span><br>
      <span>
      <div style="font-size: smaller; font-style: italic;"><br>
      <span>Chuck Williams <a href="mailto:chuck@manawiz.com"
 target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">&lt;chuck@manawiz.com&gt;</a></span>
wrote on <span>01/24/2006
09:17:14 PM</span>:<br>
      </div>
      </span></span>
      <div><span><br>
      <blockquote cite="http://mid43D725FA.4020207@manawiz.com"
 type="cite"> Ajith, thanks again!&nbsp; Very nice of you to not embarass me
on the list,
although I managed to do that myself pretty well.&nbsp; <span><span> :-) </span></span><br>
        <br>
For the benefit of others using 0.94, the corrected patch is attached
to this message.&nbsp; I also updated the bean schema for completeness,
although it appears it is missing a couple other attributes as well so
probably not important.<br>
        <br>
Chuck<br>
        <br>
        <span>
        <div style="font-size: smaller; font-style: italic;"><br>
        <span>Ajith Ranabahu <a href="mailto:ajith.ranabahu@gmail.com"
 target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">&lt;ajith.ranabahu@gmail.com&gt;</a></span>
wrote on <span>01/24/2006
09:04:56 PM</span>:<br>
        </div>
        </span><br>
        <blockquote
 cite="http://midf43ea5790601242304l76039a67s9f3a2f17ae53a99b@mail.gmail.com"
 type="cite">Well Actualy when I went through the patch I figured out
the mistake:) It's already corrected :)<br>
          <br>
          <div><span class="gmail_quote">On 1/25/06, <b
 class="gmail_sendername">Chuck Williams</b> &lt;<a
 href="mailto:chuck@manawiz.com" target="_blank"
 onclick="return top.js.OpenExtLink(window,event,this)">
chuck@manawiz.com</a>&gt; wrote:</span>
          <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:
1ex;">Thanks
Ajith!&nbsp; Unfortunately, I need to send you a revised version.&nbsp;
There is a stupid mistake in my xsl that broke the other types!&nbsp; I had
only verified that the &lt;choice&gt; code worked, not yet verified
that the rest of the generated code wasn't affected.&nbsp; It's a trivial
change I'm testing now, so should be just few.&nbsp; Mea culpa -- sorry for
the confusion.<br>
            <br>
Regarding the code, it is very easy to read.&nbsp; I compliment you on the
organizaiton.<br>
            <br>
Chuck<br>
            <br>
            <span>
            <div style="font-size: smaller; font-style: italic;"><br>
            <span>Ajith Ranabahu <a
 href="mailto:ajith.ranabahu@gmail.com" target="_blank"
 onclick="return top.js.OpenExtLink(window,event,this)">&lt;ajith.ranabahu@gmail.com&gt;</a></span>
wrote on <span>01/24/2006
08:52:44 PM</span>:<br>
            </div>
            </span>
            <div><span><br>
            <blockquote
 cite="http://midf43ea5790601242252i350f6538o6dcae455f24deae2@mail.gmail.com"
 type="cite">Hi Chuck,<br>
I looked at your solution and it is reasonable for handling choice. I
applied the patch (Actually modified the classes looking at the patch.
TortoiseSVN&nbsp; throws an exception when I try to apply the given patch)<br>
Thanks a lot for your effort in participating in the development
effort. We really appreciate you coming forward and solving this issue.
I've already solved the ref issue.<br>
              <br>
BTW you seem to have understood the workings of the code well. Did it
take a lot of effort to figure out the stuff ? <br>
              <br>
              <br>
              <div><span class="gmail_quote">On 1/25/06, <b
 class="gmail_sendername">Chuck Williams</b> &lt;<a
 href="mailto:chuck@manawiz.com" target="_blank"
 onclick="return top.js.OpenExtLink(window,event,this)">chuck@manawiz.com
              </a>&gt; wrote:</span>
              <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:
1ex;">Dims
and Ajith,<br>
                <br>
I took Dims' advice and created the attached patch to
modules/codegen/src of Axis2 0.94.&nbsp; This may not be the best
implementation of &lt;choice&gt; but it is very simple and meets my use
cases.&nbsp; The idea is this.&nbsp; A &lt;choice&gt; is treated just like
an
&lt;all&gt; where each enclosed element has minOccurs=0, except that in
the generated code setting any constituent element automatically unsets
all the others.&nbsp; Thus, whatever choice you set last is the choice you
get and you only get one.&nbsp; (The code does not enforce what happens if
you don't set any; this, additional error checking, and accessors to
fully determine the state of what has been chosen, could all be
improved.)<br>
                <br>
I'm just starting to work with it so have not tested it much yet, but
the generated code looks right to me.&nbsp; It's very simple because it
reuses all the code that is already there and makes just a few mods.<br>
                <br>
I haven't tried complex nesting cases to see if they all work, and
probably wont' because I only need &lt;choice&gt; of &lt;element&gt;'s,
although in principle any nesting that &lt;all&gt; handles, choice
should too.<br>
                <br>
I noticed in doing this that none of the particles handle the
&lt;element ref=...&gt; construction.&nbsp; This is somewhat painful, but
livable.&nbsp; If I had more time, I'd try to fix that.&nbsp; It looks like it
might be more complex than this hack due to the way the names are used
in the data structures.<br>
                <br>
I'd appreciate if you guys would add this to axis2 so I don't have to
patch future releases.&nbsp; If it is not deemed suitable, please let me
know why as perhaps I could fix it, or just fix it!<br>
                <br>
Thanks,<br>
                <br>
Chuck<br>
                <br>
                <span>
                <div style="font-size: smaller; font-style: italic;"><br>
                <span><br>
                </span></div>
                </span>
                <div><span>
                <blockquote
 cite="http://mid19e0530f0601240719k390028e6if6e289cd3b797241@mail.gmail.com"
 type="cite">
                  <pre><a href="http://wso2.com/blogs/" target="_blank"
 onclick="return top.js.OpenExtLink(window,event,this)">
</a>
  </pre>
                </blockquote>
                <br>
                </span></div>
                <br clear="all">
              </blockquote>
              </div>
              <br>
              <br clear="all">
              <br>
-- <br>
Ajith Ranabahu </blockquote>
            <br>
            </span></div>
          </blockquote>
          </div>
          <br>
          <br clear="all">
          <br>
-- <br>
Ajith Ranabahu </blockquote>
        <br>
      </blockquote>
      <br>
      </span></div>
      <br clear="all">
    </blockquote>
    </div>
    <br>
    <br clear="all">
    <br>
-- <br>
Ajith Ranabahu
  </blockquote>
  <br>
</blockquote>
<br>
</body>
</html>

Mime
View raw message