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, ...)
???

jamesRank #1,153 · 1.6K reputationPosted Feb 11, 2004, 8:51 AM EST
yufufi9 reputationPosted Feb 11, 2004, 11:53 AM EST
yufufi9 reputationPosted Feb 11, 2004, 11:54 AM EST
jamesRank #1,153 · 1.6K reputationPosted Feb 11, 2004, 12:23 PM EST
yufufi9 reputationPosted Feb 11, 2004, 10:30 PM EST
jamesRank #1,153 · 1.6K reputationPosted Feb 12, 2004, 5:00 AM EST
yufufi9 reputationPosted Feb 16, 2004, 9:45 AM EST