Problem with WS method returning an array of complex type

I

isbjoern04

Hi,

I developped a WS with IBM tools and used the wsdl in Visual Studio
2003 to add a Web Reference in my client.

I have no problems with methods returning a simple type (ex. boolean)
or complexType (ex. AccountInfo (a class defined by myself)).

Though I got en empty object, when I am calling a method returning an
array of complex type (AccountInfo). I checked the SOAP message and
it contains all the informations.

In the wsdl the array is defined by an unbouned element:
<complexType name="AccountInfo">
<sequence>
<element name="number" type="xsd:long"/>
<element name="owner" nillable="true"
type="xsd:string"/>
<element name="label" nillable="true"
type="xsd:string"/>
<element name="rubrique" nillable="true"
type="xsd:string"/>
<element name="balance" type="xsd:long"/>
<element name="currencyIso" nillable="true"
type="xsd:string"/>
<element name="availableAmount"
type="xsd:long"/>
</sequence>
</complexType>
<element name="getAccountsResponse">
<complexType>
<sequence>
<element maxOccurs="unbounded"
name="getAccountsReturn" type="impl:AccountInfo"/>
</sequence>
</complexType>
</element>

Did someone return successfully an array (of simple or complex) type
in a ws method call?

:)
Anne C.
 
M

Mickey Williams

What does the response look like on the wire? Can you change the web service
to doc/literal? I've seen some rpc/encoded web services written so that the
arrays are returned naked - instead of this:
<foos>
<foo/>
<foo/>
<foo/>
</foos>

You get:
<foo/>
<foo/>
<foo/>


--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com/blogs/mickey



isbjoern04 said:
Hi,

I developped a WS with IBM tools and used the wsdl in Visual Studio
2003 to add a Web Reference in my client.

I have no problems with methods returning a simple type (ex. boolean)
or complexType (ex. AccountInfo (a class defined by myself)).

Though I got en empty object, when I am calling a method returning an
array of complex type (AccountInfo). I checked the SOAP message and
it contains all the informations.

In the wsdl the array is defined by an unbouned element:
<complexType name="AccountInfo">
<sequence>
<element name="number" type="xsd:long"/>
<element name="owner" nillable="true"
type="xsd:string"/>
<element name="label" nillable="true"
type="xsd:string"/>
<element name="rubrique" nillable="true"
type="xsd:string"/>
<element name="balance" type="xsd:long"/>
<element name="currencyIso" nillable="true"
type="xsd:string"/>
<element name="availableAmount"
type="xsd:long"/>
</sequence>
</complexType>
<element name="getAccountsResponse">
<complexType>
<sequence>
<element maxOccurs="unbounded"
name="getAccountsReturn" type="impl:AccountInfo"/>
</sequence>
</complexType>
</element>

Did someone return successfully an array (of simple or complex) type
in a ws method call?

:)
Anne C.
 
I

isbjoern04

Hi,

It is already in doc/literal.

The repsonse looks like this:

HTTP/1.1 200 OK
Server: WebSphere Application Server/5.0
Content-Type: text/xml; charset=utf-8
Content-Language: fr-CH
Connection: close

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getAccountsResponse xmlns="NameSpaceName">
<ns-269198536:AccountInfo
xmlns:ns-269198536="NameSpaceName">
<ns-269198536:number>5566</ns-269198536:number>
<ns-269198536:blush:wner>BQUE PIGUET CIE YVERDON
</ns-269198536:blush:wner>
<ns-269198536:label>VOSTRO</ns-269198536:label>
<ns-269198536:rubrique/>
<ns-269198536:balance>15577899</ns-269198536:balance>
<ns-269198536:currencyIso>USD</ns-269198536:currencyIso><ns-269198536:availableAmount>15577899</ns-269198536:availableAmount></ns-269198536:AccountInfo>
<ns-269198536:AccountInfo xmlns:ns-269198536="NameSpaceName">
<ns-269198536:number>9575751</ns-269198536:number><ns-269198536:blush:wner>MUSIO
MICHELE </ns-269198536:blush:wner>
<ns-269198536:label>BCV RAPID</ns-269198536:label>
<ns-269198536:rubrique/>
<ns-269198536:balance>428346</ns-269198536:balance>
<ns-269198536:currencyIso>CHF</ns-269198536:currencyIso>
<ns-269198536:availableAmount>428346</ns-269198536:availableAmount></ns-269198536:AccountInfo>
</getAccountsResponse>
</soapenv:Body>
</soapenv:Envelope>
 
R

Richard Sypriano

Does anyone know if this got resolved. I have the same problem except I
created the client and service with Visual Studio 2003 from a WSDL I
built by hand. I get back an array with objects in it; but all the
values inside the objects are blank.
 
G

Girish bharadwaj

Are the objects that are being pushed into the array serializable? I believe
you need to have public fields within those objects if you dont explicitly
implement ISerializable interface.
 
R

Richard Sypriano

Thanks for your response.

The object is defined as

<s:complexType name="BlanketPOs">
<s:sequence>
<s:element maxOccurs="1" minOccurs="1" name="BlanketPONumber"
type="s:string"/>
<s:element maxOccurs="1" minOccurs="1" name="BlanketPOAmount"
type="s:double"/>
<s:element maxOccurs="1" minOccurs="1"
name="BlanketPOAmtRemaining" type="s:double"/>
<s:element maxOccurs="1" minOccurs="1"
name="BlanketPOExpiration" type="s:date"/>
</s:sequence>
</s:complexType>

in the WSDL. After adding the web reference to the project I use the
web reference to create one of these objects, populate its properties
them loaded it into the array. Here is the code


public int MaxAccountGetDetail (out WebReference.BlanketPOs[]
blanketPOs)

blanketPOs = new WebReference.BlanketPOs[1];

blanketPO = new WebReference.BlanketPOs();
blanketPOs.SetValue(blanketPO, 0);

blanketPO.BlanketPOAmount = 2222.22;
blanketPO.BlanketPOAmtRemaining = 0.0;
blanketPO.BlanketPOExpiration = DateTime.MaxValue;
blanketPO.BlanketPONumber = "1234"

return 1;

All of the properties are serializable and public otherwise I wouldn't
have access to them. I believe if all the properties of a class are
serializable then the class is serializable. Does this answer your
question or am I missing something?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top