0

I have a web method that accepts object

[WebMethod]
public static void GetObject(object data)
{

}

Also, I have 2 classes:

class ConnectionString
{
    public string ConnectionString { get; set; }

    public DatabaseType DatabaseType { get; set; }
}

class Path
{
    public string Path { get; set; }

    public bool IsNetwork { get; set; }
}

On client side, using javascript, i defined 2 similar classes as well:

function ConnectionString() {
    this.ConnectionString = '';
    this.DatabaseType = 0;
};

function Path() {
    this.Path = '';
    this.IsNetwork = false;
};

Now, according to user decision, he can ether choose to create log in database or file system. When I send data to the method, my object resulted as null. If I create method for each object, it works. Is there a way to unbox or desirialize from OBJECT type to ?

4

1 回答 1

0

您需要创建两个方法重载,每个重载都采用可能的类之一。在当前实现中,引擎不知道应该在 WSDL 中放置哪些类...

如果您使用的是 WCF,您可以使用[KnownType]属性来指定您的方法支持哪些类。

于 2013-05-19T19:58:57.647 回答