axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim K. (Gmane)" <tkgmane...@ugcs.net>
Subject Re: HELP PLEASE: array inside array and wrapped document/literal
Date Thu, 14 Apr 2005 15:52:31 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">
</head>
<body bgcolor="#ffffff" text="#000000">
<tt>I guess I was not clear:<br>
<br>
NamedValue[][] equivalent to NamedValueSet[] (and it's also clear what
index in the array does what)<br>
</tt>
<pre class="moz-signature" cols="72">Tim</pre>
<br>
<br>
Tim K. (Gmane) wrote:
<blockquote cite="midd3m2v2$afm$1@sea.gmane.org" type="cite">
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <tt>I use it so that we can do the equivalent of NamedValue[][]
multi-dims arrays, no pun intended :)<br>
  <br>
I had problems with multi-dims arrays over rpc/encoded and this solved
it.<br>
  </tt>
  <pre class="moz-signature" cols="72">Tim</pre>
  <br>
  <br>
Davanum Srinivas wrote:
  <blockquote cite="mid19e0530f050414081711d7e302@mail.gmail.com"
 type="cite">
    <pre wrap="">Tim,

what do you use NamedValueSet for? see my comment in the bug report.

-- dims

On 4/14/05, Tim K. (Gmane) <a class="moz-txt-link-rfc2396E"
 href="mailto:tkgmane+at@ugcs.net">&lt;tkgmane+at@ugcs.net&gt;</a> wrote:
  </pre>
    <blockquote type="cite">
      <pre wrap=""> Anne,
 
 We already have a lot of server code using these API's (over 200 methods
that rely on these constructs that are exposed over WS but also used by
various code on the server side, web interface, protocol servers, etc.) It's
too late in the development cycle to make such API changes. It would be
ideal if Axis worked as we are not doing anything illegal as far as I can
tell.
 
 This is the bug that I filed, Dims looked at it yesterday, but we don't
have a plan yet.
 
 <a class="moz-txt-link-freetext"
 href="http://issues.apache.org/jira/browse/AXIS-1926">http://issues.apache.org/jira/browse/AXIS-1926</a>
 Tim
 
 
 Anne Thomas Manes wrote: 
 Is option 2 such as bad thing? 

But here's a proposed work around -- define a Java object that is an
array of NamedValue objects (e.g., suboptions) and use that object as
your input parameter rather than specifying an array in the request:

NamedValue[] suboptions = new NamedValue[]
 {
 new NamedValue("dummy2-1", "val2-1"),
 new NamedValue("dummy2-2", new Integer(314))
 };

NamedValue[] options = new NamedValue[]
 {
 new NamedValue("dummy1", "dummy_val1"),
 new NamedValue("dummy2", suboptions)
 };

Anne

On 4/13/05, Tim K. (Gmane) <a class="moz-txt-link-rfc2396E"
 href="mailto:tkgmane+at@ugcs.net">&lt;tkgmane+at@ugcs.net&gt;</a> wrote:
 
 
 Anne,
 
 That makes sense. That's why I kept pushing and asking questions just to
make sure what looks like common sense is actually true.
 
 So it looks like I would have at least 3 choices here:
 
 1) Define in the schema all possible types ArrayOfXxxx that could occur at
run-time. This is less than ideal because errors would not be discovered
until run-time, but it could be done with enough testing. Also, the Axis bug
would still need to be fixed so that it works at all.
 
 
 2) Change the definition of the value element of NamedValue to be:
 
 &lt;xsd:element name="value" type="xsd:anyType" maxOccurs="unbounded"/&gt;
 
 But then end up with a generated NamedValue class on the client side whose
value is an Object[] instead of Object. The server class would also have to
be changed accordingly and that's not really an option at this point as
there is *a lot* of code written and it's too late to change it. This is
more of a hack than a real solution.
 
 
 3) Use rpc/encoded instead which I know works well, except for custom
exception/fault deserialization in .NET Maybe something custom can be done
on the .NET side for this case.
 
 
 
 Tim
 
 
 Anne Thomas Manes wrote: 
 Well -- actually, you shouldn't be able to send an array of String
