473,396 Members | 1,989 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,396 software developers and data experts.

C# pass an array of objects to a WebService...

I've googled my brains out and haven't found the answer yet, so...

I have a WebMethod that accepts an array of Order objects as a
parameter. I cannot figure out how to send an array to the webservice

namespace ArrayTest
{
public class OrderService : System.Web.Services.WebService
{
private Order[] _Orders;

public OrderService()
{}

[WebMethod]
[XmlInclude(typeof(Order))]
public void ReceiveOrders(Order[] orders)
{
_Orders = orders;

foreach(Order order in _Orders)
{
Console.WriteLine(order.id);
}
}
}
}

And here is my object:

namespace ArrayTestTypes
{
public class Order
{
public int id;

public Order()
{}
}
}

I created a simple little windows for to test out the service. The
form calls the following method:

private void button1_Click(object sender, System.EventArgs e)
{
ArrayTestTypes.Order[] orders = new ArrayTestTypes.Order[3];

ArrayTestTypes.Order order = new ArrayTestTypes.Order();
order.id = 1;
orders[0] = order;
order = new ArrayTestTypes.Order();
order.id = 100;
orders[1] = order;
order = new ArrayTestTypes.Order();
order.id = 10000;
orders[2] = order;

ArrayList list = new ArrayList(orders);

OrderService.OrderService orderService = new
OrderService.OrderService();

orderService.ReceiveOrders((OrderService.Order[])list.ToArray(typeof(OrderService.Order)));
}

So, I have an array of ArrayTestTypes.Order[] but the generated proxy
is expecting an array of OrderService.Order[] (OrderService is the
proxy generated by adding a web ref).

So, my question is how do I get my array into the format that the web
service expects?

Nov 23 '05 #1
2 16570
In proxy class --
-kill generated orders class
-add reference to order class from local namespace
When you update web referance, you'll have to do this again.

<ch***************@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
I've googled my brains out and haven't found the answer yet, so...

I have a WebMethod that accepts an array of Order objects as a
parameter. I cannot figure out how to send an array to the webservice

namespace ArrayTest
{
public class OrderService : System.Web.Services.WebService
{
private Order[] _Orders;

public OrderService()
{}

[WebMethod]
[XmlInclude(typeof(Order))]
public void ReceiveOrders(Order[] orders)
{
_Orders = orders;

foreach(Order order in _Orders)
{
Console.WriteLine(order.id);
}
}
}
}

And here is my object:

namespace ArrayTestTypes
{
public class Order
{
public int id;

public Order()
{}
}
}

I created a simple little windows for to test out the service. The
form calls the following method:

private void button1_Click(object sender, System.EventArgs e)
{
ArrayTestTypes.Order[] orders = new ArrayTestTypes.Order[3];

ArrayTestTypes.Order order = new ArrayTestTypes.Order();
order.id = 1;
orders[0] = order;
order = new ArrayTestTypes.Order();
order.id = 100;
orders[1] = order;
order = new ArrayTestTypes.Order();
order.id = 10000;
orders[2] = order;

ArrayList list = new ArrayList(orders);

OrderService.OrderService orderService = new
OrderService.OrderService();

orderService.ReceiveOrders((OrderService.Order[])list.ToArray(typeof(OrderSe
rvice.Order))); }

So, I have an array of ArrayTestTypes.Order[] but the generated proxy
is expecting an array of OrderService.Order[] (OrderService is the
proxy generated by adding a web ref).

So, my question is how do I get my array into the format that the web
service expects?

Nov 23 '05 #2
In proxy class --
-kill generated orders class
-add reference to order class from local namespace
When you update web referance, you'll have to do this again.

<ch***************@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
I've googled my brains out and haven't found the answer yet, so...

I have a WebMethod that accepts an array of Order objects as a
parameter. I cannot figure out how to send an array to the webservice

namespace ArrayTest
{
public class OrderService : System.Web.Services.WebService
{
private Order[] _Orders;

public OrderService()
{}

[WebMethod]
[XmlInclude(typeof(Order))]
public void ReceiveOrders(Order[] orders)
{
_Orders = orders;

foreach(Order order in _Orders)
{
Console.WriteLine(order.id);
}
}
}
}

And here is my object:

namespace ArrayTestTypes
{
public class Order
{
public int id;

public Order()
{}
}
}

I created a simple little windows for to test out the service. The
form calls the following method:

private void button1_Click(object sender, System.EventArgs e)
{
ArrayTestTypes.Order[] orders = new ArrayTestTypes.Order[3];

ArrayTestTypes.Order order = new ArrayTestTypes.Order();
order.id = 1;
orders[0] = order;
order = new ArrayTestTypes.Order();
order.id = 100;
orders[1] = order;
order = new ArrayTestTypes.Order();
order.id = 10000;
orders[2] = order;

ArrayList list = new ArrayList(orders);

OrderService.OrderService orderService = new
OrderService.OrderService();

orderService.ReceiveOrders((OrderService.Order[])list.ToArray(typeof(OrderSe
rvice.Order))); }

So, I have an array of ArrayTestTypes.Order[] but the generated proxy
is expecting an array of OrderService.Order[] (OrderService is the
proxy generated by adding a web ref).

So, my question is how do I get my array into the format that the web
service expects?

Nov 23 '05 #3

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

Similar topics

6
by: Morten | last post by:
Hi! I've made my own webservice which returns a collection of objects with 4 properties (or fields when they get returned from the webservice...). Is there an easy way to display each object...
2
by: Anil Pundhir | last post by:
What is the best way to pass data to a web service. The client(to send data) has .net environment and also the server on which the web service is hosted also has the .net environment. Should I...
0
by: brian.mills | last post by:
I have a web service in a technology called Jade. It is returning a StudentObject, which has an array of Application Objects on it. The Application objects never are actually Application Instances,...
10
by: Jon Maz | last post by:
Hi, I am trying to pass an array from an asp page (JScript) to a dotnet web service using the SOAP Toolkit 3.0. This is still at the Hello World stage, as you can see: WEB SERVICE METHOD ...
0
by: christopherkilmer | last post by:
I've googled my brains out and haven't found the answer yet, so... I have a WebMethod that accepts an array of Order objects as a parameter. I cannot figure out how to send an array to the...
5
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
0
by: rolandheller | last post by:
Hello! We're currently looking at migrating some of our code to .NET. Our old application written in VB6 has a DLL function that passes an Array of Variants to another function. We're planning...
6
by: placek | last post by:
Hi all. I would like to create two web services: - The first one - ImportData - should take as an input parameter a XML document and return an integer saying if passed XML document was valid...
5
by: David++ | last post by:
Hi folks, I would be interested to hear peoples views on whether or not 'pass by reference' is allowed when using a Web Service method. The thing that troubles me about pass-by-reference into...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
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...
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
marktang
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,...
0
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.