Hi,
I'm pretty new to this, so I hope I'm not completely off-track. I built a
web service in C++ that I'm accessing trough another C++ client. I have no
problems with the regular web service functionalities, but I want to define a
class on the server side that I could return to the client trough a function,
and then access this class' functions on the client side.
I guess I'm doing this wrong. Here is how my code looks:
namespace WebServer
{
[Serializable]
public __gc class TestClass
{
static String* m_staticString = S"TestString";
public: String* GetStaticString(){return m_staticString;};
};
public __gc
class WebServerClass : public System::Web::Services::WebService
{
//(...)
public:
[System::Web::Services::WebMethod]
TestClass* GetTestClass()
{
return new TestClass();
}
};
Now I can declare the TestClass on the client side, but I get a
"GetStaticString is not a member of localhost::TestClass" error when I try
to access that function. Also, when I look at the localhost.h generated file,
the only things regarding TestClass I see are:
public __gc class TestClass;
and
/// <remarks/>
[System::Xml::Serialization::XmlTypeAttribute(Namespace=S"http://tempuri.org/")]
public __gc class TestClass {
};
What gives?
Keenan Newton - 19 Feb 2005 16:49 GMT
Web Services will not serialize the implementation of a class, just the
public fields and properties (the data payload). Web Services is a way
of passing messages around not the object itself (implementation).
Phil Greg - 21 Feb 2005 12:53 GMT
That's what I understood, but then, in my example, shouldn't the
GetStaticString method show up?
> Web Services will not serialize the implementation of a class, just the
> public fields and properties (the data payload). Web Services is a way
> of passing messages around not the object itself (implementation).
Keenan Newton - 21 Feb 2005 22:45 GMT
No GetStaticString is a method, not a property or field. Compare it to
exdporting a Excel file to csv. you just store the data, not the Excel
functions you also create.