[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Venkat

8/13/2003 12:19:00 PM

Problem : While invoking the returnAl without the returnMyObject WebMethod
enabled, the operation fails with an invalid Operation exception for the
object MyObject. It suggests that I Soapinclude or XmlInclude for
non-static objects - which I tried.

Can someone please suggest a mechanism to achieve this. The MyObject is
defined in the WSDL I can see that.

The moment I enable the returnMyObject (now the MyObject is defined at a
different level in the WSDL - but same definition) everything is working
fine.

Please Help.

To recreate I suggest u can create a sample WebService and cut-n-paste the
WebMethods and the class defn .. You may need the XMl.Serialization assembly
for SoapInclude ..



Thanks

Venky

Here is the sample of the code

Created a small WebService using the wizard. I have removed most of the code
for clarity

using System;
using System.Collections;
using System.Xml.Serialization;
<All relevant using statements ...>


namespace MyCollections
{

public class Service1 : WebService
{

public Service1()
{
}

[WebMehtod]
public string HelloWorld()
{ return "Hello World" ; }

// Uncomment the WebMethod attribute and it will work
// [WebMethod]
[SoapRpc()]
public MyObject returnMyObject()
{
MyObject myo = new MyObject();
myo.a = 1; myo.s = "Sample";
return myo;
}

[WebMethod]
[SoapRpc()]
// [SoapInclude(typeof(MyObject))] // This makes NO
Difference
public ArrayList returnAL()
{
ArrayList myA = new ArrayList();
MyObject myo = new MyObject();
myo.a = 1; myo.s = "SamplefromMethod";

int a = 1;
double d = 2.0;
string st = "Sample String in AL";
myA.Add(a); myA.Add(d); myA.Add(st); // All
these will be returned if myobject is not added ..

// Next line causes the problem
myA.Add(myo);
return myA
}

public class MyObject()
{
public int a;
public string s;
// I even tried the following instead of the above two lines
// int _a; string _s;
// public int a { get { return _a;}; set {_a = value;} }
// public string s { get {return _s;}; set (_s = value ;} }
}
}

}