Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / October 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
m4gnus@gmail.com - 04 Oct 2006 09:44 GMT
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.
Gaurav Vaish (www.EdujiniOnline.com) - 08 Oct 2006 18:21 GMT
>   /// <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))]

Signature

Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujinionline.com
http://eduzine.edujinionline.com
-----------------------------------------

m4gnus@gmail.com - 27 Oct 2006 14:47 GMT
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.
[quoted text clipped - 26 lines]
> http://eduzine.edujinionline.com
> -----------------------------------------

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.