Wednesday, March 28, 2012

Why my web services cant accept parameter?

When my javascript call the echoString(s) in the following code, it return nothing

<%@dotnet.itags.org. WebService Language="C#" Class="WebService" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService {

[WebMethod]
public string echoString(string s) {
return s;
}

}

The strange things are my .NET program works fine with the code above and my javascript client program doesn't work with the code above but works fine with other people's web services. EX:

http://www.mssoapinterop.org/asmx/simple.asmx?op=echoString

What is wrong with my code? Thank you!!!!!!!!!

asdpai:

what is wrong with my code?

nothing, code is correct. Decorate youre WebService with theSystem.Web.Script.Services.ScriptService() and the WebMethode with the ScriptMethod() attribute eg.

<%@. WebService Language="C#" Class="WebService" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
usingSystem.Web.Script.Services;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService()]
public class WebService : System.Web.Services.WebService {

[ScriptMethode()]
[WebMethod]
public string echoString(string s) {
return s;
}

}

Hope that coul help.

No comments:

Post a Comment