WebMethod c#return double []

时间:2013-11-25 22:35:17

标签: c#

我遇到WebMethod的问题,返回类型是double []。我试图在表单中访问此方法,但结果是:

为操作'FIR'反序列化回复消息正文时出错。预期名称空间为“http://google.com/”的结束元素“FIRResult”。在命名空间“http://google.com/”中找到元素“double”。第1行,第278位。

示例代码:

private void submit_Click(object sender, EventArgs e)
        {
            int N = int.Parse(textBox1.Text);
            int fN = int.Parse(textBox6.Text);
            int fS = int.Parse(textBox5.Text);
            int rippleLimit = int.Parse(textBox4.Text);

            double[] result = ws.FIR(N, (double)fN, (double)fS, rippleLimit);


            this.Hide();
        }


 [WebMethod]
        public double[] FIR(int N, double fs, double fn, int rippleLimit)
        {

            double rippleDev;
            List<double> result = new List<double>();

            List<double> signal = firDesign(N, fn, fs);
            DTFT(signal, N, fs, fn, 1);

            List<double> moduledSignal = moduleSignal(Service1.real, Service1.img);

            rippleDev = calculateRippleDev(fn, moduledSignal);

            result.Add(rippleDev);

        for (int i = 0; i < moduledSignal.Count; i++)
        {
            result.Add(moduledSignal[i]);
        }


        return result.ToArray();
    }

3 个答案:

答案 0 :(得分:0)

Web方法需要static,请尝试:

[WebMethod]
public static double[] FIR(int N, double fs, double fn, int rippleLimit)
...

答案 1 :(得分:0)

我尝试过静态,但现在它有这个问题...... System.Web.Services.Protocols.SoapException:服务器无法识别HTTP标头SOAPAction的值:http://google.com/FIR。    在System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()    在System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage消息)

当我调用方法Web方法

时,在表单中

答案 2 :(得分:-1)

www.google.com来自名称空间“[WebService(Namespace)”。

相关问题