473,394 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Exporting embeded objects passed in object[] parameters

Hello,

I'm writing a service using VS2005 and C#. I've found that only the objects
used as parameters in WebMethods get exported to proxy dlls and the Service
Description. I'd like my service clients to be able to use the objects I've
defined in messages to the service and send them as "object" parameters or as
embeded items in other objects.

I can work around the problem by declaring all of the objects as public
members of a dummy class and then putting a dummy WebMethod on my service
class that takes a reference to the dummy class. If I do this the xml Service
Description contains all of the type information and WSDL.EXE emits the
correct information into the proxy dll. It occurs to me, though, that there
must be some type of directive or something that lets you tell the proxy and
Service Description generator that you want certain items included in their
output.

Can anyone tell me the correct way to do this?

Thanks
Al

--
Al
Feb 1 '07 #1
4 1616
"Al" <Al@discussions.microsoft.comwrote in message
news:28**********************************@microsof t.com...
Hello,

I'm writing a service using VS2005 and C#. I've found that only the
objects
used as parameters in WebMethods get exported to proxy dlls and the
Service
Description. I'd like my service clients to be able to use the objects
I've
defined in messages to the service and send them as "object" parameters or
as
embeded items in other objects.

I can work around the problem by declaring all of the objects as public
members of a dummy class and then putting a dummy WebMethod on my service
class that takes a reference to the dummy class. If I do this the xml
Service
Description contains all of the type information and WSDL.EXE emits the
correct information into the proxy dll. It occurs to me, though, that
there
must be some type of directive or something that lets you tell the proxy
and
Service Description generator that you want certain items included in
their
output.

Can anyone tell me the correct way to do this?
I don't understand. You have defined some classes which are not used as
parameters to or return types from your web service. Yet you want the
clients of your web service to be able to use them? What will they be using
them _for_?

John
Feb 2 '07 #2
Let's say you have a customer object that includes finance information and
inventory information. In this case the customer object has a reference to a
finance object and an inventory object. The client creates and initializes a
finance object and an inventory object. Then it creates the client object and
initializes the client object with the finance and inventory object.

The web method signature might be

class ClientInfo
{
FinanceInfo financeInfo;
InventoryInfo inventoryInfo;
}

[WebMethod(EnableSession = true)]
public void SendClientInfo(ClientInfo clientInfo)
{
...
}

This is an example; whether or not you'd design the class hierarchy like
this isn't important.

FinanceInfo and InventoryInfo won't appear in the proxy dll or the document
description.

I hope this answers your question. At least they don't in mine.
--
Al
"John Saunders" wrote:
"Al" <Al@discussions.microsoft.comwrote in message
news:28**********************************@microsof t.com...
Hello,

I'm writing a service using VS2005 and C#. I've found that only the
objects
used as parameters in WebMethods get exported to proxy dlls and the
Service
Description. I'd like my service clients to be able to use the objects
I've
defined in messages to the service and send them as "object" parameters or
as
embeded items in other objects.

I can work around the problem by declaring all of the objects as public
members of a dummy class and then putting a dummy WebMethod on my service
class that takes a reference to the dummy class. If I do this the xml
Service
Description contains all of the type information and WSDL.EXE emits the
correct information into the proxy dll. It occurs to me, though, that
there
must be some type of directive or something that lets you tell the proxy
and
Service Description generator that you want certain items included in
their
output.

Can anyone tell me the correct way to do this?

I don't understand. You have defined some classes which are not used as
parameters to or return types from your web service. Yet you want the
clients of your web service to be able to use them? What will they be using
them _for_?

John
Feb 2 '07 #3
I believe that you will need decorate all the classes with the attributes
XmlRootAttribute (in the main class) and XmlElementAttribute (in the
subclasses).

"Al" <Al@discussions.microsoft.comwrote in message
news:E2**********************************@microsof t.com...
Let's say you have a customer object that includes finance information and
inventory information. In this case the customer object has a reference to
a
finance object and an inventory object. The client creates and initializes
a
finance object and an inventory object. Then it creates the client object
and
initializes the client object with the finance and inventory object.

The web method signature might be

class ClientInfo
{
FinanceInfo financeInfo;
InventoryInfo inventoryInfo;
}

[WebMethod(EnableSession = true)]
public void SendClientInfo(ClientInfo clientInfo)
{
...
}

This is an example; whether or not you'd design the class hierarchy like
this isn't important.

FinanceInfo and InventoryInfo won't appear in the proxy dll or the
document
description.

I hope this answers your question. At least they don't in mine.
--
Al
"John Saunders" wrote:
>"Al" <Al@discussions.microsoft.comwrote in message
news:28**********************************@microso ft.com...
Hello,

I'm writing a service using VS2005 and C#. I've found that only the
objects
used as parameters in WebMethods get exported to proxy dlls and the
Service
Description. I'd like my service clients to be able to use the objects
I've
defined in messages to the service and send them as "object" parameters
or
as
embeded items in other objects.

