Transfering structure from WebService

  • Thread starter Thread starter Harvey Triana
  • Start date Start date
H

Harvey Triana

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 OnlineRecordData
{
public string WITS;
public float Value;
....
}

I use this technic to transfer data:

[WebMethod]
public List<string> OnlineRecord()
{
// data sample
OnlineRecordData[] a = new OnlineRecordData[100];
// populate a[] from database...

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

for (int i = 0; i <= a.GetUpperBound(0); i++)
{
r.Add(a.WITS + "=" + a.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 />
 
Harvey said:
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 OnlineRecordData
{
public string WITS;
public float Value;
....
}

I use this technic to transfer data:

[WebMethod]
public List<string> OnlineRecord()
{
// data sample
OnlineRecordData[] a = new OnlineRecordData[100];
// populate a[] from database...

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

for (int i = 0; i <= a.GetUpperBound(0); i++)
{
r.Add(a.WITS + "=" + a.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 OnlineRecordData serializable (and possible use private fields
and public properties).

Arne
 
Do you mean me that with BinaryFormatter is more efficient?

<Harvey Triana />


Arne Vajhøj said:
Harvey said:
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 OnlineRecordData
{
public string WITS;
public float Value;
....
}

I use this technic to transfer data:

[WebMethod]
public List<string> OnlineRecord()
{
// data sample
OnlineRecordData[] a = new OnlineRecordData[100];
// populate a[] from database...

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

for (int i = 0; i <= a.GetUpperBound(0); i++)
{
r.Add(a.WITS + "=" + a.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 OnlineRecordData serializable (and possible use private fields
and public properties).

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

<Harvey Triana />

Harvey Triana said:
Do you mean me that with BinaryFormatter is more efficient?

<Harvey Triana />


Arne Vajhøj said:
Harvey said:
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 OnlineRecordData
{
public string WITS;
public float Value;
....
}

I use this technic to transfer data:

[WebMethod]
public List<string> OnlineRecord()
{
// data sample
OnlineRecordData[] a = new OnlineRecordData[100];
// populate a[] from database...

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

for (int i = 0; i <= a.GetUpperBound(0); i++)
{
r.Add(a.WITS + "=" + a.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 OnlineRecordData serializable (and possible use private fields
and public properties).

Arne

 
Harvey said:
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
 
Back
Top