HTTP POST and <ArrayOfAnyType> Problem - Solution needed

Last post 07-07-2009 5:45 PM by johnwsaunders3. 3 replies.

Sort Posts:

  • HTTP POST and <ArrayOfAnyType> Problem - Solution needed

    06-30-2009, 9:51 AM
    • Member
      174 point Member
    • a.karthik
    • Member since 06-01-2009, 3:54 PM
    • Posts 37

    Hi All,

    I am working on developing a web service that returns an array list. Apart from SOAP, I had to enable HTTP POST and GET also.
    Initially the web service was returning the ArrayList as ArrayOfAnyType and the individual items as <anyType />. I was able to solve this problem using
    the [return :XmlElement(typeof(Data))] attribute

    But this method doesn't work for HTTP POST / GET. I searched through the entire web for a solution to this, but it was in vain.

    A lot of people have posted this question, but no answers. It would be of great help not only to me, but a bunch of other people, if
    somebody could answer this question. The following is the response I get if I am invoking the web service through POST.

    With SOAP response I don't have any problem as I said before.

    Following is the way in which I get the reponse for POST/GET

    <?xml version="1.0" encoding="utf-8"?>
    <ArrayOfAnyType xmlns="GetData.asmx">
      <anyType />
      <anyType />
    </ArrayOfAnyType>
    


    That is, the reposne i am getting is like


    <?xml version="1.0" encoding="utf-8"?>
    <ArrayOfAnyType xmlns="GetData.asmx">
      <anyType xsi:type="Data">
           <a>...</a>
           <b>...</b>
      </anyType>
      <anyType xsi:type="Data">
           <a>...</a>
           <b>...</b>
      </anyType>
      <anyType xsi:type="Data">
           <a>...</a>
           <b>...</b>
      </anyType>
    </ArrayOfAnyType>
    
    
    


    How do i make it similar to a SOAP response like


    <Data>

      <a>...</a>

      <b>....</b>

    </Data>

    ....


    This is the class I am trying to return

    class Data
    {
    	public string a;
    	public string b;
    }
    

    Thanks in advance, Appreciate any response regarding this.

    ~ Karthik
    !  My Blog
  • Re: HTTP POST and <ArrayOfAnyType> Problem - Solution needed

    07-05-2009, 7:27 PM
    Answer

    Are you stuck using .NET 1.1? If not, then you should not use ArrayList. Instead, use List<Data>.

    John Saunders
  • Re: HTTP POST and <ArrayOfAnyType> Problem - Solution needed

    07-07-2009, 5:04 PM
    • Member
      174 point Member
    • a.karthik
    • Member since 06-01-2009, 3:54 PM
    • Posts 37

    Thanks for replying John. No I am not using .Net 1.1, its 3.5. I don't have problems with SOAP methods as I use XmlInclude to solve the problem on the SOAP front. But for HTTP POST/GET calls, the inclusion of XmlInclude does not work out. So as of now, I am using .aspx pages that sets the response type to XML, apart from having the .asmx pages.


    ~ Karthik
    !  My Blog
  • Re: HTTP POST and <ArrayOfAnyType> Problem - Solution needed

    07-07-2009, 5:45 PM

    Great. My point was that ArrayList is deprecated, and you should not be using it.

    John Saunders
Page 1 of 1 (4 items)