I can work around the problem by declaring all of the objects as public
members of a dummy class and then putting a dummy WebMethod on my
service
class that takes a reference to the dummy class. If I do this the xml
Service
Description contains all of the type information and WSDL.EXE emits the
correct information into the proxy dll. It occurs to me, though, that
there
must be some type of directive or something that lets you tell the
proxy
and
Service Description generator that you want certain items included in
their
output.

Can anyone tell me the correct way to do this?

I don't understand. You have defined some classes which are not used as
parameters to or return types from your web service. Yet you want the
clients of your web service to be able to use them? What will they be
using
them _for_?

John
Feb 2 '07 #4
Thanks for your reply, Mariano. I tried different combinations of the
attributes you mentioned without any success. Here's a simplified version of
what I'd like to do. If I could get this working I could probably figure out
the embeded versions. I have the following classes and method declared
inside my WebService derived class:

[XmlRootAttribute]
public class Type1 {
string Name_;
public string Name {
get { return Name_; }
set { Name_ = value; }
}
}
[XmlRootAttribute]
public class Type2 {
string Name_;
public string Name {
get { return Name_; }
set { Name_ = value; }
}
}
[WebMethod(EnableSession = true)]
public object[] GetExportObjects() {
Type1 t1 = new Type1();
t1.Name = "Pozo";
Type2 t2 = new Type2();
t2.Name = "Lucky";
object[] objects = new object[] {t1, t2};
return objects;
}

Neither Type1 nor Type2 show up in my web document. I tried this with
various properties (e.g., "ElementName") but it didn't have any affect.

I'd appreciate any other suggestions you might have.

--
Al
"Mariano Omar Rodriguez" wrote:
I believe that you will need decorate all the classes with the attributes
XmlRootAttribute (in the main class) and XmlElementAttribute (in the
subclasses).

"Al" <Al@discussions.microsoft.comwrote in message
news:E2**********************************@microsof t.com...
Let's say you have a customer object that includes finance information and
inventory information. In this case the customer object has a reference to
a
finance object and an inventory object. The client creates and initializes
a
finance object and an inventory object. Then it creates the client object
and
initializes the client object with the finance and inventory object.

The web method signature might be

class ClientInfo
{
FinanceInfo financeInfo;
InventoryInfo inventoryInfo;
}

[WebMethod(EnableSession = true)]
public void SendClientInfo(ClientInfo clientInfo)
{
...
}

This is an example; whether or not you'd design the class hierarchy like
this isn't important.

FinanceInfo and InventoryInfo won't appear in the proxy dll or the
document
description.

I hope this answers your question. At least they don't in mine.
--
Al
"John Saunders" wrote:
"Al" <Al@discussions.microsoft.comwrote in message
news:28**********************************@microsof t.com...
Hello,

I'm writing a service using VS2005 and C#. I've found that only the
objects
used as parameters in WebMethods get exported to proxy dlls and the
Service
Description. I'd like my service clients to be able to use the objects
I've
defined in messages to the service and send them as "object" parameters
or
as
embeded items in other objects.

I can work around the problem by declaring all of the objects as public
members of a dummy class and then putting a dummy WebMethod on my
service
class that takes a reference to the dummy class. If I do this the xml
Service
Description contains all of the type information and WSDL.EXE emits the
correct information into the proxy dll. It occurs to me, though, that
there
must be some type of directive or something that lets you tell the
proxy
and
Service Description generator that you want certain items included in
their
output.

Can anyone tell me the correct way to do this?

I don't understand. You have defined some classes which are not used as
parameters to or return types from your web service. Yet you want the
clients of your web service to be able to use them? What will they be
using
them _for_?

John
Feb 2 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Andy | last post by:
Hi Could someone clarify for me the method parameter passing concept? As I understand it, if you pass a variable without the "ref" syntax then it gets passed as a copy. If you pass a...
48
by: Andrew Quine | last post by:
Hi Just read this article http://www.artima.com/intv/choices.html. Towards the end of the dicussions, when asked "Did you consider including support for the concept of immutable directly in C#...
0
by: Elliot M. Rodriguez | last post by:
I implemented a very small, basic data access layer for my web application. It works just fine, except for this one bug. One of my methods returns an abstracted dataset. To accomodate X number of...
14
by: Niklas | last post by:
Hi What I have learned is that a variable is just a reference when dealing with Objects. Are you supposed to use ByVal or ByRef in functions? They produce the same result or have I missed...
1
by: BobRoyAce | last post by:
I have a class that has several Subs that do DB things, some of which require the same set of parameters to be passed to a stored procedure. One class has 12 parameters and part of code used to...
20
by: walterbyrd | last post by:
Reading "Think Like a Computer Scientist" I am not sure I understand the way it describes the way objects work with Python. 1) Can attributes can added just anywhere? I create an object called...
4
by: Deckarep | last post by:
Hello fellow C# programmers, This question is more about general practice and convention so here goes: I got into a discussion with a co-worker who insisted that as a general practice all...
0
by: Al Santino | last post by:
Hello, I'm writing a service using VS2005 and C#. I've found that only the objects used as parameters in WebMethods get exported to proxy dlls and the Service Description. My service clients can...
11
by: MikeT | last post by:
This may sound very elementary, but can you trap when your object is set to null within the object? I have created a class that registers an event from an object passed in the constructor. When...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.