简体   繁体   中英

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. I am not sure where is this service hence do not have it my 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. 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

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

var url = currentProxy.Endpoint.Address.Uri;

option 2 - add reference to the project thats already working

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. now you can you use the newly created wrapper to access the WCF service from the new project via the wrapper

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM