“Add Service Reference” is failing in VS

送分小仙女□ 提交于 2020-01-03 03:42:11

问题


In MS's Visual Web Developer, I have a completely default ASP.NET web service project and another project. When use the right click menu on the second project to run "Add Service Reference", I can find the first project listed as an option but I get an error when I attempt to select it, I get an error

Metadata contains a reference that cannot be resolved: 'http://0.0.0.0:3495/Service1.asmx?wsdl'.
There was an error downloading 'http://0.0.0.0:3495/Service1.asmx?wsdl'.
Unable to connect to the remote server
The requested address is not valid in its context 0.0.0.0:3495
Metadata contains a reference that cannot be resolved: 'http://localhost:3495/Service1.asmx'.
Metadata contains a reference that cannot be resolved: 'http://localhost:3495/Service1.asmx'.
If the service is defined in the current solution, try building the solution and adding the service reference again.

I have gotten the same problem when using WCF services also.

What am I doing wrong?


I found this reference that has this service and things work with that. (WhyT_ doesn't the default service just work?)


回答1:


The reference is not getting added since the proxy is not getting generated.

In my case I got the "Metadata contains a reference that cannot be resolved" since some of the internal types used by the exposed object on the contract were not serializable.

After applying the Serializable attribute, the proxy generated correctly and a reference was added.

So you might want to check if the types exposed over the contract are serializable.




回答2:


The service needs to be accessible for all (ananymous) users. You can make a location accessible using:

<location path="YOURPATH" >
  <system.web>
    <authorization>
      <allow users="*" />
    </authorization>
  </system.web>
</location>



回答3:


The service needs to be available.

If you start just the service, add service reference should work.



来源:https://stackoverflow.com/questions/762322/add-service-reference-is-failing-in-vs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!