Saturday 15 August 2015

asp.net - How to consume different proxyclass versions (production or test) of ASMX webservice -


I got an ASMX webservice as a separate project in Visual Studio 2005. In pursuance of the "separate assembly", my proxy class is in a separate class library project that has no code - a Web named ASMXproxy with reference only Thus, when I compile, I have a FileServiceProxy.dll , context, app.config , .disco and .wsdl files.

To consume this WS, I have the same web app project, which is called Flamesassadado in a similar solution. It does not have any web context, but instead there is a "regular" reference for FileServiceProxy.dll. In my default .aspx.cs file, I can access my WS through these snippets:

  using FileServiceProxy.ASMXproxy; Public Partial Class _Default: System.Web.UI.Page {ASMXproxy.FileService BrokerService; Protected Zero Page_Old (Object Sender, EventArgues E) {Try {BrokerService = New ASMX Proxy. Fileserve (;);  

So when things work right in this way, I find it strange when I want to test a deployment version or change the "localhost" version. I just can not make changes to app.config:

  & lt; Application settings & gt; & Lt; FileServiceProxy.Properties.Settings & gt; & Lt; Setting name = "FileServiceProxy_CSSMXProxy_FileSyver" serializeAs = "string" & gt; & Lt; Price & gt; Http: //localhost/TRIMBrokerService/FileService.asmx< / Pricing & gt; & Lt; / Settings & gt; & Lt; /FileServiceProxy.Properties.Settings> & Lt; / ApplicationSettings & gt;  

In short, when I have to publish my web app to any other server, then I have to change the web context in the proxy class and recreate it. Then when I want to debug it on my localhost, then I have to change the web reference to the local host (above).

Ideally, I'd like to expose any type of option (such as a radio button or a text box to replace a URL on runtime) in my web app demo project, as if I was a type of "Late binding" can do the desired FileServiceProxy.dll to be used on runtime, others have sketched the offers, but I've stuck on how to do this. Must Ojekt and therefore other DLLs - maybe Failsewayrprokseepiardi DLLs - it seems strange and even though I'm not sure that I do.

Actually, you can use the same context. Simply change the proxy instances URL properties:

 using  (var svc = new WebServiceProxy ()) {svc.Url = realUrl; Var result = svc.ServiceMethod (); }  

No comments:

Post a Comment