web services in asp.net

Posted by Murugavelmsc under Interview Questions on 4/2/2013 | Points: 10 | Views : 3349 | Status : [Member] | Replies : 6
Hi Experts,

I have two web services with same method name but its functionality is different.

How can i call the web services based on the condition.

Please help me.

Thanks,
Murugavel S

Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/



Responses

Posted by: Jayakumars on: 4/2/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

Dotnet Allow Overloading

For Ex We Are use Duplicate method name but there only based on Parameter like this


[WebMethod]
public string HelloWorld(string RecStr) {
RecStr = RecStr + " " + "Welcome";
return RecStr;
}

[WebMethod]
public string HelloWorld(string RecStr,string RecStr1) {
RecStr = RecStr + " " + "Welcome";
return RecStr;
}


Mark as Answer if its helpful to you

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Murugavelmsc on: 4/2/2013 [Member] Starter | Points: 25

Up
0
Down
Hi Jayakumar,

Same method name and same parameter.

How can i invoke the two web services based on condition in the code.

Thanks,
Murugavel S


Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 4/2/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi
Murugavel

Working this in my System.

1.How to Call Webservice Method in our Asp Page

WebService wb1=new WebService ();
string Rec1 = wb1.HelloWorld("Asp.net");
string Rec2 = wb1.HelloWorld("Asp.net","Dotnet");


Webservice like this

[WebMethod]
public string HelloWorld(string RecStr)
{
RecStr = RecStr + " " + "Welcome";
return RecStr;
}

[WebMethod]
public string HelloWorld(string RecStr, string RecStr1)
{
RecStr = RecStr1 + " " + "Welcome";
return RecStr;
}


Mark as Answer if its helpful to you

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Murugavelmsc on: 4/2/2013 [Member] Starter | Points: 25

Up
0
Down
Hi jayakumar,

in the web services have same number of parameters

public string HelloWorld(string RecStr, string RecStr1) instead of public string HelloWorld(string RecStr)

Thanks,
Murugavel S


Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 4/2/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

also try this code

WebService wb1=new WebService ();
string Empame = "AAA";
if (Empame == "AAA")
{
string Rec1 = wb1.HelloWorld("Asp.net");
}
else
{
string Rec2 = wb1.HelloWorld("Asp.net", "Dotnet");
}


Mark as Answer if its helpful to you

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 4/2/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hello
murugavel

see this

public string HelloWorld(string RecStr, string RecStr1) - here 2 parameters

public string HelloWorld(string RecStr) - here 1 Paramters.

so we are call this method based on parameter thats overloading.

Mark as Answer if its helpful to you

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response