unless you had previously defined a type which is an array of string.
You see -- that what's really going wrong in Tim's application.

Consider this point: The "value" element has not been defined to allow
multiple occurrences. To make that work, then you would need to define
the "value" element like this:

 &lt;xsd:element name="value" type="xsd:anyType" maxOccurs="unbounded"/&gt;

But the way it's defined, an &lt;options&gt; element contains one &lt;name&gt;
element and one &lt;value&gt; element.

You see, this is the really challenging thing about using
&lt;xsd:anyType&gt;. Axis can't generate schema type definitions on the fly
(or if it did, it would have to send the schema with the request).

Assuming that you had previously defined an ArrayOfString type:

&lt;xsd:complexType name="ArrayOfString"
 &lt;xsd:sequence&gt;
 &lt;xsd:element name="item" type="xsd:string" maxOccurs="unbounded"/&gt;
 &lt;xsd:sequence&gt;
&lt;xsd:complexType&gt;

Then you should be able to send:

NamedValue object:
 name: "dummy2"
 value: String[]

And on the wire, it would look like this:

&lt;options&gt;
 &lt;name&gt;dummy2&lt;/name&gt;
 &lt;value xsi:type="ns1:ArrayOfString"&gt;
 &lt;item&gt;blah&lt;/item&gt;
 &lt;item&gt;blah&lt;/item&gt;
 &lt;/value&gt;
&lt;/options&gt;



On 4/13/05, Tim K. (Gmane) <a class="moz-txt-link-rfc2396E"
 href="mailto:tkgmane+at@ugcs.net">&lt;tkgmane+at@ugcs.net&gt;</a> wrote:
 
 
 Hi Anne,
 
 I would be curious to see what the correct message should look like for a
String[] as the value of the NamedvAlue, i.e. something like this:
 
 NamedValue object:
 name: "dummy-2"
 value: String[]


&lt;options&gt;
 &lt;name&gt;dummy2&lt;/name&gt;
 &lt;value xsi:type="....."&gt;
 &lt;!-- How do you form the String[] in here? --&gt;
 &lt;/value&gt;
&lt;/options&gt;

 Are wrappers always needed in this case?
 
 Thanks.
 
 Tim
 
 
 Anne Thomas Manes wrote: 
 You're right. The array within the array should be mapped to this:

&lt;login xmlns=<a class="moz-txt-link-rfc2396E"
 href="http://some/namespace">"http://some/namespace"</a>&gt;
 &lt;username&gt;tim&lt;/username&gt;
 &lt;password&gt;tim&lt;/password&gt;
 &lt;options&gt;
 &lt;name&gt;dummy1&lt;/name&gt;
 &lt;value xsi:type="xsd:string"&gt;dummy_val1&lt;/value&gt;
 &lt;/options&gt;
 &lt;options&gt;
 &lt;name&gt;dummy2&lt;/name&gt;
 &lt;value xsi:type="ns1:NamedValue" xmlns:ns1=<a
 class="moz-txt-link-rfc2396E" href="http://some/namespace">"http://some/namespace"</a>&gt;
 &lt;name&gt;dummy2-1&lt;/name&gt;
 &lt;value xsi:type="xsd:string"&gt;val2-1&lt;/value&gt;
 &lt;name&gt;dummy2-2&lt;/name&gt;
 &lt;value xsi:type="xsd:int"&gt;314&lt;/value&gt;
 &lt;/value&gt;
 &lt;/options&gt;
&lt;/login&gt;

I suggest you file a bug report, because Axis is not generating the
right message structure per the WSDL.

Anne

On 4/13/05, Tim K. (Gmane) <a class="moz-txt-link-rfc2396E"
 href="mailto:tkgmane+at@ugcs.net">&lt;tkgmane+at@ugcs.net&gt;</a> wrote:
 
 
 Hi Anne,
 
 I actually started from Java classes using Java2WSDL (I know this is not
the best practice, but if there's something wrong with the WSDL I could try
and fix it by hand).
 
 The ArrayOfNamedValue is defined like below, but it does not seem to come
into play at all:
 
 
 
 
 
 
 
