2

I have a problem with a WebMethod which return type is a double[]. I am trying to access this method in form but result is :

Error in deserializing body of reply message for operation 'FIR'. End element 'FIRResult' from namespace 'http://google.com/' expected. Found element 'double' from namespace 'http://google.com/'. Line 1, position 278.

Example code :

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();
    }
OsomA
  • 155
  • 1
  • 18

3 Answers3

0

Web methods need to be static, try:

[WebMethod]
public static double[] FIR(int N, double fs, double fn, int rippleLimit)
...
MadSkunk
  • 3,309
  • 2
  • 32
  • 49
  • Are you sure? Microsoft uses `[WebMethod]` in a non-static context. http://msdn.microsoft.com/en-us/library/byxd99hx(v=vs.90).aspx – Nick Gotch Nov 25 '13 at 22:48
  • Odd, I need to read that link properly, but yes webmethods need to be static, see http://stackoverflow.com/questions/1360253/call-non-static-method-in-server-sideaspx-cs-from-client-side-use-javascript – MadSkunk Nov 25 '13 at 22:50
  • I think you/we are confusing WebServices with PageMethods, which are you trying to create? (both use the [WebMethod] attribute) We need to see more of your code, server side and client side. – MadSkunk Nov 25 '13 at 23:01
0

I've tried with static but now it has this problem... System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://google.com/FIR. at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)

in Form when i call the method web method

OsomA
  • 155
  • 1
  • 18
  • 1
    WE NEED TO SEE MORE CODE! How are you calling this method? Where is http://google.com coming from!? – MadSkunk Nov 25 '13 at 23:27
-1

www.google.com is from namespace "[WebService(Namespace ]".

OsomA
  • 155
  • 1
  • 18