Passing objects to Web Services 2
I have a class, lets say Message. Added as a reference to both to my web service and client application.
A webmethod takes the message class as a parameter.
What I want to do is a create an instance in the client application and pass it to the webmethod.
I can't do:
Message yoyo=new Message(filename);
myservice.procMessage(yoyo);
.net says I sent Message but what function wants is localhost.Message and cannot cast one to other.
Then I tried boxing. But this time:
An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll
Additional information: There was an error generating the XML document.
----
Then I found the post in the forums. Solution was split your class into 2, data and code. Pass the one with the data.
Ok. Then I created a sprMessage class. Sorry. localhost.sprMessage class.
localhost.sprMessage ziza=new localhost.sprMessage();
Message yoyo=new Message(filename);
yoyo.CopyTo(ziza);
Oops. CopyTo wants sprMessage but what I send is localhost.sprMessage which is completely different ??
--
Only solution I can think of now. Instead of sending message class to ProMessage send its data one by one..
[webmethod]
promessage(string name,int [] values, ...)
???
yufufiPosted Feb 16, 2004, 2:45 PM
jamesPosted Feb 12, 2004, 10:00 AM
yufufiPosted Feb 12, 2004, 3:30 AM
jamesPosted Feb 11, 2004, 5:23 PM
yufufiPosted Feb 11, 2004, 4:54 PM
yufufiPosted Feb 11, 2004, 4:53 PM
jamesPosted Feb 11, 2004, 1:51 PM