0

I am developing a web application using MVC 3 and ASMX Web Services.

I am trying to send a List< object > to a Web Method, but I get the following error:

" cannot convert from 'System.Collections.Generic.List' to 'WebServiceClass.ArrayOfAnyType' "

This is my Web Service definition:

public class WebServiceClass : System.Web.Services.WebService
{
    [WebMethod]
    public bool MyWebMethod(List<object> ParameterValues)
    {
        //do stuff..
    }
}

And this is the block of code where I call the Web Method:

        List<object> ParameterValues = new List<object>();

        WebServiceClass.WebServiceClassSoapClient MyWebService = new WebServiceClass.WebServiceClassSoapClient();

        //I use actual objects here, this is just for an example
        ParameterValues.Add(new DateTime(2012,5,2));
        ParameterValues.Add(23);
        ParameterValues.Add("some string");

        MyWebService.MyWebMethod(ParameterValues);

My idea was to save time and pass Lists of objects to all Web Methods instead of defining WebMethod(DateTime date, int someint, string somestring).

Is there a solution for this?

Best regards.


You are allowed to use <link /> tags inside a <head> tag, you are not allowed to use <link /> tags inside a <script> tag.

On the other hand the presence of the <link /> tag inside your <script> tag is a simple misinterpretation. xHTML documents (since you're using an xHTML DTD) indeed contain CDATA sections to make sure the content of the script area is not parsed as xHTML to.

Your error is caused by the use of xHTML reserved characters &/</>.

The validation engine is probably wrongly reading the link inside the script tags even though the content of those script tags should not parsed as HTML.

Try separating the lower that sign from the rest of the string as such:

 $('head').append('<'+'link rel="stylesheet" href="{site_url}css/high-contrast.css" type="text/css" id="hc_stylesheet"/'+'>'); 
4

1 に答える 1

0

DateTimeメソッドが、int、の 3 つのパラメータを想定している場合はstring、この引数を使用してメソッドを定義します。そうしないと、大文字と小文字を区別する必要があり、ソリューションは型安全ではありません。

コード内のすべてのメソッドは、オブジェクトのリストをパラメーターとして取っていますか? おそらくそうではありません。同じことが Web メソッドにも当てはまります。

于 2012-08-03T11:10:30.910 に答える