Tim, what do you use NamedValueSet for? see my comment in the bug report.
-- dims On 4/14/05, Tim K. (Gmane) <[EMAIL PROTECTED]> wrote: > 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. > > http://issues.apache.org/jira/browse/AXIS-1926 > 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) <[EMAIL PROTECTED]> 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: > > <xsd:element name="value" type="xsd:anyType" maxOccurs="unbounded"/> > > 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: > > <xsd:element name="value" type="xsd:anyType" maxOccurs="unbounded"/> > > But the way it's defined, an <options> element contains one <name> > element and one <value> element. > > You see, this is the really challenging thing about using > <xsd:anyType>. 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: > > <xsd:complexType name="ArrayOfString" > <xsd:sequence> > <xsd:element name="item" type="xsd:string" maxOccurs="unbounded"/> > <xsd:sequence> > <xsd:complexType> > > Then you should be able to send: > > NamedValue object: > name: "dummy2" > value: String[] > > And on the wire, it would look like this: > > <options> > <name>dummy2</name> > <value xsi:type="ns1:ArrayOfString"> > <item>blah</item> > <item>blah</item> > </value> > </options> > > > > On 4/13/05, Tim K. (Gmane) <[EMAIL PROTECTED]> 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[] > > > <options> > <name>dummy2</name> > <value xsi:type="....."> > <!-- How do you form the String[] in here? --> > </value> > </options> > > 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: > > <login xmlns="http://some/namespace"> > <username>tim</username> > <password>tim</password> > <options> > <name>dummy1</name> > <value xsi:type="xsd:string">dummy_val1</value> > </options> > <options> > <name>dummy2</name> > <value xsi:type="ns1:NamedValue" xmlns:ns1="http://some/namespace"> > <name>dummy2-1</name> > <value xsi:type="xsd:string">val2-1</value> > <name>dummy2-2</name> > <value xsi:type="xsd:int">314</value> > </value> > </options> > </login> > > 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) <[EMAIL PROTECTED]> 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: > > > > > > > > - <complexType name="ArrayOfNamedValue"> > > > - <sequence> > > > <element name="item" type="impl:NamedValue" minOccurs="0" > maxOccurs="unbounded" /> > </sequence> > </complexType> > I exposed this method: > NamedValue[] login(String username, String password, NamedValue[] options) > Which in the WSDL the request looks like this: > > > > - <element name="login"> > > > - <complexType> > > > - <sequence> > > > <element name="username" type="xsd:string" /> > > <element name="password" type="xsd:string" /> > > <element name="options" type="impl:NamedValue" > maxOccurs="unbounded" /> > </sequence> > </complexType> > </element> > And the response like this: > > > > - <element name="loginResponse"> > > > - <complexType> > > > - <sequence> > > > <element name="loginReturn" type="impl:NamedValue" > maxOccurs="unbounded" /> > </sequence> > </complexType> > </element> > 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 <--- 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)? > > <login xmlns="http://some/namespace"> > <username>tim</username> > <password>tim</password> > <options> > <name>dummy1</name> > <value xsi:type="xsd:string">dummy_val1</value> > </options> > <options> > <name>dummy2</name> > <value xsi:type="ns1:NamedValue" xmlns:ns1="http://some/namespace"> > <name>dummy2-1</name> > <value xsi:type="xsd:string">val2-1</value> > </value> > <value xsi:type="ns2:NamedValue" xmlns:ns2="http://some/namespace"> > <name>dummy2-2</name> > <value xsi:type="xsd:int">314</value> > </value> > </options> > </login> > > 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 <options> tag come from)? > > It looks to me as if the message corresponds to the request. Because > you're using <xsd:anytype>, 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) <[EMAIL PROTECTED]> 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: > > <complexType name="NamedValue"> > <sequence> > <element name="name" nillable="true" type="xsd:string" /> > <element name="value" nillable="true" type="xsd:anyType" /> > </sequence> > </complexType> > > 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: > > <login xmlns="http://some/namespace"> > <username>tim</username> > <password>tim</password> > <options> > <name>dummy1</name> > <value xsi:type="xsd:string">dummy_val1</value> > </options> > <options> > <name>dummy2</name> > <value xsi:type="ns1:NamedValue" xmlns:ns1="http://some/namespace"> > <name>dummy2-1</name> > <value xsi:type="xsd:string">val2-1</value> > </value> > <value xsi:type="ns2:NamedValue" xmlns:ns2="http://some/namespace"> > <name>dummy2-2</name> > <value xsi:type="xsd:int">314</value> > </value> > </options> > </login> > > 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 > > > > > > > > > > > > > -- Davanum Srinivas - http://webservices.apache.org/~dims/
