I am not clear. Seems there are two issues,
1. SOAP encoding (blaaaach!) vs
Literal
2. wrapped or bare arrays
Let's stay away from SOAPENC:arrayType since we all listen to
WS-I.
So, on issue #2, are you
asking, does .NET expect arrays embedded in types to be serialized
as [Example 1]:
<Container>
<param1> foo</param1>
<wrapper>
<param2>bar</param2>
<param2>blah</param2>
...
</wrapper>
</Container>
or as [Example 2]
<Container>
<param1> foo</param1>
<param2>bar</param2>
<param2>blah</param2>
...
</Container>
?
The answer is, .NET can go either way. It takes its
cue from the WSDL.
If the WSDL uses a complexType to wrap an array, such as
this:
<s:complexType name="Container">
<s:sequence> <s:element minOccurs="1" maxOccurs="1" name="param1" nillable="true" type="s:string" /> <s:element minOccurs="1" maxOccurs="1" name="wrapper" nillable="true" type="tns:ArrayOfString" /> </s:sequence> </s:complexType> <s:complexType name="ArrayOfString"> <s:sequence> <s:element minOccurs="0" maxOccurs="unbounded" name="param2" type="s:string" /> </s:sequence> </s:complexType> ... then .NET will expect the XML on the wire to be
"wrapped", as in [Example 1] above. If the WSDL does not use a complexType
to wrap the array, but instead uses an element with maxOccurs != 1, like so:
<s:complexType name="Container">
<s:sequence> <s:element minOccurs="1" maxOccurs="1" name="param1" nillable="true" type="s:string" /> <s:element minOccurs="0" maxOccurs="unbounded" name="param2" type="s:string" /> </s:sequence> </s:complexType> ...then .NET will expect XML on the wire that does not wrap
the array in an element, such as in [Example 2] above.
So you can do whatever.
> what
format do people usually use?
I guess it's a matter of style and taste. From
the app programmer's perspective, the generated type on the .NET side behaves
the same. It looks like this:
public class Container {
public string param1;
public string[] param2;
}
The metadata attached to the type (in the form of inline
code attributes) tells the .NET XML serializer whether to use a wrapper
element or not.
So the differences in on-the-wire serialization don't
bubble up to the .NET programmer. Personally I find the use of "ArrayOfX" to be
clunky in the WSDL and XSD. But it reads more nicely in the
serialized XML, and so I generally prefer it in complex schema. In
simple schema, I don't care.
-D From: Bill Keese [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 16, 2005 9:18 PM Cc: [EMAIL PROTECTED] Subject: Re: rpc/literal vs document/literal, and returning a list of objects ArraySerializer v1.5 checkin comment: Support serializing Arrays in "literal" fashion (a .NET-ism). We introduce an "isEncoded" flag on the MessageContext for now - this really wants to get set to the encoding state we're in at present, but I couldn't figure out how to coax that out of the serialization code yet. Let's say we have: class Bean { public String field1; public String [] field2; } if isEncoded is true (the default), we get XML that looks like: <bean> <field1>hi there</field1> <field2 SOAPENC:arrayType="xsd:string[2]"> <item>1</item> <item>2</item> </field2> </bean> whereas if isEncoded is false, we now get: <bean> <field1>hi there</field1> <field2>1</field2> <field2>2</field2> </bean> TODOs: 1) Figure out how to get encodingStyle for real 2) Implement deserializing from arrays encoded like thisBill Bill Keese wrote: Hi Dino, |
- RE: rpc/literal vs document/literal, and returni... Dino Chiesa
- Re: rpc/literal vs document/literal, and re... Bill Keese
- Re: rpc/literal vs document/literal, an... Bill Keese
- Re: rpc/literal vs document/literal, and re... Dino Chiesa
- Re: rpc/literal vs document/literal, an... Bill Keese
- Re: rpc/literal vs document/literal... Sebastien Mayemba Mbokoso