Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Consume C# WS in C# App
Message
 
To
16/03/2008 11:07:04
General information
Forum:
ASP.NET
Category:
Web Services
Miscellaneous
Thread ID:
01302443
Message ID:
01302488
Views:
7
I completely don't understand this. I get the idea of a factory, but I don't understand the code.

First, I'm getting "The type or namespace name 'SoapHttpClientProtocol' could not be found (are you
missing a using directive or an assembly reference?)"

Aside from me asking what reference I'm missing, how do I find out that info the next time someone
provides a code snippet?

Thanks





>Kevin,
>
>You can access the web reference directly, as in Viv's example, but we use a Web Service factory class for one simple reason:
>
>When you add a web reference to your project, the actual URL to that reference gets stored. At runtime, you may have a need to change that to something else (something you may have stored in a config file perhaps). When you instantiate the Web Service via a factory class, you can set the URL at runtime.
>
>
>public class WebServiceFactory
>{
>	// the default URL
>	private static string m_url = "http://localhost/webservices.myapp/";
>
>	public static SoapHttpClientProtocol GetWebService(SoapHttpClientProtocol ws)
>	{
>		string url    = ws.Url.ToLower();
>		string newurl = this.MyMethodToGetURLFromConfig();
>		if (newurl.Length == 0 || newurl.ToLower().Trim() == m_url)
>		{
>			return ws;
>		}
>		else
>		{
>			ws.Url = url.Replace(m_url, newurl);
>			return ws;
>		}
>	}
>
>
>And you use it like this:
>
>
>// declaration
>private MyApp.PersonnelWS.Personnel oWS;
>
>// instantiation
>this.oWS  = (MyApp.PersonnelWS.Personnel)WebServiceFactory.GetWebService(new MyApp.PersonnelWS.Personnel());
>
>// use as any other class method call
>string XML = this.oWS.GetPersonnel(MyKey);
>
>
>~~Bonnie
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform