473,804 Members | 3,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tricky one (at least for me)

Here's the thing I have a web aplication (1.1) and one of my classes
has an array as a property (let's say Class A, has an ArrayList of Bs).

On the other side I have a win form app which uses web services from
the first app.
The thing is that when I create an instance of A in my win form app, I
can't add bs to de arraylist. I can't even see the ArrayList.
I also tryied with DataTables with no luck, should I try a DataSet.
What am I doing wrong???

TIA.
Regards,

Sebastián
http://sgomez.blogspot.com

Nov 29 '05 #1
5 1450
Silly thing perhaps, but you have updated the service after making a
build? Otherwise any changes you simply aren't going to show up.

Sorry if I hugely underestimated your skill-level but it's the first thing
that came to mind.

HTH,
Cyr1dian
Nov 29 '05 #2
Don't worry about it Cyr1dian, that's a must do question, I should
have said so myself.
But the answer is yes, I have.

Thanx anyways.

--
http://sgomez.blogspot.com

Nov 29 '05 #3
Okay then :)

The really obvious stuff out of the way it, as you said, does get tricky..

Sketch of what I assume you're doing (pseudo C#):

[Serializable]
Class A
{
Public int[] bs
{
get;
set;
}
}

Class ws: Webservice
{
[WebMethod]
Public A GetA();
{
A a = new A();
return a;
}
}

Class client: forms
{
client.ws.ws ServMe = new client.ws.ws();
ServMe.Credenti als = System.Net.Cred entialCache.Def aultCredentials ;
A a = ServMe.GetA();

a.bs[] = ... //but you can't see the bs property?
}

Aside from the fact that this is, obviously, a sketch; I don't see a
problem with the concept.
Is it an option for you to perhaps publish the array independantly from
the object?

grtz,
Cyr
Nov 29 '05 #4
Sebastian,

For your datatable issue, datatables are not serializable across web
services. You have to wrap the datatable in a dataset before it will
become serializable and returned from a web service. In .NET 2.0,
datatables can be returned directly from web services.

As for your arraylist issue, I've put together a working sample based
on Cyr's outline. There is one issue with ArrayLists that might be
causing your trouble, so I'll walk through what I did. Note: I changed
Cyr's arrays into arraylist objects as I believe this is what you are
trying to use.

1) I created the "A" class. You need to make sure that your property
has both a set and a get feature if you want to serialize your property
out through a web service.

[Serializable]
public class A
{
private System.Collecti ons.ArrayList myObject = new
System.Collecti ons.ArrayList(1 0);

public System.Collecti ons.ArrayList bs
{
get{
return myObject;
}
set{
bs = value;
}
}

2) I created my webmethod

[WebMethod]
public A GetArray()
{
A o = new A();
return o;
}

3) From my client, I added my web reference to my new web service

4) Here's the key when using ArrayLists, I manually opened the web
service proxy class (reference.cs) generated in my client application
and modified the stub.

The proxy will be generated with something like this in it

/// <remarks/>
[System.Xml.Seri alization.XmlTy peAttribute(Nam espace="http://tempuri.org/")]
public class A {

/// <remarks/>
public object[] bs;
}

As you can see, the bs property of the "A" class has been changed from
an arraylist into an object array. This is because the wsdl.exe tool
uses a least common denomiator approach to generating your proxies.
This will prevent you from accessing any methods associated witht the
arraylist class.

What you need to do, is manually change the type back into an array
list.

/// <remarks/>
[System.Xml.Seri alization.XmlTy peAttribute(Nam espace="http://tempuri.org/")]
public class A {

/// <remarks/>
public System.Collecti ons.ArrayList bs;
}

5) Write your client code to use the new web service

localhost1.Seri alizeTest myServiceProxy = new
localhost1.Seri alizeTest();
localhost1.A myClass = new localhost1.A();

myClass = myServiceProxy .GetArray();

myClass .bs.Add("my entry");
As I said, this is working for me, so if it still doesn't work for you,
then something else is going on that we need to find.

Hope that helps.

Peter Kelcey}

Nov 30 '05 #5
Thanx Peter, great tip.
I've solved using DataSets though...

The only problem that I see with your implementation is that you're
defining the array length, and I don't know at design time how big the
array is gonna get. So I'll keep with my DataSets and wait for VS2005
to come out (in Uruguay).

Thank you both guys.

Dec 12 '05 #6

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

Similar topics

15
2215
by: dracolytch | last post by:
Good day all, Ok, I have a pretty tricky problem that I need some help with. I pass around search query information a fair amount (specifically WHERE statements). Normally, I just rawurlencode() the buggers, and pass them via the URL. I like having the where clauses in the URL, because then someone can just bookmark the URL, or send it to a friend, and I don't have to worry about a thing. If someone does a search that requires a LIKE...
4
1913
by: Bung | last post by:
Hi, I have a tricky sql statment I have to write (tricky for me) and I am stuck. I'm having trouble with the following problem. Table1 (Column a, Column b, Column c) Table2 (Column a, Column b, Column c) Table3 (Column a, Column b, Column c) Table1 contains a row of value (1, 2, 3)
2
337
by: M Maloney | last post by:
Hey all, I was wondering if anyone could help me with this problem I have: Given a text file like this: 8 =ABC 18.00 Dr Who: Underworld 18.30 Collectors 19.00 News
25
3414
by: PyPK | last post by:
What possible tricky areas/questions could be asked in Python based Technical Interviews?
5
1636
by: Danny | last post by:
Hi there I need help with a tricky problem. I have a 2 dimensional array with qualities such as ball size, ball color, ball weight. Now I have to print out all the possible combinations of this. assume I have it stored as such i have two dimensional array ball:
8
1885
by: pras.vaidya | last post by:
Hi , below given question was asked to me during an interview and i figured it out little tricky . It would be a great help if anyone could solve it. Code : - main() { char *s1="abcd",*s2=NULL; /* From here you call a function copy which has return type void .
7
15096
by: NileshKorpe | last post by:
Can you please send me link of some c++ tricky (confusing) questions usually asked in the c++ technical interview. Thank You
1
1506
by: MorrganMail | last post by:
Or at least I find it tricky. :-) Assume we have three tables A, B and C. Table A contains a path and the distance for traveling that path: A (PathId, NodeId, Dist (from previous node)) 1, 1, 0 1, 2, 10 1, 3, 5
9
2364
by: raylopez99 | last post by:
Just an observation: pens for drawing lines in Win Forms are tricky when assignment is inside the paint handler. inside of the Paint handler, but not inside a "using" brace (that is, outside of "using { Pen mypen = new Pen(Color.Black, 1)) {}), which I think makes a difference: I find the following assignment does not work: //myPenTest instantiated in the normal constructor, as was baseline,
0
9705
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9576
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10568
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10311
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9138
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2988
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.