Where to put schema when using custom collection?

Discussion in 'ASP .Net Web Services' started by Whoever, Nov 11, 2004.

  1. Whoever

    Whoever Guest

    See below. The WSDL looks good, the result is OK but not Schema. Where and
    how should I put it in. Hopfully not manually. Thanks.

    public class aUser {
    public string UserID { get {...} set {...}
    public string UserName {...}
    }

    public class UserList : System.Collection.CollectionBase {
    public void Add(aUser user) {...}
    public aUser this[int Index] {...}
    }

    A web service:

    [WebMethod]
    [return: XmlElement("UserList", typeof(UserList))]
    public UserList getUserList(string search) {
    UserList ul = new UserList();
    return ul;
    }
     
    Whoever, Nov 11, 2004
    #1
    1. Advertising

  2. Whoever

    Dan Rogers Guest

    Hi,

    You didn't mention what you would like the schema to look like. Given this
    code, I'd expect the schema to be a single element that is returned as an
    array. Depending on what you want to happen, there are a number of
    attributes provided that let you get different results, both in the way the
    instance of the XML look on the wire, as well as the type information
    exposed in the schema that is generated from the automatic documentation
    feature of ASP.NET.

    In general, you need to use XmlTypeAttribute to change information seen in
    the schema. Any attribute such as XmlRoot, XmlElement and XmlAttribute
    will effect the shape seen in the generated schema. For specific "how do I
    get it to look like this" and you have a schema in mind already, take the
    schema you expected and use a tool such as XSD.exe, WSDL.exe or even
    XsdObjectGen.exe to create classes from the schema. Then look at the way
    the generated code uses attributes to effect the shape of the generated
    schema.

    I hope this helps,

    Dan Rogers
    Microsoft Corporation
    --------------------
    >From: "Whoever" <>
    >Subject: Where to put schema when using custom collection?
    >Date: Wed, 10 Nov 2004 21:43:26 -0500
    >Lines: 23
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.3790.181
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181
    >Message-ID: <#>
    >Newsgroups:

    microsoft.public.dotnet.framework.webservices,microsoft.public.dotnet.framew
    ork.aspnet.webservices,microsoft.public.dotnet.framework.aspnet
    >NNTP-Posting-Host: mskresolve-1.mskcc.org 140.163.53.249
    >Path:

    cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10
    phx.gbl
    >Xref: cpmsftngxa10.phx.gbl

    microsoft.public.dotnet.framework.aspnet.webservices:26444
    microsoft.public.dotnet.framework.aspnet:275226
    microsoft.public.dotnet.framework.webservices:7360
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    >
    >See below. The WSDL looks good, the result is OK but not Schema. Where

    and
    >how should I put it in. Hopfully not manually. Thanks.
    >
    >public class aUser {
    > public string UserID { get {...} set {...}
    > public string UserName {...}
    >}
    >
    >public class UserList : System.Collection.CollectionBase {
    > public void Add(aUser user) {...}
    > public aUser this[int Index] {...}
    >}
    >
    >A web service:
    >
    >[WebMethod]
    >[return: XmlElement("UserList", typeof(UserList))]
    >public UserList getUserList(string search) {
    > UserList ul = new UserList();
    > return ul;
    >}
    >
    >
    >
     
    Dan Rogers, Nov 15, 2004
    #2
    1. Advertising

  3. Whoever

    Whoever Guest

    Thanks for the reply.

    I do use XmlElement/XmlAttribute to customize the result, it shows up in the
    WSDL.

    The problem is I don't know how to make schema to show up at all. I want it
    to come in front of the data when you call the service. Any idea?
    Reference etc? Thanks.

    WSDL:
    HTTP/1.1 200 OK
    Content-Type: text/xml; charset=utf-8
    Content-Length: length

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <getUserListResponse>
    <UserList>
    <aUser>
    <User_Id>string</User_Id>
    <Name>string</Name>
    <Phone_Num>string</Phone_Num>
    </aUser> <aUser>
    <User_Id>string</User_Id>
    <Name>string</Name>
    <Phone_Num>string</Phone_Num>
    </aUser>
    </UserList>
    </getUserListResponse>
    </soap:Body>
    </soap:Envelope>Result..... Need Schema Here .... <?xml version="1.0"
    encoding="utf-8" ?> - <ArrayOfAUser
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">- <aUser> <User_ID />
    <Name>Whoever</Name> <Phone_Num>123456</Phone_Num> </aUser>....
    "Dan Rogers" <> wrote in message
    news:p...
    > Hi,
    >
    > You didn't mention what you would like the schema to look like. Given

    this
    > code, I'd expect the schema to be a single element that is returned as an
    > array. Depending on what you want to happen, there are a number of
    > attributes provided that let you get different results, both in the way

    the
    > instance of the XML look on the wire, as well as the type information
    > exposed in the schema that is generated from the automatic documentation
    > feature of ASP.NET.
    >
    > In general, you need to use XmlTypeAttribute to change information seen in
    > the schema. Any attribute such as XmlRoot, XmlElement and XmlAttribute
    > will effect the shape seen in the generated schema. For specific "how do

    I
    > get it to look like this" and you have a schema in mind already, take the
    > schema you expected and use a tool such as XSD.exe, WSDL.exe or even
    > XsdObjectGen.exe to create classes from the schema. Then look at the way
    > the generated code uses attributes to effect the shape of the generated
    > schema.
    >
    > I hope this helps,
    >
    > Dan Rogers
    > Microsoft Corporation
     
    Whoever, Nov 16, 2004
    #3
  4. Whoever

    Dan Rogers Guest

    Hi,

    In general, this is not how SOAP works. The schema is communicated to the
    interested observer as a part of the information referenced in the WSDL
    file. This file describes the service interface contract. At run time,
    the schema for the packet you are sending is not required, nor would it
    serve any purpose. The thinking is that the software that is processing a
    SOAP request has to have been compiled and prepared ahead of time. The
    contract that that software expects is published ahead of time, so that
    callers will only send what the service expects.

    Having a schema for the data you are sending is useful when you go to build
    software that either calls a service or processes a request that matches a
    given contract description. But communicating that schema as a part of the
    request doesn't facilitate any particularly useful purpose, so in general,
    you won't find a schema node included in the data transmission for SOAP
    traffic.

    I hope this helps,

    Dan Rogers
    Microsoft Corporation
    --------------------
    >From: "Whoever" <>
    >References: <#>

    <>
    >Subject: Re: Where to put schema when using custom collection?
    >Date: Tue, 16 Nov 2004 10:21:50 -0500
    >Lines: 68
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.3790.181
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181
    >Message-ID: <eIbAAA$>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    >NNTP-Posting-Host: mskresolve-1.mskcc.org 140.163.53.249
    >Path:

    cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15
    .phx.gbl
    >Xref: cpmsftngxa10.phx.gbl

    microsoft.public.dotnet.framework.aspnet.webservices:26602
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    >
    >Thanks for the reply.
    >
    >I do use XmlElement/XmlAttribute to customize the result, it shows up in

    the
    >WSDL.
    >
    >The problem is I don't know how to make schema to show up at all. I want

    it
    >to come in front of the data when you call the service. Any idea?
    >Reference etc? Thanks.
    >
    >WSDL:
    >HTTP/1.1 200 OK
    >Content-Type: text/xml; charset=utf-8
    >Content-Length: length
    >
    ><?xml version="1.0" encoding="utf-8"?>
    ><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    >xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    >xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    > <soap:Body>
    > <getUserListResponse>
    > <UserList>
    > <aUser>
    > <User_Id>string</User_Id>
    > <Name>string</Name>
    > <Phone_Num>string</Phone_Num>
    > </aUser> <aUser>
    > <User_Id>string</User_Id>
    > <Name>string</Name>
    > <Phone_Num>string</Phone_Num>
    > </aUser>
    > </UserList>
    > </getUserListResponse>
    > </soap:Body>
    ></soap:Envelope>Result..... Need Schema Here .... <?xml version="1.0"
    >encoding="utf-8" ?> - <ArrayOfAUser
    >xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    >xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">- <aUser> <User_ID

    />
    ><Name>Whoever</Name> <Phone_Num>123456</Phone_Num> </aUser>....
    >"Dan Rogers" <> wrote in message
    >news:p...
    >> Hi,
    >>
    >> You didn't mention what you would like the schema to look like. Given

    >this
    >> code, I'd expect the schema to be a single element that is returned as an
    >> array. Depending on what you want to happen, there are a number of
    >> attributes provided that let you get different results, both in the way

    >the
    >> instance of the XML look on the wire, as well as the type information
    >> exposed in the schema that is generated from the automatic documentation
    >> feature of ASP.NET.
    >>
    >> In general, you need to use XmlTypeAttribute to change information seen

    in
    >> the schema. Any attribute such as XmlRoot, XmlElement and XmlAttribute
    >> will effect the shape seen in the generated schema. For specific "how do

    >I
    >> get it to look like this" and you have a schema in mind already, take the
    >> schema you expected and use a tool such as XSD.exe, WSDL.exe or even
    >> XsdObjectGen.exe to create classes from the schema. Then look at the way
    >> the generated code uses attributes to effect the shape of the generated
    >> schema.
    >>
    >> I hope this helps,
    >>
    >> Dan Rogers
    >> Microsoft Corporation

    >
    >
    >
     
    Dan Rogers, Nov 16, 2004
    #4
  5. Whoever

    Whoever Guest

    This makes perfect sense. I got confused by DataSet which has type any in
    WSDL and schema as part of the returned data.

    Thank you very much.

    "Dan Rogers" <> wrote in message
    news:...
    > Hi,
    >
    > In general, this is not how SOAP works. The schema is communicated to the
    > interested observer as a part of the information referenced in the WSDL
    > file. This file describes the service interface contract. At run time,
    > the schema for the packet you are sending is not required, nor would it
    > serve any purpose. The thinking is that the software that is processing a
    > SOAP request has to have been compiled and prepared ahead of time. The
    > contract that that software expects is published ahead of time, so that
    > callers will only send what the service expects.
    >
    > Having a schema for the data you are sending is useful when you go to

    build
    > software that either calls a service or processes a request that matches a
    > given contract description. But communicating that schema as a part of

    the
    > request doesn't facilitate any particularly useful purpose, so in general,
    > you won't find a schema node included in the data transmission for SOAP
    > traffic.
    >
    > I hope this helps,
    >
    > Dan Rogers
    > Microsoft Corporation
    > --------------------
    > >From: "Whoever" <>
    > >References: <#>

    > <>
    > >Subject: Re: Where to put schema when using custom collection?
    > >Date: Tue, 16 Nov 2004 10:21:50 -0500
    > >Lines: 68
    > >X-Priority: 3
    > >X-MSMail-Priority: Normal
    > >X-Newsreader: Microsoft Outlook Express 6.00.3790.181
    > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181
    > >Message-ID: <eIbAAA$>
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    > >NNTP-Posting-Host: mskresolve-1.mskcc.org 140.163.53.249
    > >Path:

    >

    cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15
    > phx.gbl
    > >Xref: cpmsftngxa10.phx.gbl

    > microsoft.public.dotnet.framework.aspnet.webservices:26602
    > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    > >
    > >Thanks for the reply.
    > >
    > >I do use XmlElement/XmlAttribute to customize the result, it shows up in

    > the
    > >WSDL.
    > >
    > >The problem is I don't know how to make schema to show up at all. I want

    > it
    > >to come in front of the data when you call the service. Any idea?
    > >Reference etc? Thanks.
    > >
    > >WSDL:
    > >HTTP/1.1 200 OK
    > >Content-Type: text/xml; charset=utf-8
    > >Content-Length: length
    > >
    > ><?xml version="1.0" encoding="utf-8"?>
    > ><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    > >xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    > >xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    > > <soap:Body>
    > > <getUserListResponse>
    > > <UserList>
    > > <aUser>
    > > <User_Id>string</User_Id>
    > > <Name>string</Name>
    > > <Phone_Num>string</Phone_Num>
    > > </aUser> <aUser>
    > > <User_Id>string</User_Id>
    > > <Name>string</Name>
    > > <Phone_Num>string</Phone_Num>
    > > </aUser>
    > > </UserList>
    > > </getUserListResponse>
    > > </soap:Body>
    > ></soap:Envelope>Result..... Need Schema Here .... <?xml version="1.0"
    > >encoding="utf-8" ?> - <ArrayOfAUser
    > >xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    > >xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">- <aUser> <User_ID

    > />
    > ><Name>Whoever</Name> <Phone_Num>123456</Phone_Num> </aUser>....
    > >"Dan Rogers" <> wrote in message
    > >news:p...
    > >> Hi,
    > >>
    > >> You didn't mention what you would like the schema to look like. Given

    > >this
    > >> code, I'd expect the schema to be a single element that is returned as

    an
    > >> array. Depending on what you want to happen, there are a number of
    > >> attributes provided that let you get different results, both in the way

    > >the
    > >> instance of the XML look on the wire, as well as the type information
    > >> exposed in the schema that is generated from the automatic

    documentation
    > >> feature of ASP.NET.
    > >>
    > >> In general, you need to use XmlTypeAttribute to change information seen

    > in
    > >> the schema. Any attribute such as XmlRoot, XmlElement and XmlAttribute
    > >> will effect the shape seen in the generated schema. For specific "how

    do
    > >I
    > >> get it to look like this" and you have a schema in mind already, take

    the
    > >> schema you expected and use a tool such as XSD.exe, WSDL.exe or even
    > >> XsdObjectGen.exe to create classes from the schema. Then look at the

    way
    > >> the generated code uses attributes to effect the shape of the generated
    > >> schema.
    > >>
    > >> I hope this helps,
    > >>
    > >> Dan Rogers
    > >> Microsoft Corporation

    > >
    > >
    > >

    >
     
    Whoever, Nov 18, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lloyd Dupont
    Replies:
    0
    Views:
    463
    Lloyd Dupont
    Jul 27, 2003
  2. Whoever
    Replies:
    0
    Views:
    303
    Whoever
    Nov 11, 2004
  3. Markus
    Replies:
    1
    Views:
    1,545
    Markus
    Nov 23, 2005
  4. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,265
    Stanimir Stamenkov
    Apr 25, 2005
  5. Øyvind Isaksen
    Replies:
    1
    Views:
    981
    Øyvind Isaksen
    May 18, 2007
Loading...

Share This Page