"Gustaf" <gustafl@algonet.se> wrote in message
news:OBP4Ubp0HHA.3536@TK2MSFTNGP06.phx.gbl...
> In the thread "Library differences when adding Web Reference" I reported a
> case where a client app couldn't access all the classes exposed by a Web
> Service. I've returned to this problem again, and found that it's a
> 'maxOccurs' attribute in the schema that causes it. Here's an example
> schema:
>
> <?xml version="1.0" encoding="utf-8"?>
> <xs:schema
> xmlns="
http://example.org/Foo" > xmlns:xs="
http://www.w3.org/2001/XMLSchema" > targetNamespace="
http://example.org/Foo" > elementFormDefault="qualified">
>
> <xs:complexType name="BookType">
> <xs:sequence>
> <xs:element name="Title" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
>
> <xs:complexType name="BookListType">
> <xs:sequence>
> <xs:element name="Book" type="BookType" maxOccurs="2"/>
> </xs:sequence>
> </xs:complexType>
>
> <xs:element name="BookList" type="BookListType"/>
>
> </xs:schema>
>
> If maxOccurs > 1 on the Book element, it causes the BookListType.Book
> property to be an array:
>
> public BookType[] Book { set; get; }
>
> This appears to be correct, so there's no problem with the code generated
> by xsd.exe. I import the generated classes, and replace the HelloWorld()
> method with this in Service.asmx:
>
> [WebMethod]
> public BookListType GetBookList()
> {
> return null;
> }
>
> Now I got a Web Service, which the following public members:
>
> public class Service : System.Web.Services.WebService
> public BookListType GetBookList()
> public Service()
>
> public class BookListType
> public BookType[] Book { set; get; }
>
> public class BookType
> public string Title { set; get; }
>
> Next step is to use the Web Service from a client app. But when I add a
> Web Reference to this Web Service, the BookListType class *disappears*. If
> I set maxOccurs to '1' in the schema, regenerate the proxy, build and
> update the reference, it doesn't disappear. So the "Add Web Reference..."
> wizard in .NET doesn't support Web Services with array parameters. I guess
> it's a bug in the wizard. Can you add the reference manually, without the
> wizard, and thereby get access to the BookListType class? Or do I need to
> use another platform than .NET to test my Web Service?
Also, please remind us which version of .NET you're using.