passing structure to a web service

S

Sharko

Hi,

I am facing a problem in passing a structure to web service.
When I pass the structure to the web method, the structure reaches the
web method with all it's attributes reinitialized based on it's data
type (attributes of type "int" are set to zero, strings are set to the
empty string, etc..)

Below are the settings and some code snippets:

- All the structures are placed in one DLL, namely, SysObjects.
- The web service has web methods whose paramaters are structures
from the SysObjects and passed by reference.

NOTE:
The attributes of the structure are internal. When the attributes
are made "public" instead of internal, everything works fine.

Code snippets:

SysObjects DLL: Below is one of the structures used
-----------------------------------------------------------------------------


public struct SysItem
{
internal int id;

internal SysItem( int id)
{
this.id = id ;
}

public int ID
{
get { return id ; }
set { /* empty */ }
}
}
_____________________________

Web Service DLL: Below is one of the web methods
---------------------------------------------------------------------------

public class TestService : System.Web.Services.WebService
{
[WebMethod]
public void Test (VBCObjects.SysItem item)
{
Console.WriteLine (item.ID);
}

[WebMethod]
public SysItem GetItem (int id)
{
return SysItem (id);
}
}

__________________________________________

ClientApp: Below is the code for the web service consumer (client)
------------------------------------------------------------------------------------------------
public Test
{
public void TestMethod()
{
TestService service = new TestService();

SysItem item= service.GetItem(100);
service.Test(item);
}
}

______________________


Thanks in advance...
 

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,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top