WSDL does not show correct return type information for C# web service

Discussion in 'ASP .Net Web Services' started by m4gnus@gmail.com, Oct 4, 2006.

  1. Guest

    I have made a web service using C# and my problem is that the
    auto-generated WSDL-file does not show the correct type information for
    return parameters. It is desireable that it does because people who are
    to use the web service must know what it returns and it would be nice
    if they didn't have to ask me but instead just look in the WSDL-file.

    The method public MailboxStatus[] GetMailboxStatus(string[]
    extensions) returns a MailboxStatus[] which looks like this:
    public class MailboxStatus
    {
    /// <summary>
    /// The mailbox's id.
    /// </summary>
    private int id;

    /// <summary>
    /// The mailbox's user id.
    /// </summary>
    private int uid;

    /// <summary>
    /// The messages in the mailbox.
    /// </summary>
    private Message[] messages;
    }

    The 'id' and 'uid' are shown correctly in the WSDL but 'messages' is
    not. Like this:
    <GetMailboxStatusResponse xmlns="http://www.icepeak.se/webservices/">
    <GetMailboxStatusResult>
    <MailboxStatus>
    <Id>int</Id>
    <Uid>int</Uid>
    <Messages>
    <Message xsi:nil="true" />
    <Message xsi:nil="true" />
    </Messages>
    </MailboxStatus>
    </GetMailboxStatusResult>
    </GetMailboxStatusResponse>


    If I add [return:XmlArrayItem(typeof(Message))] above the
    GetMailboxStatus method 'messages' is shown correctly but instead 'id'
    and 'uid' are not, they are not shown at all actually. Like this:

    <GetMailboxStatusResponse xmlns="http://www.icepeak.se/webservices/">
    <GetMailboxStatusResult>
    <Message>
    <Id>int</Id>
    <Status>int</Status>
    <TimestampInUTC>dateTime</TimestampInUTC>
    <LengthInSeconds>int</LengthInSeconds>
    <ANumber>int</ANumber>
    <FileFormat>string</FileFormat>
    <Url>string</Url>
    </Message>
    </GetMailboxStatusResult>
    </GetMailboxStatusResponse>


    Any ideas on how to solve this so both 'id', 'uid' and 'messages' types
    are shown in the auto-generated WSDL?

    Looking forward to your helpful reponse
    Thanks in advance
    Magnus

    ps. I hope it was correct to post this here even though it's about
    something written in C#. If not, please inform me.
     
    , Oct 4, 2006
    #1
    1. Advertising

  2. Guest

    Thank you very much for responding to my question. It seems very few
    knows about this because I've asked around a lot and no one had the
    slighest idea.

    However, I did what you suggested but Message is still shown as before
    in the WSDL.
    I added:
    /// <summary>
    /// The messages in the mailbox.
    /// </summary>
    [XmlArray(ElementName = "WhatEver_Like_Messages", IsNullable=false)]
    [XmlArrayItem(Type = typeof(Message),
    ElementName="WhatEver_Like_Message")]
    private Message[] messages;
    (let's refer to XmlArray.. by A)

    and

    [return: XmlArray(ElementName="WhatEver_Like_MessageBoxStatusArray",
    IsNullable=false)]
    [return: XmlArrayItem(typeof(MailboxStatus))]
    public MailboxStatus[] GetMailboxStatus(string[] extensions)
    (let's refer to XmlArray.. by B)

    I seems very logical but still doesn't work...hmm
    Did I misunderstand something?

    If I comment out B, Message is shown correctly in the WSDL, but when I
    have both A and B, Message is shown as:
    <Messages>
    <Message xsi:nil="true" />
    <Message xsi:nil="true" />
    </Messages>

    In the HTTP POST section it looks like it should, but not in the SOAP
    section.

    Cheers
    Magnus


    Gaurav Vaish (www.EdujiniOnline.com) skrev:

    > > /// <summary>
    > > /// The messages in the mailbox.
    > > /// </summary>
    > > private Message[] messages;
    > > }

    >
    > Add attributes:
    > [XmlArray(ElementName = "WhatEver_Like_Messages", IsNullable=true/false)]
    > [XmlArrayItem(Type = typeof(Message), ElementName="WhatEver_Like_Message")]
    >
    > to the 'messages' field.
    >
    > > If I add [return:XmlArrayItem(typeof(Message))] above the
    > > GetMailboxStatus method 'messages' is shown correctly but instead 'id'
    > > and 'uid' are not, they are not shown at all actually. Like this:

    >
    > Because you've said that the items are are of type Message... and not
    > MailboxStatus.
    > It should have been:
    >
    > [return: XmlArray(ElementName="WhatEver_Like_MessageBoxStatusArray",
    > IsNullable=true/false)]
    > [return: XmlArrayItem(typeof(MailboxStatus))]
    >
    >
    >
    >
    > --
    > Happy Hacking,
    > Gaurav Vaish | www.mastergaurav.com
    > www.edujinionline.com
    > http://eduzine.edujinionline.com
    > -----------------------------------------
     
    , Oct 27, 2006
    #2
    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. Kiran
    Replies:
    3
    Views:
    776
  2. Ben Fidge
    Replies:
    5
    Views:
    3,119
    Giorgio
    Feb 11, 2006
  3. Bert Leu
    Replies:
    1
    Views:
    482
    Cowboy \(Gregory A. Beamer\)
    Nov 23, 2007
  4. Molalla Attenborough

    My webservice WSDL doesn't return any information about the elements.

    Molalla Attenborough, Dec 23, 2003, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    200
    BruceJohnson
    Dec 28, 2003
  5. Bert Leu

    Creating a Web Service (Service, not Client) from WSDL

    Bert Leu, Nov 23, 2007, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    296
    Cowboy \(Gregory A. Beamer\)
    Nov 23, 2007
Loading...

Share This Page