Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, November 23, 2009 7:28 PM
Hello i'm trying to call an webservice with the following code but "Send Web Service method name is not valid" is comming as an exception. I now its the right name but i cant figure out what is causing this.Any help ?
//////////////////////////////////////////////////////////////////////////////////
WebMethod webmethod = new WebMethod("http://localhost:3441/SMS.asmx");
object[] paremeters = new object[5];
paremeters[0] = "+351914336160";
paremeters[1] = "TESTE EVOCAÇAO OH YEAH";
paremeters[2] = "false";
paremeters[3] = "250";
paremeters[4] = "dapinheiro";
webmethod.CallMethod("Send", paremeters);
/////////////////////////////////////////////////////////////////////////////////
[System.Web.Services.WebServiceBindingAttribute(Name = "SMS", Namespace = "http://tempuri.org/")]
public class WebMethod : System.Web.Services.Protocols.SoapHttpClientProtocol
{
[System.Diagnostics.DebuggerStepThroughAttribute()]
public WebMethod(string url)
{
this.Url = url;
}
//[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Send", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public object[] CallMethod(string method, object[] parameters)
{
try
{
object[] results = this.Invoke(method, parameters);
return results;
}
catch (Exception ex)
{
throw ex;
}
}
}
Best Regards, Diogo Pinheiro
All replies (3)
Thursday, November 26, 2009 10:06 AM ✅Answered
Hi,
This is due to you are missing [Web Method] attribute on your service method, this will cause your method will not be exposed.
Try to modify your CallMethod as following:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Send", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[Web Method]
public object[] CallMethod(string method, object[] parameters)
{
try
{
object[] results = this.Invoke(method, parameters);
return results;
}
catch (Exception ex)
{
throw ex;
}
}
Thanks
Binze
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Monday, November 23, 2009 8:36 PM
up !Best Regards, Diogo Pinheiro
Thursday, November 26, 2009 4:40 PM
Here you can see my method. I have the [WebMethod]. Anyway I'm going to try with your callling.
namespace WebserviceLayer
{
/// <summary>
/// Summary description for SMS
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class SMS : System.Web.Services.WebService
{
[WebMethod]
public bool Send(string receiver, string message, bool isUrgent, string businessArea, string userName )
{
ISmsService smsService = new SmsService();
return smsService.SendSms(receiver, message, isUrgent, businessArea, userName, DateTime.Now);
}
}
}
Best Regards, Diogo Pinheiro