的NuGet包:如何将引用添加到Web服务? [英] NuGet packages: how to add references to webservices?
问题描述
我创建的NuGet包,在这里我想用两个Web服务。
I am creating a NuGet package, where I would like to use two web services.
我开始通过手动添加文件服务和修改配置文件。但是,当我正在经历的文件和修正的参考,我明白了,这种做法是不是生产性的,特别是,如果以后我需要更新的Web服务和引用。我用Google搜索的解决方案,但几乎没有发现任何有用的。
I started by adding manually the files for the services and modifying config file. But while I was going through the files and correcting the references, I understood that this approach is not productive, especially, if later I would need update the webservices and references. I googled for solutions, but barely found anything helpful.
因此,我的问题是,什么是引用添加到Web服务到的NuGet包一个正确的做法?
Thus, my question is, what is a correct approach to add references to the webservices into NuGet packages?
感谢你。
推荐答案
我选择的方法是使用 SvcUtil工具生成代理类的Web服务。然后我能或者使用这个代理类来访问Web服务,或走的更远,并在其上,并参考创建基于DLL这个DLL在目标项目。
The approach I selected was to use svcutil to generate proxy class for the Web service. Then I was able to either use this proxy class to access webservice, or to go farther and create dll based on it and reference this dll in the targeted project.
在情况下,它可能是有用的人,这里是PowerShell的code的创建基于web服务的URL代理类和DLL:
In case it can be useful to someone, here is the powershell code which creates proxy class and dll based on a webservice url:
$className = "SomeClass";
$svcUri = "http://.../SomeWebService.svc?wsdl";
$csFile = $className + '.cs';
$dllName = [System.IO.Path]::Combine($temp, $className + ".dll")
$svcUtilresult = & svcutil.exe /noConfig /out:$csFile $svcUri
csc.exe /t:library /out:$dllName $csFile
这篇关于的NuGet包:如何将引用添加到Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!