Data Type to implement ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Swapnil2006

    Data Type to implement ?

    I am using the SOAP 1.1 request and response to create a corresponding web
    method for it.
    SOAP 1.1 response looks like as follows :

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelop e xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
    xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/">
    <soap:Body>
    <GetPostsRespon se xmlns="http://tempuri.org/">
    <PostSet>
    <TotalRecords>i nt</TotalRecords>
    <Posts>
    <anyType />
    <anyType />
    </Posts>
    </PostSet>
    </GetPostsRespons e>
    </soap:Body>
    </soap:Envelope>

    However the SOAP 1.1 response generated for the web method I am writing is
    as follows:

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelop e xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
    xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/">
    <soap:Body>
    <GetPostsRespon se xmlns="http://tempuri.org/">
    <GetPostsResult >
    <PostSet>
    <TotalRecords xmlns="http://namespace.org/">int</TotalRecords>
    <Posts xmlns="http://namespace.org/">
    <anyType />
    <anyType />
    </Posts>
    </PostSet>
    <PostSet>
    <TotalRecords xmlns="http://namespace.org/">int</TotalRecords>
    <Posts xmlns="http://namespace.org/">
    <anyType />
    <anyType />
    </Posts>
    </PostSet>
    </GetPostsResult>
    </GetPostsRespons e>
    </soap:Body>
    </soap:Envelope>

    The dummy web method I have written is as follows

    [WebMethod]
    public PostSet[] GetPosts(int postID, int pageIndex, int pageSize, int
    sortBy, int sortOrder, int userID, bool returnRecordCou nt)
    {
    PostSet[] _ArrPostSet = new PostSet[0];
    int dt = 0;
    _ArrPostSet[0].TotalRecords = dt;
    object[] test = new object[1];
    _ArrPostSet[0].Posts = test;
    return _ArrPostSet;

    }
    where PostSet is a class
    What Data Type should I implement to generate a soap response as above.?

  • reez

    #2
    Re: Data Type to implement ?

    do you want to return only one post set? if so then don't return an
    array and you'll basically get the response you listed above with the
    exception of the getpostsresult tag....i removed this before....if i
    find the code i'll post it here

    Comment

    • swapnil2006

      #3
      Re: Data Type to implement ?

      Thanks .. I implemented a Partial class as PostSet and changed the return
      type to PostSet .
      added XmlElementAttri bute attribute. Code snippnet is below.

      [WebMethod]
      [return: System.Xml.Seri alization.XmlEl ementAttribute( "PostSet",
      IsNullable = true)]
      public PostSet GetPosts(int postID, int pageIndex, int pageSize, int
      sortBy, int sortOrder, int userID, bool returnRecordCou nt)
      {
      PostSet _PostSet = new PostSet();
      int dt = 0;
      _PostSet.TotalR ecords = dt;
      object[] test = new object[1];
      _PostSet.Posts = test;
      return _PostSet;
      }

      "reez" wrote:
      [color=blue]
      > do you want to return only one post set? if so then don't return an
      > array and you'll basically get the response you listed above with the
      > exception of the getpostsresult tag....i removed this before....if i
      > find the code i'll post it here
      >
      >[/color]

      Comment

      Working...