Dynamically load .asmx web-service

邮差的信 提交于 2019-12-11 15:26:28

问题


I have an .aspx page that can perform a number of functions. The type of function is determined at run-time depending on which button the user clicks. This makes makes a web-service call to an .asmx method. The web-service call returns html and javascript which then become part of the original page.

This new content has javascript events attached to button clicks, data validation etc. In turn these events then call their own web-service methods in another .asmx file. The main page does not know about these other .asmx files when the page loads.

So, is there any way of dynamically loading these .asmx files on demand?


回答1:


You can create an assembly dynamically from the webservice, we do this where I work. Check out this codeproject link for an example that you can work from.

(disclaimer, I only gave the codeproject page a quick once over to see that it should be a good start for what you want, it's along the same lines of what we do)




回答2:


"ASMX files" are not loaded. They are files which define ASMX web services - which area called. You don't need to load these files.




回答3:


Check out this link for the project code! That helps you call the web service at run-time. You can save and reuse the web service structure. There is a simple example:

//how to use service proxy
var factory = new ProxyFactory();
var service = factory.ImportService("www.site.net/webservice.asmx");

//how to call service method
var proxy = new Proxy(service.ServiceFile, service.ServiceName);
var result = proxy.InvokeMethod("CallMe", new ProxyMember("Id", 123));

//how to use method result
foreach (var item in result)
{
    var Id = item.Members["Id"].Value;
}


来源:https://stackoverflow.com/questions/1380310/dynamically-load-asmx-web-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!