[英]Copy service reference from one project to another project in same solution
We have one service reference in one project of a solution. 在一个解决方案的项目中,我们有一个服务参考。 I am trying to move this service reference to new project in same solution.
我正在尝试将此服务参考移至同一解决方案中的新项目。 But adding the service reference in new project using URL present in the service reference of old project is throwing 404 error.
但是,使用旧项目的服务引用中存在的URL在新项目中添加服务引用会引发404错误。 I am not sure where is this service hence do not have it my IIS.
我不确定此服务在哪里,因此没有我的IIS。
I tried to copy all the files and adding them to source control. 我试图复制所有文件并将其添加到源代码管理中。 like copy paste but then it has some auto generated code under reference.cs which generates all classes.
例如复制粘贴,但在reference.cs下有一些自动生成的代码,该代码会生成所有类。 They have old namespaces and might have to change it to new namespace manually.
他们具有旧的名称空间,可能必须手动将其更改为新的名称空间。 So, not sure if this can cause some other issue as I will be manually updating the auto generated code.
因此,不确定这是否会导致其他问题,因为我将手动更新自动生成的代码。
Is there a way to add this service reference in my new project? 有没有办法在我的新项目中添加此服务引用?
option 1 - find the url by debugging the first project 选项1-通过调试第一个项目找到URL
Assuming that the first project accesses the WCF service correctly, you can debug it to the point where it makes the service call and look at the the remote address in the watch 假设第一个项目正确访问了WCF服务,则可以将其调试到进行服务调用的位置,并查看监视中的远程地址。
var url = currentProxy.Endpoint.Address.Uri;
option 2 - add reference to the project thats already working 选项2-将引用添加到已经有效的项目中
add a wrapper class that makes the WCF call in your original project and then add project reference of your original project to the new project. 添加一个在原始项目中进行WCF调用的包装器类,然后将原始项目的项目引用添加到新项目中。 now you can you use the newly created wrapper to access the WCF service from the new project via the wrapper
现在您可以使用新创建的包装器通过包装器从新项目访问WCF服务
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.