Web Services & Custom Classes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I posted a similar question last week and got an answer but its not working.

I have three projects in a solution. Project A is a library. Project B is a
web service. Project C is a windows app.

Project B and C make reference to project A in order to share the same
library of classes. There is an abstract class in A and class that derives
from the abstract one.

Project B references project A and has a web method who's return type is the
class in project A that derives from an abstract class.

When Project C calls the web method in project B nothing comes back. This
should not be the case and I have verified via debug that the object is
instantiated, populated with values, but when the return statement is
executed the caller gets a null object back.

I also started the solution in debug with Project A (web service) as the
start up app. I invoked the web method and recieved xml output that has no
child nodes...in other words NOTHING but just before that the object to be
returned again was instantiated and had values.

I have tried using XmlInclude in various locations to no avail. Im not quite
sure how to get this thing working.

Someone showed me the following, that does not do exactly what I'm doing.
Instead the example has everythign within the web service itself. This is not
how my classes are encapsulated. Mine are split out as I described
above....shared library.

http://msdn.microsoft.com/library/d...erializationxmlincludeattributeclasstopic.asp

Can anyone help me out here? I'm getting a bit desparate as the deadline
approaches. Thanks!
 
Demetri,

The problem here is that when you expose the class from library A
through the web service, a WSDL file is created which defines that type
which is exposed. On the other end, when you create the proxy, it creates a
new type definition which is compatable with the old one, but is not the
same. This is the reason for the null return value.

What you need to do is go into the proxy, and change the code so that it
will instantiate the type from library A and not the type that it defines
from the WSDL. Then, it should work.

Hope this helps.
 
I've already done this and that did solve the problem of being able to share
class types over multiple projects. This can't be the issue i'm having at
this point though. The reason is because like I said.....I've executed the
web service itself and same problem. Therefore, no proxy is involved.

-Demetri

Nicholas Paldino said:
Demetri,

The problem here is that when you expose the class from library A
through the web service, a WSDL file is created which defines that type
which is exposed. On the other end, when you create the proxy, it creates a
new type definition which is compatable with the old one, but is not the
same. This is the reason for the null return value.

What you need to do is go into the proxy, and change the code so that it
will instantiate the type from library A and not the type that it defines
from the WSDL. Then, it should work.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Demetri said:
I posted a similar question last week and got an answer but its not
working.

I have three projects in a solution. Project A is a library. Project B is
a
web service. Project C is a windows app.

Project B and C make reference to project A in order to share the same
library of classes. There is an abstract class in A and class that derives
from the abstract one.

Project B references project A and has a web method who's return type is
the
class in project A that derives from an abstract class.

When Project C calls the web method in project B nothing comes back. This
should not be the case and I have verified via debug that the object is
instantiated, populated with values, but when the return statement is
executed the caller gets a null object back.

I also started the solution in debug with Project A (web service) as the
start up app. I invoked the web method and recieved xml output that has no
child nodes...in other words NOTHING but just before that the object to be
returned again was instantiated and had values.

I have tried using XmlInclude in various locations to no avail. Im not
quite
sure how to get this thing working.

Someone showed me the following, that does not do exactly what I'm doing.
Instead the example has everythign within the web service itself. This is
not
how my classes are encapsulated. Mine are split out as I described
above....shared library.

http://msdn.microsoft.com/library/d...erializationxmlincludeattributeclasstopic.asp

Can anyone help me out here? I'm getting a bit desparate as the deadline
approaches. Thanks!
 
Demetri,

Can you boil your code down into a small sample (even if it is across
multiple projects).


Demetri said:
I've already done this and that did solve the problem of being able to
share
class types over multiple projects. This can't be the issue i'm having at
this point though. The reason is because like I said.....I've executed the
web service itself and same problem. Therefore, no proxy is involved.

-Demetri

Nicholas Paldino said:
Demetri,

The problem here is that when you expose the class from library A
through the web service, a WSDL file is created which defines that type
which is exposed. On the other end, when you create the proxy, it
creates a
new type definition which is compatable with the old one, but is not the
same. This is the reason for the null return value.

What you need to do is go into the proxy, and change the code so that
it
will instantiate the type from library A and not the type that it defines
from the WSDL. Then, it should work.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Demetri said:
I posted a similar question last week and got an answer but its not
working.

I have three projects in a solution. Project A is a library. Project B
is
a
web service. Project C is a windows app.

Project B and C make reference to project A in order to share the same
library of classes. There is an abstract class in A and class that
derives
from the abstract one.

Project B references project A and has a web method who's return type
is
the
class in project A that derives from an abstract class.

When Project C calls the web method in project B nothing comes back.
This
should not be the case and I have verified via debug that the object is
instantiated, populated with values, but when the return statement is
executed the caller gets a null object back.

I also started the solution in debug with Project A (web service) as
the
start up app. I invoked the web method and recieved xml output that has
no
child nodes...in other words NOTHING but just before that the object to
be
returned again was instantiated and had values.

I have tried using XmlInclude in various locations to no avail. Im not
quite
sure how to get this thing working.

Someone showed me the following, that does not do exactly what I'm
doing.
Instead the example has everythign within the web service itself. This
is
not
how my classes are encapsulated. Mine are split out as I described
above....shared library.

http://msdn.microsoft.com/library/d...erializationxmlincludeattributeclasstopic.asp

Can anyone help me out here? I'm getting a bit desparate as the
deadline
approaches. Thanks!
 
Actually, I have figured it out. It would seem that only PUBLIC properties
that have BOTH a get and set accessor will be included in the serialization.
I only had the GET accessor. This leads to my next question: Is there a way
around this?

-Demetri

Nicholas Paldino said:
Demetri,

Can you boil your code down into a small sample (even if it is across
multiple projects).


Demetri said:
I've already done this and that did solve the problem of being able to
share
class types over multiple projects. This can't be the issue i'm having at
this point though. The reason is because like I said.....I've executed the
web service itself and same problem. Therefore, no proxy is involved.

-Demetri

Nicholas Paldino said:
Demetri,

The problem here is that when you expose the class from library A
through the web service, a WSDL file is created which defines that type
which is exposed. On the other end, when you create the proxy, it
creates a
new type definition which is compatable with the old one, but is not the
same. This is the reason for the null return value.

What you need to do is go into the proxy, and change the code so that
it
will instantiate the type from library A and not the type that it defines
from the WSDL. Then, it should work.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I posted a similar question last week and got an answer but its not
working.

I have three projects in a solution. Project A is a library. Project B
is
a
web service. Project C is a windows app.

Project B and C make reference to project A in order to share the same
library of classes. There is an abstract class in A and class that
derives
from the abstract one.

Project B references project A and has a web method who's return type
is
the
class in project A that derives from an abstract class.

When Project C calls the web method in project B nothing comes back.
This
should not be the case and I have verified via debug that the object is
instantiated, populated with values, but when the return statement is
executed the caller gets a null object back.

I also started the solution in debug with Project A (web service) as
the
start up app. I invoked the web method and recieved xml output that has
no
child nodes...in other words NOTHING but just before that the object to
be
returned again was instantiated and had values.

I have tried using XmlInclude in various locations to no avail. Im not
quite
sure how to get this thing working.

Someone showed me the following, that does not do exactly what I'm
doing.
Instead the example has everythign within the web service itself. This
is
not
how my classes are encapsulated. Mine are split out as I described
above....shared library.

http://msdn.microsoft.com/library/d...erializationxmlincludeattributeclasstopic.asp

Can anyone help me out here? I'm getting a bit desparate as the
deadline
approaches. Thanks!
 
Back
Top