c# - Using reflection to call an ASP.NET web service -


say have asmx web service, myservice. service has method, mymethod. execute mymethod on server side follows:

myservice service = new myservice(); service.mymethod(); 

i need similar, service , method not known until runtime.

i'm assuming reflection way go that. unfortunately, i'm having hard time making work. when execute code:

type.gettype("myservice", true); 

it throws error:

could not load type 'myservice' assembly 'app_web__ktsp_r0, version=0.0.0.0, culture=neutral, publickeytoken=null'.

any guidance appreciated.

i'm not sure if best way go it. obvious way me, make http request, , call webservice using actual http or post. using method, i'm not entirely sure how you'd set data sending web service. i've added sample code in vb.net

dim httprequest httpwebrequest dim httpresponse httpwebresponse dim responsereader streamreader dim url string dim responsetext string  url = "http://www.example.com/mywebserivce/mymethod?arg1=a&arg2=b"  httprequest = httpwebrequest.create(url) httprequest.method = "get"  httpresponse = httprequest.getresponse()  responsereader = new streamreader(httpresponse.getresponsestream()) responsetext = responsereader.readtoend() 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -