Stupid XML Serialisaton and Web Services

  • Thread starter Thread starter Matthew Carter via .NET 247
  • Start date Start date
M

Matthew Carter via .NET 247

My company's XML webservice has several methods that pass backserialised data, and all seemed well during testing, and duringthe first few weeks of deployment. But people are coming back tome saying that the keep getting the error "DataRelation cannotbe serialized because it does not have a default publicconstructor" when they browse to the URL of the Web Service. Butit does have a public constructor, it really does, and now it'sdriving me up the wall.

Thanks

--------------------------------
Matthew Carter
Development Manager

Applied Language
http://www.appliedlanguage.com
 
No it doesn't .. You need to have a constructor on your object that looks
like DataRelation() not .. DataRelation(...) .. what formatter are you
using? Are you passing DataRelation objects directly .. i.e.

Do you have a webmethod that looks like

DataRelation WebMethodName
... or ..
WebMethodName(DataRelation..)

?

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/



My company's XML webservice has several methods that pass back serialised
data, and all seemed well during testing, and during the first few weeks of
deployment. But people are coming back to me saying that the keep getting
the error "DataRelation cannot be serialized because it does not have a
default public constructor" when they browse to the URL of the Web Service.
But it does have a public constructor, it really does, and now it's driving
me up the wall.

Thanks

--------------------------------
Matthew Carter
Development Manager

Applied Language
http://www.appliedlanguage.com
 
Not only as what I mentioned i.e. DataRelation being the actual serialized
data.. you could also be getting the same error if you are sending
"DataTables" as return values of your WebMethods.

Change those to DataSets everywhere in your code and it should work. This
problem shouldn't happen in ADO.NET 2.0.

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/



My company's XML webservice has several methods that pass back serialised
data, and all seemed well during testing, and during the first few weeks of
deployment. But people are coming back to me saying that the keep getting
the error "DataRelation cannot be serialized because it does not have a
default public constructor" when they browse to the URL of the Web Service.
But it does have a public constructor, it really does, and now it's driving
me up the wall.

Thanks

--------------------------------
Matthew Carter
Development Manager

Applied Language
http://www.appliedlanguage.com
 
Matt:

That error doesn't mean that you aren't using a public constructor as much
as it means you can't return that type through the web service b/c it's not
serializable. I'm guessing your web method is of type DataRelation? You
can definitely use DataRelations in your webmethod, I just don't thhink you
can use it as a return type (same for DataTables if you reference them
outside of a dataset btw).

HTH,

Bill

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
My company's XML webservice has several methods that pass back serialised
data, and all seemed well during testing, and during the first few weeks of
deployment. But people are coming back to me saying that the keep getting
the error "DataRelation cannot be serialized because it does not have a
default public constructor" when they browse to the URL of the Web Service.
But it does have a public constructor, it really does, and now it's driving
me up the wall.

Thanks

--------------------------------
Matthew Carter
Development Manager

Applied Language
http://www.appliedlanguage.com
 
Back
Top