WebServices need to implient serializable?

neednt

In my opinion...
you neednt implement serializable class to develop a WebService.
But is rare, that you want return a class. Normaly, in WebServices the results returned are access to ejecute functions, you can offer at user the functions or subs of the class. no....

I dont know, jejeje im beginner developer....

Bye.
 
The class needs to be serializable to XML, most definately. Since SOAP, the underlying protocol of web services, utilizes XML as its structural markup language all data that is transferred has to be XML, no exceptions. Your class will be serialized to XML before its sent, and back to the class once its been received.
 
its only a data class, no methods. So derek what do i need to flag to make a class serializable to xml? The whole point of my current project is to take all processing off a pocketpc device, so it just recives data and .net handles all the parsing etc, not my own code.
 
Just add the serializable attribute before the keyword class..

C#:
<Serializable()> class SomeClass {
   // ....
}
 
Keep in mind that there are numerous attributes under the System.Xml.Serialization namespace that will allow you to better format the serialized XML that is produced from a custom class. Examples of these attributes include XmlElementAttribute, XmlAttributeAttribute and XmlTextAttribute, which define class members as elements, attributes and text, respectively.
 
While I do have a plethora of information available on the topic, so does Google, so have a gander... *hint* *hint* *nudge* *nudge* ;)
 
Im confused...

Well, data class, what like is it????

I think you neednt serialize your data class because Web Services .NET convert automaticaly in XML document. OK?

You only must construct one function that returned a DataSet, and Web Service will converted to .XML document your DataSet automaticaly, doesnt?

Code:
<webmethod()> public function GetAllDatas() as DataSet
   .
   .
   .
  return MyDataSet
end function

Perhaps, you want construct your own XML document. Then yes, you need serialize your data to your own document.

At the end, if I was you, I serialize to XML if you need a particular XML document.

And dont know, Im so beginner......excuse me if it Im saying, is stupid.

Answer me and let me learn much.
Bye.
 
NOW, IM SURE. See...

DATASETS is the key to serialize DATA to XML. The DataSet class has several methods for reading and writing data as XML.
For it, follow this steps:

1. Obtain data from your container or database.
2. Pass it to a DataSet.
3. Invoke to writeXML method of dataset class.

See this example Saving a DataSet to a file as XML
Code:
Before you must populate DataSet
  .
  .
  .
 Save dataSet as XML.
ds.WriteXml("mydataXML.xml")

Its all. Also you can overload WriteXML method.

To read data and import it again to a DataSet

Code:
Dim ds As New DataSet( )
ds.ReadXml("mydataXML.xml")

ALSO!! You can work as before with your own schema. Look at, you have to your use GetXml and GetXmlSchema methods to obtain the schema wich your DataSet work. And WriteXml and WriteXmlSchema methods to configure DataSet with your own schema.
 
The DataSet object is serializable, yes, but that wasnt his question. The custom class that he wishes to return has to be serializable, or the SOAP cant handle it.
 
Back
Top