Transfering structure from WebService

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

    #1

    Transfering structure from WebService

    It's well known that IDictionary collections present run-time exceptions if
    you attempt to serialize them across Web service boundaries.

    I need transfer data from this struct:

    private struct OnlineRecordDat a
    {
    public string WITS;
    public float Value;
    ....
    }

    I use this technic to transfer data:

    [WebMethod]
    public List<stringOnli neRecord()
    {
    // data sample
    OnlineRecordDat a[] a = new OnlineRecordDat a[100];
    // populate a[] from database...

    List<stringr = new List<string>();

    for (int i = 0; i <= a.GetUpperBound (0); i++)
    {
    r.Add(a[i].WITS + "=" + a[i].Value.ToString ("E"));
    }
    return r;
    }

    My question is: Is there is some way to write this more efficient code? ...
    I need the best speed

    Thanks in advanced,
    <Harvey Triana />


  • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

    #2
    Re: Transfering structure from WebService

    Harvey Triana wrote:
    It's well known that IDictionary collections present run-time exceptions if
    you attempt to serialize them across Web service boundaries.
    >
    I need transfer data from this struct:
    >
    private struct OnlineRecordDat a
    {
    public string WITS;
    public float Value;
    ....
    }
    >
    I use this technic to transfer data:
    >
    [WebMethod]
    public List<stringOnli neRecord()
    {
    // data sample
    OnlineRecordDat a[] a = new OnlineRecordDat a[100];
    // populate a[] from database...
    >
    List<stringr = new List<string>();
    >
    for (int i = 0; i <= a.GetUpperBound (0); i++)
    {
    r.Add(a[i].WITS + "=" + a[i].Value.ToString ("E"));
    }
    return r;
    }
    >
    My question is: Is there is some way to write this more efficient code? ...
    I need the best speed
    The best solution from a object oriented and portability aspect would be
    to return an array of your class.

    In your code return a.

    Just make OnlineRecordDat a serializable (and possible use private fields
    and public properties).

    Arne

    Comment

    • Harvey Triana

      #3
      Re: Transfering structure from WebService

      Do you mean me that with BinaryFormatter is more efficient?

      <Harvey Triana />


      "Arne Vajhøj" <arne@vajhoej.d kescribió en el mensaje
      news:47236c6c$0 $90268$14726298 @news.sunsite.d k...
      Harvey Triana wrote:
      >It's well known that IDictionary collections present run-time exceptions
      >if you attempt to serialize them across Web service boundaries.
      >>
      >I need transfer data from this struct:
      >>
      > private struct OnlineRecordDat a
      > {
      > public string WITS;
      > public float Value;
      > ....
      > }
      >>
      >I use this technic to transfer data:
      >>
      > [WebMethod]
      > public List<stringOnli neRecord()
      > {
      > // data sample
      > OnlineRecordDat a[] a = new OnlineRecordDat a[100];
      > // populate a[] from database...
      >>
      > List<stringr = new List<string>();
      >>
      > for (int i = 0; i <= a.GetUpperBound (0); i++)
      > {
      > r.Add(a[i].WITS + "=" + a[i].Value.ToString ("E"));
      > }
      > return r;
      > }
      >>
      >My question is: Is there is some way to write this more efficient code?
      >... I need the best speed
      >
      The best solution from a object oriented and portability aspect would be
      to return an array of your class.
      >
      In your code return a.
      >
      Just make OnlineRecordDat a serializable (and possible use private fields
      and public properties).
      >
      Arne

      Comment

      • Harvey Triana

        #4
        Re: Transfering structure from WebService

        Or, with SoapFormatter (i use WebServices) ... ?

        <Harvey Triana />

        "Harvey Triana" <harveytriana@h otmail.comescri bió en el mensaje
        news:%23OB0vAjG IHA.1548@TK2MSF TNGP05.phx.gbl. ..
        Do you mean me that with BinaryFormatter is more efficient?
        >
        <Harvey Triana />
        >
        >
        "Arne Vajhøj" <arne@vajhoej.d kescribió en el mensaje
        news:47236c6c$0 $90268$14726298 @news.sunsite.d k...
        >Harvey Triana wrote:
        >>It's well known that IDictionary collections present run-time exceptions
        >>if you attempt to serialize them across Web service boundaries.
        >>>
        >>I need transfer data from this struct:
        >>>
        >> private struct OnlineRecordDat a
        >> {
        >> public string WITS;
        >> public float Value;
        >> ....
        >> }
        >>>
        >>I use this technic to transfer data:
        >>>
        >> [WebMethod]
        >> public List<stringOnli neRecord()
        >> {
        >> // data sample
        >> OnlineRecordDat a[] a = new OnlineRecordDat a[100];
        >> // populate a[] from database...
        >>>
        >> List<stringr = new List<string>();
        >>>
        >> for (int i = 0; i <= a.GetUpperBound (0); i++)
        >> {
        >> r.Add(a[i].WITS + "=" + a[i].Value.ToString ("E"));
        >> }
        >> return r;
        >> }
        >>>
        >>My question is: Is there is some way to write this more efficient code?
        >>... I need the best speed
        >>
        >The best solution from a object oriented and portability aspect would be
        >to return an array of your class.
        >>
        >In your code return a.
        >>
        >Just make OnlineRecordDat a serializable (and possible use private fields
        >and public properties).
        >>
        >Arne
        >
        >

        Comment

        • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

          #5
          Re: Transfering structure from WebService

          Harvey Triana wrote:
          Do you mean me that with BinaryFormatter is more efficient?
          Binary is absolutely faster than SOAP XML.

          But it would not be a real web service anymore.

          Arne

          Comment

          Working...