views:

30

answers:

2

I have a web service that accepts and returns a custom class. The problem is that the Form that calls the web service method requires instantiation of the webservice.myClass instead of the local copy of the myClass? For example:

**myservice:**
class myclass
{
...
}

class myservice
{
[WebMethod]
public void mymethod(myclass cls)
{
cls.xxx = yyy;
returns cls
}
}

**caller form:**
class myclass
{
...
}

class caller
{
private void call()
{
myservice.myclass cls = new myservice.myclass(); //<-------------------
cls = myservice.mymethod(cls);
}
}

It requires myservice.myclass and I'd like to use local myclass, which is exactly the same. Is this possible?

A: 

How is it different from:

class caller
{
    private void call()
    {
        local.myclass cls = new myservice.myclass(); //<-------------------
        cls = myservice.mymethod(cls);
    }
}

What is the specific need? Instantiation is always local. If you need to keep the instance, you can pass it as an out param.

Kangkan
A: 

If I understand what you're asking, this has been asked before:

http://stackoverflow.com/questions/216884/force-net-webservice-to-use-local-object-class-not-proxy-class

Though that guy also found that it was asked yet before then as well. Maybe this one's tough for SO to parse in the suggestions :)

And trust me, this has been asked many times all over the internet. It's one of my biggest complaints about how classic web services are handled in .NET and Visual Studio, and one of the driving forces behind me switching to request/response services (and the Agatha project).

David