sending/receiving datasets from webservice

Hi

If sending/receiving datasets  from webservice is mandatory in an application , is there any better solution in CFv2.0 in replace of using dime attachments

Can i use  XmlSerializer   to convert datasets to bytes and pass that as parameter to webmethods or add to soap attachment instead of the dataset itself

Please advice

Thanks

Gauls

 




Answer this question

sending/receiving datasets from webservice

  • C#Coder

    The default serializes ds in XML but with XMLSerialize i can convert the DS to arraybytes ,and send as paramter to webmethod is this much better performance wise

  • eric1969

    Just declare Web method which takes/returns dataset, framework would take care of the rest.



  • xie tianmin

    Try http://gotcf.net. - BinaryFormatter compatible with the one found on full .net framework. The binary serialization of the datasets is supported as well (compatible with full .net framework of course) via serialization surrogates, included in the library.

  • Alvin Kuiper

    What is the reason you don't want to use the default serialization of the datasets in the web service

    -Alex


  • huabing78

    Web Services are using pretty much the same sockets under the hood so you're basically saying sockets are much faster than… very same sockets. You probably having some sort of anomaly in configuration, e.g. your data goes through slow proxy for WS vs. direct connection with sockets. You might want to sniff the traffic to see what’s going on… Generally you won’t get any improvements this way, just increase complexity and reduce flexibility of your code.



  • NoSTaBoNN

    1. Not sure, probably it’s cached in the proxy. In any case it won’t have any significant impact on performance as serialization itself is way longer than creation of the serializer instance.

    2. No. Quite the opposite in fact - it would be significantly slower as in addition to serializing DataSet you would need to serialize byte array to XML so it can be send via XML Web Service. So it makes no sense at all unless your goal is to slow it down. There are some suggestions on the WEB to send DataSet as string – they also would slow things down though not as much array.

    By the way, writing XML to byte array is not exactly what I meant by binary serialization. I’m talking about converting dataset’s content to the binary format and sending that somehow, preferably not via XML WS.



  • bslim

    This thread may be of some help to you.

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1606940&SiteID=1

    I am finding that using web services for the xfer of large amounts of data is very slow. Using a TCPSocket to access an ASPX page showed a substantial improvement in performance.

    --Finkster


  • biffpixel

    Yes the XML serializer will serialize into xml , what happens when i do the following

    Private Function GetBytes(ByRef ds As DataSet) As Byte()

    Dim byteds As Byte() = Nothing

    Dim x As XmlSerializer = XmlSerializerCache.GetXmlSerializer(ds.GetType, "http://gauls.co.uk")

    Dim ms As New MemoryStream

    x.Serialize(ms, ds)

    byteds = ms.ToArray()

    Return byteds

    End Function

    In the above code i crearte a cache for XmlSerializer so that i can resue them as its quite an expensive to recreate them , now to my questions

    1. If i use the default Xml Serializer for the webservice (passing the dataset to webmethod) will the webservice recreate the XmlSerializer for every call made to access the webmethod

    2. Any benefit performance wise if the memory stream of XML is converted to Array of bytes BTW can you please help me to visualize the "bytesds" here

    Thanks

    Regards

    Gauls



  • simon_

    Why do you believe XML serializer would serialize into "arraybytes" and not to XML I'd say you would get XML from it, hence the name.

    In fact, here's little secret: both SOAP serializer and XML serializer are very close and in case of DataSet they both would use DataSet's IXmlSerializable interface so you would get exactly the same results. No Base64 or "arraybytes" in either cases.

    If you want DataSet serialized as binary you would need to do it yourself.



  • sanjay tiwari

    I understand what you are saying, and it makes sense; however, I have been observing quite different results. My application runs on WM5.0, but it also runs on a desktop. When the data-load objects run on the desktop, the data transfer is very quick. When the code runs on the PPC, data moves at a snail’s pace.

    When testing on the desktop, I see no observable difference between using a Web Service and using a TCPSocket. This is not the case on the hand held. When running my tests on a Symbol 9090 and a Dell Axim, the web service technique is noticeably slower. On the desktop, a transfer of 500 rows takes only seconds. The same test on the hand-held will take minutes (via web service).

    I can not explain and it does not make sence to me. The only thing I can think of wich might add delay could be the parsing of SOAP tags. Since I do not know the code behind System.Web.Services.Protocols.SoapHttpClientProtocol, I can not vouch for its efficiency. I assume, at some level, it uses a TCPSocket. So, I gain speed by avoiding the middle-man -- at the expense of versatility.

    I really would like to stay with the WebSerivce because of the potential to reuse this with other applications; but, speed is king when talking about data transfer to a hand-held device.


  • enric vives

    I seriously doubt SOAP parsing has anything to do with it. My theory is what connection goes through proxy with WS as opposed to been direct with TCP. Another possible reason is bad negotiations of protocols with your WS which you don’t do with TCP.

    Capturing packets would show what’s going on. You actually have to do that because who knows how that’s going to work in production environment. In reality WS might not be located on the same PC device is cradled to and there might be proxies involved so your socket based code would simply fail right away.



  • sending/receiving datasets from webservice