how or when to use XmlInclude ?

R

R.A.

Hi

I have a web service that returns a custom class in one of the service
methods.

public class MyClass
{
public string Name;
public string Street;
}


web method:

[WebMethod (Description = "Get customer info")]
public MtClass [] GetCustomerList (string ZipCode)

{

....

}



As I am testing I didn't use XmlInclude for MyClass or for the
GetCustomerList method but still I am able to get the serialized information
back from the web service. If this is the case then do I need XmlInclude at
all?



Thanks
 
D

Dan Rogers

In this case you don't need to use XmlInclude. You would only need the
XmlInclude if you had an interface that included the ability for different
types than expected at compile time to be added to the return at runtime.
This happens when you return an object as the return type, for instance.

Regards,

Dan Rogers
Microsoft Corporation
--------------------
 
R

R.A.

Thanks,

Then why is it that when I view the web service method (using MS IE) I see
the method return type MyClass only? MyClass is derived from an abstract
class and I would like the consumer of the web service to be able to read
the public methods of the abstract class also. What I have now is that I
only see the MyClass methods in the IE when I click on that web service
method (see it in soap protocol).

public abstract class ABC
{
public string Phone;
}

public class MyClass : ABC
{
public string Name;
public string Street;
}

Thanks

Dan Rogers said:
In this case you don't need to use XmlInclude. You would only need the
XmlInclude if you had an interface that included the ability for different
types than expected at compile time to be added to the return at runtime.
This happens when you return an object as the return type, for instance.

Regards,

Dan Rogers
Microsoft Corporation
--------------------
From: "R.A." <[email protected]>
Subject: how or when to use XmlInclude ?
Date: Tue, 7 Dec 2004 09:01:24 -0600
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
NNTP-Posting-Host: 204.124.82.48
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXS01.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08
phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.aspnet.webservices:27071
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices

Hi

I have a web service that returns a custom class in one of the service
methods.

public class MyClass
{
public string Name;
public string Street;
}


web method:

[WebMethod (Description = "Get customer info")]
public MtClass [] GetCustomerList (string ZipCode)

{

...

}



As I am testing I didn't use XmlInclude for MyClass or for the
GetCustomerList method but still I am able to get the serialized information
back from the web service. If this is the case then do I need XmlInclude at
all?



Thanks
 
D

Dan Rogers

This is just a behavior of the shallow reflection used to paint the
documentation page. In general, you need to use a properly created proxy
to actually call the service - and that proxy relies on the contract, not
on the server side implementation.

I think you'll find that the proxy defines the right inheritence structure
for the data items that are public and serialized to the wire. There won't
be any callable methods on the data objects, since this is not object
remoting, it is a contract bound interface only that makes the data on the
wire the bridge between systems.

--------------------
Subject: Re: how or when to use XmlInclude ?
Date: Wed, 8 Dec 2004 09:03:58 -0600
Lines: 97
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
NNTP-Posting-Host: 204.124.82.48
Path: cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
..phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.aspnet.webservices:27090
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices

Thanks,

Then why is it that when I view the web service method (using MS IE) I see
the method return type MyClass only? MyClass is derived from an abstract
class and I would like the consumer of the web service to be able to read
the public methods of the abstract class also. What I have now is that I
only see the MyClass methods in the IE when I click on that web service
method (see it in soap protocol).

public abstract class ABC
{
public string Phone;
}

public class MyClass : ABC
{
public string Name;
public string Street;
}

Thanks

Dan Rogers said:
In this case you don't need to use XmlInclude. You would only need the
XmlInclude if you had an interface that included the ability for different
types than expected at compile time to be added to the return at runtime.
This happens when you return an object as the return type, for instance.

Regards,

Dan Rogers
Microsoft Corporation
--------------------
From: "R.A." <[email protected]>
Subject: how or when to use XmlInclude ?
Date: Tue, 7 Dec 2004 09:01:24 -0600
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
NNTP-Posting-Host: 204.124.82.48
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXS01.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP0 8
phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.aspnet.webservices:27071
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices

Hi

I have a web service that returns a custom class in one of the service
methods.

public class MyClass
{
public string Name;
public string Street;
}


web method:

[WebMethod (Description = "Get customer info")]
public MtClass [] GetCustomerList (string ZipCode)

{

...

}



As I am testing I didn't use XmlInclude for MyClass or for the
GetCustomerList method but still I am able to get the serialized information
back from the web service. If this is the case then do I need XmlInclude at
all?



Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top