locked
return ArrayofString from web service RRS feed

  • Question

  • I am required to use an .asmx web service and one of the properties  "To" of the web service expects a value of type ArrayOfString. I am using C# 4.0. I cant seem to find out how I can assign a value to this property of this type.

    All the below fails

              var arr3 = new string[] { "test@test.com" };

                msg.To = arr3;

    or
                List<string> toList = new List<string>();

    toList.Add("test@test.com");
                msg.To = toList;

    Monday, December 17, 2012 10:58 PM

Answers

  • Hi,

    According research, if you want to get the string[] in the client in one of two ways suggested in this post:

    • a) by creating a WCF service instead of an ASMX service, and using Add Service Reference.
    • b) by keeping the asmx service, and using Add Web Reference instead of Add Service Reference.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Haixia_Xie Monday, December 24, 2012 9:56 AM
    Wednesday, December 19, 2012 2:55 AM

All replies

  • Please check out this

    List<string> msg { get; set; }
    string[] mylist = new string[5]; 
    mylist[0] = "Hello";            
    mylist[1] = "how";            
    mylist[2] = "are";            
    mylist[3] = "you";           
    mylist[4] = "?";
    msg = new List<string>(mylist.Length);
    msg.AddRange(mylist);


    With Thanks and Regards
    Sambath Raj.C
    click "Proposed As Answer by" if this post solves your problem or "Vote As Helpful" if a post has been useful to you
    Happy Programming!

    Tuesday, December 18, 2012 10:19 AM
  • that didnt work.

    The strange thing is If I add the same web service as a classic .asmx reference, the ".TO"
     property is showing a string array "string[]". If I add it as a service reference it changes to "ArrayOfString". Why is that? And can i add a service reference that maintains the string[] property type?


    • Edited by spark29er Tuesday, December 18, 2012 4:05 PM
    Tuesday, December 18, 2012 3:46 PM
  • Hi,

    According research, if you want to get the string[] in the client in one of two ways suggested in this post:

    • a) by creating a WCF service instead of an ASMX service, and using Add Service Reference.
    • b) by keeping the asmx service, and using Add Web Reference instead of Add Service Reference.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Haixia_Xie Monday, December 24, 2012 9:56 AM
    Wednesday, December 19, 2012 2:55 AM