I have a class that does not have a default constructor. The nature of the class inherently excludes it from having one and to put one in will blatantly misrepresent the object that it is modelling.
So having said that, how do I get it to go through SOAP when SOAP requires that the class has a default constructor?
In ASP.NET 2 the error message is "<class> cannot be serialized because it does not have a parametless constructor" (please note the typo/spelling error) A similar error occurs in ASP.NET 1.x
(Implementing my own IXmlSerializable interface that does not help. I tried it.)
Regards
Dave A 12 2100
Dave,
The reason you get this error is because Web services use XmlSerialization
to send your objects across - which means your class is bound by all
restrictions XmlSerializer puts on it - default public constructor being one
of them.
How do you get around it? Well you should not get around it. But if you
must, wrap this class in another class with a pub-def-constructor, and
implement IXmlSerializable to customize the xml serialization behavior. In
an End to End .NET shop you may even send a stream of bytes using
BinaryFormatter.
Or you can just send a bytestream as a function return and
serialize/deserialize using binaryformatter - though that assumes that your
client has .NET, which breaks the web service philosophy.
- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
----------------------------------------------------------------------------
---------------
"Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message
news:ux**************@TK2MSFTNGP15.phx.gbl...
I have a class that does not have a default constructor. The nature of the
class inherently excludes it from having one and to put one in will
blatantly misrepresent the object that it is modelling.
So having said that, how do I get it to go through SOAP when SOAP requires
that the class has a default constructor?
In ASP.NET 2 the error message is "<class> cannot be serialized because it
does not have a parametless constructor" (please note the typo/spelling
error) A similar error occurs in ASP.NET 1.x
(Implementing my own IXmlSerializable interface that does not help. I tried
it.)
Regards
Dave A
Dave,
The reason you get this error is because Web services use XmlSerialization
to send your objects across - which means your class is bound by all
restrictions XmlSerializer puts on it - default public constructor being one
of them.
How do you get around it? Well you should not get around it. But if you
must, wrap this class in another class with a pub-def-constructor, and
implement IXmlSerializable to customize the xml serialization behavior. In
an End to End .NET shop you may even send a stream of bytes using
BinaryFormatter.
Or you can just send a bytestream as a function return and
serialize/deserialize using binaryformatter - though that assumes that your
client has .NET, which breaks the web service philosophy.
- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
----------------------------------------------------------------------------
---------------
"Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message
news:ux**************@TK2MSFTNGP15.phx.gbl...
I have a class that does not have a default constructor. The nature of the
class inherently excludes it from having one and to put one in will
blatantly misrepresent the object that it is modelling.
So having said that, how do I get it to go through SOAP when SOAP requires
that the class has a default constructor?
In ASP.NET 2 the error message is "<class> cannot be serialized because it
does not have a parametless constructor" (please note the typo/spelling
error) A similar error occurs in ASP.NET 1.x
(Implementing my own IXmlSerializable interface that does not help. I tried
it.)
Regards
Dave A
Sahil,
I have looked into it further and there is actually a very elegant work
around that keeps both my design and SOAP happy.
You create a default constructor but adorn it with...
[Obsolete("This constructor is used internally for SOAP communications and
cannot be called through code.", true)]
public myClass()
{
}
It is not possible to call this constructor because it will result in a
compilation error but SOAP is only too happy to call it. I have tested it
and it works. (It requires ASP.NET 2 which I am targetting anyway)
Regards
Dave A
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message
news:O1*************@TK2MSFTNGP09.phx.gbl... Dave,
The reason you get this error is because Web services use XmlSerialization to send your objects across - which means your class is bound by all restrictions XmlSerializer puts on it - default public constructor being one of them.
How do you get around it? Well you should not get around it. But if you must, wrap this class in another class with a pub-def-constructor, and implement IXmlSerializable to customize the xml serialization behavior. In an End to End .NET shop you may even send a stream of bytes using BinaryFormatter.
Or you can just send a bytestream as a function return and serialize/deserialize using binaryformatter - though that assumes that your client has .NET, which breaks the web service philosophy.
- Sahil Malik [MVP] Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync ---------------------------------------------------------------------------- ---------------
"Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message news:ux**************@TK2MSFTNGP15.phx.gbl... I have a class that does not have a default constructor. The nature of the class inherently excludes it from having one and to put one in will blatantly misrepresent the object that it is modelling.
So having said that, how do I get it to go through SOAP when SOAP requires that the class has a default constructor?
In ASP.NET 2 the error message is "<class> cannot be serialized because it does not have a parametless constructor" (please note the typo/spelling error) A similar error occurs in ASP.NET 1.x
(Implementing my own IXmlSerializable interface that does not help. I tried it.)
Regards Dave A
Sahil,
I have looked into it further and there is actually a very elegant work
around that keeps both my design and SOAP happy.
You create a default constructor but adorn it with...
[Obsolete("This constructor is used internally for SOAP communications and
cannot be called through code.", true)]
public myClass()
{
}
It is not possible to call this constructor because it will result in a
compilation error but SOAP is only too happy to call it. I have tested it
and it works. (It requires ASP.NET 2 which I am targetting anyway)
Regards
Dave A
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message
news:O1*************@TK2MSFTNGP09.phx.gbl... Dave,
The reason you get this error is because Web services use XmlSerialization to send your objects across - which means your class is bound by all restrictions XmlSerializer puts on it - default public constructor being one of them.
How do you get around it? Well you should not get around it. But if you must, wrap this class in another class with a pub-def-constructor, and implement IXmlSerializable to customize the xml serialization behavior. In an End to End .NET shop you may even send a stream of bytes using BinaryFormatter.
Or you can just send a bytestream as a function return and serialize/deserialize using binaryformatter - though that assumes that your client has .NET, which breaks the web service philosophy.
- Sahil Malik [MVP] Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync ---------------------------------------------------------------------------- ---------------
"Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message news:ux**************@TK2MSFTNGP15.phx.gbl... I have a class that does not have a default constructor. The nature of the class inherently excludes it from having one and to put one in will blatantly misrepresent the object that it is modelling.
So having said that, how do I get it to go through SOAP when SOAP requires that the class has a default constructor?
In ASP.NET 2 the error message is "<class> cannot be serialized because it does not have a parametless constructor" (please note the typo/spelling error) A similar error occurs in ASP.NET 1.x
(Implementing my own IXmlSerializable interface that does not help. I tried it.)
Regards Dave A
Oh my !!! Who would have thought.
But using the ObsoleteAttribute for this, smells of a hack. I feel they
didn't write the ObsoleteAttribute for this purpose :-) ..
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/
"Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message
news:eQ****************@tk2msftngp13.phx.gbl... Sahil,
I have looked into it further and there is actually a very elegant work around that keeps both my design and SOAP happy.
You create a default constructor but adorn it with...
[Obsolete("This constructor is used internally for SOAP communications and cannot be called through code.", true)] public myClass() { }
It is not possible to call this constructor because it will result in a compilation error but SOAP is only too happy to call it. I have tested it and it works. (It requires ASP.NET 2 which I am targetting anyway)
Regards Dave A
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:O1*************@TK2MSFTNGP09.phx.gbl... Dave,
The reason you get this error is because Web services use XmlSerialization to send your objects across - which means your class is bound by all restrictions XmlSerializer puts on it - default public constructor being one of them.
How do you get around it? Well you should not get around it. But if you must, wrap this class in another class with a pub-def-constructor, and implement IXmlSerializable to customize the xml serialization behavior. In an End to End .NET shop you may even send a stream of bytes using BinaryFormatter.
Or you can just send a bytestream as a function return and serialize/deserialize using binaryformatter - though that assumes that your client has .NET, which breaks the web service philosophy.
- Sahil Malik [MVP] Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync ---------------------------------------------------------------------------- ---------------
"Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message news:ux**************@TK2MSFTNGP15.phx.gbl... I have a class that does not have a default constructor. The nature of the class inherently excludes it from having one and to put one in will blatantly misrepresent the object that it is modelling.
So having said that, how do I get it to go through SOAP when SOAP requires that the class has a default constructor?
In ASP.NET 2 the error message is "<class> cannot be serialized because it does not have a parametless constructor" (please note the typo/spelling error) A similar error occurs in ASP.NET 1.x
(Implementing my own IXmlSerializable interface that does not help. I tried it.)
Regards Dave A
Oh my !!! Who would have thought.
But using the ObsoleteAttribute for this, smells of a hack. I feel they
didn't write the ObsoleteAttribute for this purpose :-) ..
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/
"Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message
news:eQ****************@tk2msftngp13.phx.gbl... Sahil,
I have looked into it further and there is actually a very elegant work around that keeps both my design and SOAP happy.
You create a default constructor but adorn it with...
[Obsolete("This constructor is used internally for SOAP communications and cannot be called through code.", true)] public myClass() { }
It is not possible to call this constructor because it will result in a compilation error but SOAP is only too happy to call it. I have tested it and it works. (It requires ASP.NET 2 which I am targetting anyway)
Regards Dave A
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:O1*************@TK2MSFTNGP09.phx.gbl... Dave,
The reason you get this error is because Web services use XmlSerialization to send your objects across - which means your class is bound by all restrictions XmlSerializer puts on it - default public constructor being one of them.
How do you get around it? Well you should not get around it. But if you must, wrap this class in another class with a pub-def-constructor, and implement IXmlSerializable to customize the xml serialization behavior. In an End to End .NET shop you may even send a stream of bytes using BinaryFormatter.
Or you can just send a bytestream as a function return and serialize/deserialize using binaryformatter - though that assumes that your client has .NET, which breaks the web service philosophy.
- Sahil Malik [MVP] Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync ---------------------------------------------------------------------------- ---------------
"Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message news:ux**************@TK2MSFTNGP15.phx.gbl... I have a class that does not have a default constructor. The nature of the class inherently excludes it from having one and to put one in will blatantly misrepresent the object that it is modelling.
So having said that, how do I get it to go through SOAP when SOAP requires that the class has a default constructor?
In ASP.NET 2 the error message is "<class> cannot be serialized because it does not have a parametless constructor" (please note the typo/spelling error) A similar error occurs in ASP.NET 1.x
(Implementing my own IXmlSerializable interface that does not help. I tried it.)
Regards Dave A
BTW - MS agrees with my views, this is an issue. You might not wanna do it
this way because in a future release this will quit working.
Relevant link - http://lab.msdn.microsoft.com/Produc...3-2fae1dcd07ae
- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
----------------------------------------------------------------------------
---------------
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message
news:eD*************@TK2MSFTNGP10.phx.gbl... Oh my !!! Who would have thought.
But using the ObsoleteAttribute for this, smells of a hack. I feel they didn't write the ObsoleteAttribute for this purpose :-) ..
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/ "Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message news:eQ****************@tk2msftngp13.phx.gbl... Sahil,
I have looked into it further and there is actually a very elegant work around that keeps both my design and SOAP happy.
You create a default constructor but adorn it with...
[Obsolete("This constructor is used internally for SOAP communications
and cannot be called through code.", true)] public myClass() { }
It is not possible to call this constructor because it will result in a compilation error but SOAP is only too happy to call it. I have tested
it and it works. (It requires ASP.NET 2 which I am targetting anyway)
Regards Dave A
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:O1*************@TK2MSFTNGP09.phx.gbl... Dave,
The reason you get this error is because Web services use XmlSerialization to send your objects across - which means your class is bound by all restrictions XmlSerializer puts on it - default public constructor
being one of them.
How do you get around it? Well you should not get around it. But if you must, wrap this class in another class with a pub-def-constructor, and implement IXmlSerializable to customize the xml serialization behavior. In an End to End .NET shop you may even send a stream of bytes using BinaryFormatter.
Or you can just send a bytestream as a function return and serialize/deserialize using binaryformatter - though that assumes that your client has .NET, which breaks the web service philosophy.
- Sahil Malik [MVP] Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
-------------------------------------------------------------------------
--- ---------------
"Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message news:ux**************@TK2MSFTNGP15.phx.gbl... I have a class that does not have a default constructor. The nature of the class inherently excludes it from having one and to put one in will blatantly misrepresent the object that it is modelling.
So having said that, how do I get it to go through SOAP when SOAP requires that the class has a default constructor?
In ASP.NET 2 the error message is "<class> cannot be serialized because it does not have a parametless constructor" (please note the typo/spelling error) A similar error occurs in ASP.NET 1.x
(Implementing my own IXmlSerializable interface that does not help. I tried it.)
Regards Dave A
BTW - MS agrees with my views, this is an issue. You might not wanna do it
this way because in a future release this will quit working.
Relevant link - http://lab.msdn.microsoft.com/Produc...3-2fae1dcd07ae
- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
----------------------------------------------------------------------------
---------------
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message
news:eD*************@TK2MSFTNGP10.phx.gbl... Oh my !!! Who would have thought.
But using the ObsoleteAttribute for this, smells of a hack. I feel they didn't write the ObsoleteAttribute for this purpose :-) ..
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/ "Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message news:eQ****************@tk2msftngp13.phx.gbl... Sahil,
I have looked into it further and there is actually a very elegant work around that keeps both my design and SOAP happy.
You create a default constructor but adorn it with...
[Obsolete("This constructor is used internally for SOAP communications
and cannot be called through code.", true)] public myClass() { }
It is not possible to call this constructor because it will result in a compilation error but SOAP is only too happy to call it. I have tested
it and it works. (It requires ASP.NET 2 which I am targetting anyway)
Regards Dave A
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:O1*************@TK2MSFTNGP09.phx.gbl... Dave,
The reason you get this error is because Web services use XmlSerialization to send your objects across - which means your class is bound by all restrictions XmlSerializer puts on it - default public constructor
being one of them.
How do you get around it? Well you should not get around it. But if you must, wrap this class in another class with a pub-def-constructor, and implement IXmlSerializable to customize the xml serialization behavior. In an End to End .NET shop you may even send a stream of bytes using BinaryFormatter.
Or you can just send a bytestream as a function return and serialize/deserialize using binaryformatter - though that assumes that your client has .NET, which breaks the web service philosophy.
- Sahil Malik [MVP] Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
-------------------------------------------------------------------------
--- ---------------
"Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message news:ux**************@TK2MSFTNGP15.phx.gbl... I have a class that does not have a default constructor. The nature of the class inherently excludes it from having one and to put one in will blatantly misrepresent the object that it is modelling.
So having said that, how do I get it to go through SOAP when SOAP requires that the class has a default constructor?
In ASP.NET 2 the error message is "<class> cannot be serialized because it does not have a parametless constructor" (please note the typo/spelling error) A similar error occurs in ASP.NET 1.x
(Implementing my own IXmlSerializable interface that does not help. I tried it.)
Regards Dave A
Thanks for reporting that as a 'bug'! I don't know how to solve my original
problem now - and the problem stands.
Dave A
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message
news:OR**************@TK2MSFTNGP15.phx.gbl... BTW - MS agrees with my views, this is an issue. You might not wanna do it this way because in a future release this will quit working.
Relevant link - http://lab.msdn.microsoft.com/Produc...3-2fae1dcd07ae
- Sahil Malik [MVP] Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync ---------------------------------------------------------------------------- ---------------
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:eD*************@TK2MSFTNGP10.phx.gbl... Oh my !!! Who would have thought.
But using the ObsoleteAttribute for this, smells of a hack. I feel they didn't write the ObsoleteAttribute for this purpose :-) ..
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/ "Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message news:eQ****************@tk2msftngp13.phx.gbl... > Sahil, > > I have looked into it further and there is actually a very elegant work > around that keeps both my design and SOAP happy. > > You create a default constructor but adorn it with... > > [Obsolete("This constructor is used internally for SOAP communications and > cannot be called through code.", true)] > public myClass() > { > } > > It is not possible to call this constructor because it will result in a > compilation error but SOAP is only too happy to call it. I have tested it > and it works. (It requires ASP.NET 2 which I am targetting anyway) > > Regards > Dave A > > "Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message > news:O1*************@TK2MSFTNGP09.phx.gbl... >> Dave, >> >> The reason you get this error is because Web services use >> XmlSerialization >> to send your objects across - which means your class is bound by all >> restrictions XmlSerializer puts on it - default public constructor being >> one >> of them. >> >> How do you get around it? Well you should not get around it. But if >> you >> must, wrap this class in another class with a pub-def-constructor, and >> implement IXmlSerializable to customize the xml serialization >> behavior. >> In >> an End to End .NET shop you may even send a stream of bytes using >> BinaryFormatter. >> >> Or you can just send a bytestream as a function return and >> serialize/deserialize using binaryformatter - though that assumes that >> your >> client has .NET, which breaks the web service philosophy. >> >> - Sahil Malik [MVP] >> Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
------------------------------------------------------------------------- --- >> --------------- >> >> "Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message >> news:ux**************@TK2MSFTNGP15.phx.gbl... >> I have a class that does not have a default constructor. The nature of >> the >> class inherently excludes it from having one and to put one in will >> blatantly misrepresent the object that it is modelling. >> >> So having said that, how do I get it to go through SOAP when SOAP >> requires >> that the class has a default constructor? >> >> In ASP.NET 2 the error message is "<class> cannot be serialized >> because >> it >> does not have a parametless constructor" (please note the >> typo/spelling >> error) A similar error occurs in ASP.NET 1.x >> >> (Implementing my own IXmlSerializable interface that does not help. I >> tried >> it.) >> >> Regards >> Dave A >> >> > >
Thanks for reporting that as a 'bug'! I don't know how to solve my original
problem now - and the problem stands.
Dave A
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message
news:OR**************@TK2MSFTNGP15.phx.gbl... BTW - MS agrees with my views, this is an issue. You might not wanna do it this way because in a future release this will quit working.
Relevant link - http://lab.msdn.microsoft.com/Produc...3-2fae1dcd07ae
- Sahil Malik [MVP] Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync ---------------------------------------------------------------------------- ---------------
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:eD*************@TK2MSFTNGP10.phx.gbl... Oh my !!! Who would have thought.
But using the ObsoleteAttribute for this, smells of a hack. I feel they didn't write the ObsoleteAttribute for this purpose :-) ..
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/ "Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message news:eQ****************@tk2msftngp13.phx.gbl... > Sahil, > > I have looked into it further and there is actually a very elegant work > around that keeps both my design and SOAP happy. > > You create a default constructor but adorn it with... > > [Obsolete("This constructor is used internally for SOAP communications and > cannot be called through code.", true)] > public myClass() > { > } > > It is not possible to call this constructor because it will result in a > compilation error but SOAP is only too happy to call it. I have tested it > and it works. (It requires ASP.NET 2 which I am targetting anyway) > > Regards > Dave A > > "Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message > news:O1*************@TK2MSFTNGP09.phx.gbl... >> Dave, >> >> The reason you get this error is because Web services use >> XmlSerialization >> to send your objects across - which means your class is bound by all >> restrictions XmlSerializer puts on it - default public constructor being >> one >> of them. >> >> How do you get around it? Well you should not get around it. But if >> you >> must, wrap this class in another class with a pub-def-constructor, and >> implement IXmlSerializable to customize the xml serialization >> behavior. >> In >> an End to End .NET shop you may even send a stream of bytes using >> BinaryFormatter. >> >> Or you can just send a bytestream as a function return and >> serialize/deserialize using binaryformatter - though that assumes that >> your >> client has .NET, which breaks the web service philosophy. >> >> - Sahil Malik [MVP] >> Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
------------------------------------------------------------------------- --- >> --------------- >> >> "Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message >> news:ux**************@TK2MSFTNGP15.phx.gbl... >> I have a class that does not have a default constructor. The nature of >> the >> class inherently excludes it from having one and to put one in will >> blatantly misrepresent the object that it is modelling. >> >> So having said that, how do I get it to go through SOAP when SOAP >> requires >> that the class has a default constructor? >> >> In ASP.NET 2 the error message is "<class> cannot be serialized >> because >> it >> does not have a parametless constructor" (please note the >> typo/spelling >> error) A similar error occurs in ASP.NET 1.x >> >> (Implementing my own IXmlSerializable interface that does not help. I >> tried >> it.) >> >> Regards >> Dave A >> >> > >
Sorry dude, but it smelt like a bug, walked like a bug, and I didn't think a
right architecture should exploit a bug.
But hey if you wanna go ahead with it - go for it. Why? because this isn't
gonna be fixed until atleast ORCAS.
--
- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
----------------------------------------------------------------------------
---------------
"Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message
news:el**************@TK2MSFTNGP09.phx.gbl... Thanks for reporting that as a 'bug'! I don't know how to solve my
original problem now - and the problem stands.
Dave A
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:OR**************@TK2MSFTNGP15.phx.gbl... BTW - MS agrees with my views, this is an issue. You might not wanna do
it this way because in a future release this will quit working.
Relevant link - http://lab.msdn.microsoft.com/Produc...3-2fae1dcd07ae - Sahil Malik [MVP] Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
--------------------------------------------------------------------------
-- ---------------
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:eD*************@TK2MSFTNGP10.phx.gbl... Oh my !!! Who would have thought.
But using the ObsoleteAttribute for this, smells of a hack. I feel they didn't write the ObsoleteAttribute for this purpose :-) ..
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/ "Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message news:eQ****************@tk2msftngp13.phx.gbl... > Sahil, > > I have looked into it further and there is actually a very elegant
work > around that keeps both my design and SOAP happy. > > You create a default constructor but adorn it with... > > [Obsolete("This constructor is used internally for SOAP
communications and > cannot be called through code.", true)] > public myClass() > { > } > > It is not possible to call this constructor because it will result in
a > compilation error but SOAP is only too happy to call it. I have
tested it > and it works. (It requires ASP.NET 2 which I am targetting anyway) > > Regards > Dave A > > "Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message > news:O1*************@TK2MSFTNGP09.phx.gbl... >> Dave, >> >> The reason you get this error is because Web services use >> XmlSerialization >> to send your objects across - which means your class is bound by all >> restrictions XmlSerializer puts on it - default public constructor being >> one >> of them. >> >> How do you get around it? Well you should not get around it. But if >> you >> must, wrap this class in another class with a pub-def-constructor,
and >> implement IXmlSerializable to customize the xml serialization >> behavior. >> In >> an End to End .NET shop you may even send a stream of bytes using >> BinaryFormatter. >> >> Or you can just send a bytestream as a function return and >> serialize/deserialize using binaryformatter - though that assumes
that >> your >> client has .NET, which breaks the web service philosophy. >> >> - Sahil Malik [MVP] >> Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
------------------------------------------------------------------------
- --- >> --------------- >> >> "Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message >> news:ux**************@TK2MSFTNGP15.phx.gbl... >> I have a class that does not have a default constructor. The nature
of >> the >> class inherently excludes it from having one and to put one in will >> blatantly misrepresent the object that it is modelling. >> >> So having said that, how do I get it to go through SOAP when SOAP >> requires >> that the class has a default constructor? >> >> In ASP.NET 2 the error message is "<class> cannot be serialized >> because >> it >> does not have a parametless constructor" (please note the >> typo/spelling >> error) A similar error occurs in ASP.NET 1.x >> >> (Implementing my own IXmlSerializable interface that does not help.
I >> tried >> it.) >> >> Regards >> Dave A >> >> > >
Sorry dude, but it smelt like a bug, walked like a bug, and I didn't think a
right architecture should exploit a bug.
But hey if you wanna go ahead with it - go for it. Why? because this isn't
gonna be fixed until atleast ORCAS.
--
- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
----------------------------------------------------------------------------
---------------
"Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message
news:el**************@TK2MSFTNGP09.phx.gbl... Thanks for reporting that as a 'bug'! I don't know how to solve my
original problem now - and the problem stands.
Dave A
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:OR**************@TK2MSFTNGP15.phx.gbl... BTW - MS agrees with my views, this is an issue. You might not wanna do
it this way because in a future release this will quit working.
Relevant link - http://lab.msdn.microsoft.com/Produc...3-2fae1dcd07ae - Sahil Malik [MVP] Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
--------------------------------------------------------------------------
-- ---------------
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:eD*************@TK2MSFTNGP10.phx.gbl... Oh my !!! Who would have thought.
But using the ObsoleteAttribute for this, smells of a hack. I feel they didn't write the ObsoleteAttribute for this purpose :-) ..
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/ "Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message news:eQ****************@tk2msftngp13.phx.gbl... > Sahil, > > I have looked into it further and there is actually a very elegant
work > around that keeps both my design and SOAP happy. > > You create a default constructor but adorn it with... > > [Obsolete("This constructor is used internally for SOAP
communications and > cannot be called through code.", true)] > public myClass() > { > } > > It is not possible to call this constructor because it will result in
a > compilation error but SOAP is only too happy to call it. I have
tested it > and it works. (It requires ASP.NET 2 which I am targetting anyway) > > Regards > Dave A > > "Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message > news:O1*************@TK2MSFTNGP09.phx.gbl... >> Dave, >> >> The reason you get this error is because Web services use >> XmlSerialization >> to send your objects across - which means your class is bound by all >> restrictions XmlSerializer puts on it - default public constructor being >> one >> of them. >> >> How do you get around it? Well you should not get around it. But if >> you >> must, wrap this class in another class with a pub-def-constructor,
and >> implement IXmlSerializable to customize the xml serialization >> behavior. >> In >> an End to End .NET shop you may even send a stream of bytes using >> BinaryFormatter. >> >> Or you can just send a bytestream as a function return and >> serialize/deserialize using binaryformatter - though that assumes
that >> your >> client has .NET, which breaks the web service philosophy. >> >> - Sahil Malik [MVP] >> Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
------------------------------------------------------------------------
- --- >> --------------- >> >> "Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message >> news:ux**************@TK2MSFTNGP15.phx.gbl... >> I have a class that does not have a default constructor. The nature
of >> the >> class inherently excludes it from having one and to put one in will >> blatantly misrepresent the object that it is modelling. >> >> So having said that, how do I get it to go through SOAP when SOAP >> requires >> that the class has a default constructor? >> >> In ASP.NET 2 the error message is "<class> cannot be serialized >> because >> it >> does not have a parametless constructor" (please note the >> typo/spelling >> error) A similar error occurs in ASP.NET 1.x >> >> (Implementing my own IXmlSerializable interface that does not help.
I >> tried >> it.) >> >> Regards >> Dave A >> >> > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dan Perl |
last post by:
There is something with initializing mutable class attributes that I am
struggling with. I'll use an example to explain:
class Father:
attr1=None # this is OK
attr2= # this is wrong...
|
by: hazz |
last post by:
The following classes follow from the base class ' A ' down to the derived class ' D ' at the bottom of the inheritance chain.
I am calling the class at the bottom, "public class D" from a client...
|
by: Dave A |
last post by:
I have a class that does not have a default constructor. The nature of the class inherently excludes it from having one and to put one in will blatantly misrepresent the object that it is modelling....
|
by: Ross McLean |
last post by:
Hi all,
I've been teaching myself C# for a new project at work. I have a bit of
a background in c++ and java but never been what you could call a guru.
I'm having some strange things happening...
|
by: Samuel Zallocco |
last post by:
Hi all,
I've a problem with PHP5 + PEAR::SOAP.
I Have the following 2 script that implements a simple web service:
The Server Code running on WinXP + PHP5 + Apache 2.x:...
|
by: Tony Johansson |
last post by:
Hello!
I have a class definition called MyClass see below.
I create an instance of this class MyClass
I also want this instance to be able to modify the test instance that exist
in this...
|
by: Sanders Kaufman |
last post by:
I'm wondering if I'm doing this right, as far as using another class
object as a PHP class property.
class my_baseclass {
var $Database;
var $ErrorMessage;
var $TableName;
var $RecordSet;...
|
by: Rik Wasmus |
last post by:
I had some problems on 1 particular server (up to 3 others with the same
PHP&SOAP version work, 1 of which with the same OS) with constructing a
SOAP client:
FAIL:
<?php...
|
by: stroudg2 |
last post by:
Situation:
I have been tasked to provide a non-intrusive solution to allow .NET web services to grab an incoming SOAP header and process the credentials stored within in such a way that a...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |