[英].NET webservice client from WSDL
I have a WSDL from which I generated the implementation of ClientBase namely MyService 我有一个WSDL,通过它我生成了ClientBase的实现,即MyService
function void updateData(Data data){
BasicHttpBinding binding = new BasicHttpBinding();
// see there is naked username and password.
EndpointAddress address = new EndpointAddress("http://qa.farwaha.com/eai_enu/start.swe?SWEExtSource=WebService&SWEExtCmd=Execute&UserName=john&Password=johspassword");
MyService service = new MyService(binding, address);
try{
service.update(data);
}finally{
service.close();
}
}
Unfortunately, to call this web service I have to pass User name and password as shown in the code. 不幸的是,要调用此Web服务,我必须传递代码中所示的用户名和密码。 so, my question is around best practices.
因此,我的问题是围绕最佳实践。
Given that its a Winform Application. 鉴于其Winform应用程序。
How memory / CPU intensive is creating MyService object? 创建MyService对象的内存/ CPU占用率如何?
If you suggest cashing the service, it will hold on to the EndpointAddress; 如果您建议兑现服务,它将保留在EndpointAddress上; which intern has a string with Username and Password.
该实习生的字符串包含用户名和密码。 Which is not a good idea .. any work arounds?
哪个不是一个好主意..任何解决方法?
This is a sample code, I have User Object which stores password in SecureString and every time I have to access the password; 这是一个示例代码,我有一个用户对象,该对象将密码存储在SecureString中,并且每次必须访问密码时都可以; I get string from SecureString in an instance private method, use it quickly and let it be garbage collected.
我在实例私有方法中从SecureString获取字符串,快速使用它并让它被垃圾回收。 I believe if I use a method something like above, it will be safe OR safe enough rather than holding on to reference of Service, What do you suggest !!
我相信,如果我使用上述方法,那将是安全或足够安全的,而不是坚持引用服务,您对此有何建议!
To your specific questions: 对您的具体问题:
using
statements to invoke the Dispose pattern and clean-up deterministically. using
语句中,以调用Dispose模式并确定性地进行清理。 See my Magic8Ball WCF Service on Codeplex for examples. Other observations: 其他观察:
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.