开发者

Adding a service reference to a website

I am trying to add a service reference to my website. When I add the service reference to a WPF application I get a reference.cs file that I can edit and add attributes to. When I try to do the same thing in a asp.net website there this file isn't present. I ha开发者_StackOverflow社区ve also tried looking on the file system and the reference.cs isn't present. Can anyone provide some guidance?

EDIT:: Im using VS2010 and I need to edit the reference.cs to add [Webget] and [WebPost] attributes


If you want to manually edit a service stub, consider using svcutil.exe.


In Visual Studio, right-click on the reference under the "Service Reference" section of the Solution Explorer and click "View in Object Browser". Then, in the Object Browser, under the namespace for the reference, right-click on any of the properties and select "Go to Definition". This will load up "Reference.cs" file.

Hope this helps!

Edit: Also worth noting is that the classes generated for you are partial classes, so it may be beneficial to consider extending them in a separate file so that you can still "Update" the reference and not have the generated code overwrite any changes you make. This would all depend on what you're planing on modifying though.


Depending on the version of VS it will create a folder under the project root. In my case under VS2010 I added a ref to http://www.webservicex.net/stockquote.asmx?WSDL, set the namespace to ServiceReference1 and it created a folder in the project root called \Service References\ServiceReference1 under which it stored all the ref files including Reference.cs

If you are not seeing this folder then there may be something wrong at your service that VS is unable to query the WSDL and generate the files. Try the stock service above to test.

And editing the generated files is usually a bad idea as they can get regenerated when you refresh the reference. Unless you want to rip the generated code out and never refresh it again.

UPDATE:


  • Seems like that webservicex service is slow, try this
  • Also, seems like there is a diff between "Web Reference" and "Service Reference". See here. But ultimately it creates a sub folder in your project root called either "Service References" or "Web References" with the sub folder of whatever you named your reference.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