- &lt;complexType name="ArrayOfNamedValue"&gt; 
 
 
- &lt;sequence&gt; 
 
 
 &lt;element name="item" type="impl:NamedValue" minOccurs="0"
maxOccurs="unbounded" /&gt; 
 &lt;/sequence&gt;
 &lt;/complexType&gt; 
 I exposed this method:
 NamedValue[] login(String username, String password, NamedValue[] options)
 Which in the WSDL the request looks like this:
 
 
 
- &lt;element name="login"&gt; 
 
 
- &lt;complexType&gt; 
 
 
- &lt;sequence&gt; 
 
 
 &lt;element name="username" type="xsd:string" /&gt; 
 
 &lt;element name="password" type="xsd:string" /&gt; 
 
 &lt;element name="options" type="impl:NamedValue"
maxOccurs="unbounded" /&gt; 
 &lt;/sequence&gt; 
 &lt;/complexType&gt; 
&lt;/element&gt; 
 And the response like this:
 
 
 
- &lt;element name="loginResponse"&gt; 
 
 
- &lt;complexType&gt; 
 
 
- &lt;sequence&gt; 
 
 
 &lt;element name="loginReturn" type="impl:NamedValue"
maxOccurs="unbounded" /&gt; 
 &lt;/sequence&gt; 
&lt;/complexType&gt; 
&lt;/element&gt; 
 This seems OK so far, even though ArrayOfNamedValue is defined but it does
not seem to be used.
 
 This is exactly what I want to pass back and forth:
 
 NamedValue object:
 name: "dummy-2"
 value: NamedValue[]

But it doesn't look like that's what I get on the server side, it seems that
I get:

NamedValue object:
 name: "dummy-2"
 value: NamedValue &lt;--- Note no array [] here

 And the value of the red NamedValue is the last value sent, in my example
below it's 314
 
 How would Axis know that it needs to convert the request below into a
NamedValue[] on the server side? What if the sequence of values would not be
homogeneus, would it convert it into an Object[] instead (if it worked at
all)?
 
 &lt;login xmlns=<a class="moz-txt-link-rfc2396E"
 href="http://some/namespace">"http://some/namespace"</a>&gt;
 &lt;username&gt;tim&lt;/username&gt;
 &lt;password&gt;tim&lt;/password&gt;
 &lt;options&gt;
 &lt;name&gt;dummy1&lt;/name&gt;
 &lt;value xsi:type="xsd:string"&gt;dummy_val1&lt;/value&gt;
 &lt;/options&gt;
 &lt;options&gt;
 &lt;name&gt;dummy2&lt;/name&gt;
 &lt;value xsi:type="ns1:NamedValue" xmlns:ns1=<a
 class="moz-txt-link-rfc2396E" href="http://some/namespace">"http://some/namespace"</a>&gt;
 &lt;name&gt;dummy2-1&lt;/name&gt;
 &lt;value xsi:type="xsd:string"&gt;val2-1&lt;/value&gt;
 &lt;/value&gt;
 &lt;value xsi:type="ns2:NamedValue" xmlns:ns2=<a
 class="moz-txt-link-rfc2396E" href="http://some/namespace">"http://some/namespace"</a>&gt;
 &lt;name&gt;dummy2-2&lt;/name&gt;
 &lt;value xsi:type="xsd:int"&gt;314&lt;/value&gt;
 &lt;/value&gt;
 &lt;/options&gt;
 &lt;/login&gt;
 
 The part in red above does not seem to map to this:
 NamedValue object:
 name: "dummy-2"
 value: NamedValue[]

 This confuses me greatly, I'm not sure whether what I'm trying to do is
allowed/supported over wrapped doc/literal at all, if it is not I should
then switch back to rpc/encoded or it's just a bug in Axis.
 
 Btw, .NET doesn't seem to be able to convert the red fragment above into a
NamedValue[] so I suspect the message generated by Axis is not correct when
it comes to arrays inside arrays.
 
 Thanks.
 
 Tim
 
 
 Anne Thomas Manes wrote: 
 Tim,

How did you define the array of NamedValue in the schema (where did
the &lt;options&gt; tag come from)?

