何时添加服务参考?
我正在构建一个 WCF 服务,该服务将部署到运行 IIS 的服务器。我可以添加当前解决方案中的服务引用并正常使用。
如果我将该服务部署到该特定计算机,我是否需要将该服务重新添加到使用该服务的应用程序中?
I'm building a WCF service that will get deployed to a server running IIS. I can add the service reference from the current solution and use it fine.
If I deploy the service to that particular machine, will I need to re-add the service to the application that consumes it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不需要,您只需更改服务 URL 以匹配其他计算机即可。
添加服务引用时会生成代理,该代理将针对托管这些服务的所有服务器起作用 - 它只需要正确的 URL。
您只需要在暴露的服务发生变化时更新服务引用,例如添加新方法或更改参数。
No, you just need to change the service URL to match the other machine.
A proxy is generated when you add the service reference and that proxy will work against all servers that host those services - it just needs the right URL.
You only need to update the service refernece when the services exposed changes, e.g. adding a new method or changing a parameter.
不会。它的工作方式是,当您添加对项目的引用时,它会查询给定的服务 URL,并通过 SOAP 通过 XML 创建特定服务的所有类和方法的列表。
这就是一个 .NET 类。
如果您向服务添加了其他方法,则只需删除并重新添加引用。
例如,报告服务 2005 Web 服务:
您添加对项目的引用,然后导入命名空间。
您实例化该类的一个对象,并将 URL 传递给它。
然后通过此类的实例调用 WebService 方法。
见下文:
No. The way it works is, when you add the reference to your project, it queries the service URL given and creates, over XML via SOAP, a list of all classes and methods of your particular service.
This is then a .NET class.
You only need to remove and readd the reference if you added additional methods to your service.
E.g. the reporting service 2005 web service:
You add the reference to your project, then import the namespace.
You instanciate an object of this class, and pass it the URL.
Then you call the WebService method via the instance of this class.
See below:
长话短说,更改客户端应用程序配置文件中的服务地址以指向新服务器。
这将是您的部署过程的一部分。
Long story short, change the service address in the configuration file of the client application to point to the new server.
This will be part of your deployment procedure.