It looks to me as if the message corresponds to the request. Because
you're using &lt;xsd:anytype&gt;, the value element may contain an array of
the NameValue. Hence the dummy-2 object is defined thus:

NamedValue object:
 name: "dummy-2"
 value: NamedValue[]

Is this not what you want?

Anne

On 4/13/05, Tim K. (Gmane) <a class="moz-txt-link-rfc2396E"
 href="mailto:tkgmane+at@ugcs.net">&lt;tkgmane+at@ugcs.net&gt;</a> wrote:
 
 
 Hello,
 
 If someone could please help me with this issue I would appreciate it. I
recently converted my web service from rpc/encoded to wrapped
document/literal so that it works with .NET (before the change everything
still worked even with .NET, except for problems with custom
exceptions/faults).
 
 I have a data type defined as:
 
 &lt;complexType name="NamedValue"&gt;
 &lt;sequence&gt;
 &lt;element name="name" nillable="true" type="xsd:string" /&gt; 
 &lt;element name="value" nillable="true" type="xsd:anyType" /&gt; 
 &lt;/sequence&gt;
 &lt;/complexType&gt;
 
 I need the value to be xsd:anyType so that I can send arrays of NamedValue
with various types for value.
 
 On the server side I have a method defined as:
 
 NamedValue[] login(String username, String password, NamedValue[] options)
 
 If I create on the client side an options array that looks like this:
 
 NamedValue[] options = new NamedValue[]
 {
 new NamedValue("dummy1", "dummy_val1"),
 
 new NamedValue("dummy2",
 new NamedValue[]
 {
 new NamedValue("dummy2-1", "val2-1"),
 new NamedValue("dummy2-2", new Integer(314))
 })
 };
 
 Note the array inside the array above.
 
 A request to the server from an Axis client (latest CVS version of 1.2RC3)
looks like this:
 
 &lt;login xmlns=<a class="moz-txt-link-rfc2396E"
 href="http://some/namespace">"http://some/namespace"</a>&gt;
 &lt;username&gt;tim&lt;/username&gt;
 &lt;password&gt;tim&lt;/password&gt;
 &lt;options&gt;
 &lt;name&gt;dummy1&lt;/name&gt;
 &lt;value xsi:type="xsd:string"&gt;dummy_val1&lt;/value&gt;
 &lt;/options&gt;
 &lt;options&gt;
 &lt;name&gt;dummy2&lt;/name&gt;
 &lt;value xsi:type="ns1:NamedValue" xmlns:ns1=<a
 class="moz-txt-link-rfc2396E" href="http://some/namespace">"http://some/namespace"</a>&gt;
 &lt;name&gt;dummy2-1&lt;/name&gt;
 &lt;value xsi:type="xsd:string"&gt;val2-1&lt;/value&gt;
 &lt;/value&gt;
 &lt;value xsi:type="ns2:NamedValue" xmlns:ns2=<a
 class="moz-txt-link-rfc2396E" href="http://some/namespace">"http://some/namespace"</a>&gt;
 &lt;name&gt;dummy2-2&lt;/name&gt;
 &lt;value xsi:type="xsd:int"&gt;314&lt;/value&gt;
 &lt;/value&gt;
 &lt;/options&gt;
 &lt;/login&gt;
 
 The encoding of the array inside the array does not seem right to me, the
server ends up with a NamedValue value for "dummy2" instead of a
NamedValue[].
 
 If the message is not correct, what should it look like? I assume it would
need a wrapper, something like ArrayOfNamedValue ... but then this type
would have to be defined in the schema (which in this case it is), but what
about say ArrayOfLong, ArrayOfString, etc. which are not defined in the
schema and could be sent at runtime because the value type is xsd:anyType?
 
 Is this supposed to work the way I want it with wrapped doc/literal? It
worked fine before with rpc/encoded.
 
 If so, is this a bug in Axis? Any available patches for it?
 
 Thank you for any help you may provide.
 -- 
Tim

 
 

 
 

 
 

 
 
 
    </pre>
    </blockquote>
    <pre wrap=""><!---->

  </pre>
  </blockquote>
</blockquote>
</body>
</html>


Mime
View raw message