Adding a service reference to a website - c#

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 have 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.

Related

How to use a class of one project in another project under the same solution?

I have two projects of Web API and Windows Forms App under one solution.
The names are:
Solution - CliendAddress
Web API - ClientAddress
WFA - ClientAddressWFA
In the ClientAddress project there is a class called ServiceResponse. How can I use this ServiceResponse class in my project ClientAddressWFA?
From my ClientAddressWFA, I've already added the reference to ClientAddress 👇
However, when I am trying to add using ClientAddress.Models; (<---- This is where the ServiceResponse class is) in my ClientAddress.WFA project, I'm getting an error👇
Recording: https://screenrec.com/share/XTp0dwbI42
If you need just this one source file then you can just add it to the other project "as link". Quick and dirty, but who cares. However, if you need more classes, then make a shared library project that would then be referenced by both projects. That's what shared libraries are for.
So, in project ClientAddressWFA try to add this one .cs file but instead of clicking "Add" click on small triangle next to "Add", and select "Add As Link".
Sometimes just restarting the visual studio and compiling again will work (Given that class you are referencing from another project is public and you have added project reference)

Convert Website to Web application With Visual Studio 2015

I have a Website Solution and I want Convert it to Web Application.
When I Transfer Base files (like DAL,BLL(.cs files my mean)) and Build My Solution it's working.
But When I Add other files that use the Base Files I have Many Errors Like (CS0246,CS0103,CS0118,CS1061).
I see this answer like:
https://msdn.microsoft.com/en-us/library/w7xf6dxs.aspx
and
Why am I getting error CS0246: The type or namespace name could not be found?
I want to Know if I build My Solution and Visual Studio Create .dll files why I have error that say not found X.dll? and how can it be fix?
You will have to go through and fix each error in turn as you migrate.
https://msdn.microsoft.com/en-us/library/aa983476(v=vs.100).aspx
I usually create an empty Web Application project and then copy the output into the same folder as my Web Site. Then I open the web application project in tye same solution as my website. Now you have two Projects for the same location.
Now enable the "show hidden files" option and "include" all the files in your project. At this point you will get loads of errors... Make sure that you first right-click on the root of your Web Application and select "Upgrade to Web Application" as this will do much of the grunt work for you.
In Web Applications you get Partial classes and when generated they are clashing with each other. In a Web Site you can have duplicate namespaces and class names, in a web application you can't. You need to go through all of your *.aspx and it's associated files and rename all of the class snakes to be unique.
This will start removing the errors although it may take some time to get through them all.

visual studio issue pulling in web service

I am using VS2010, and I want to consume a webservice that was given to me
https://www.###################/pinManagement.cfc?wsdl
I have done this many times before but for some reason this one i cant get right
right click, add solution
add service reference
past in url, give a namespace and voila
This pulls in fine, but for some reason a bunch of objects in the wsdl are being left off, namely all the request/response objects. the methods are there, but nothing else.
what am I doing wrong?
Thanks
ok, i solved it. thanks to Ian for the steps to see my error.
i got the solution from this site
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/51babae5-26e5-4405-b03c-4301710854c0/
but ill repost the steps below incase the link dies
In Visual studio:
1. Click on "Show All Files" in the solution explorer
Open the file named "Reference.svcmap" in your service reference
Set the option UseSerializerForFaults to false in "Reference.svcmap" and save it (please don't update the service reference, apparently doing so will reset the option to true)
Open the Reference.cs and you should see the operations generated
Right click on your web service select:
Configure Service Reference=>Un-check reuse types in referenced assemblies
See if that helps
EDIT ::
Try creating a proxy using the XmlSerializer. You can do that by running svcutil from the command line and then pulling the generated .cs and .config files into your project:
svcutil /serializer:XmlSerializer https://www.example.com/Collections/1x0x0/pinManagement.cfc?wsdl
Any errors that you get from svcutil will probably help you narrow down the problem.

Why, when adding a service reference in VS2010, is the client class not generated?

I'm going insane, I beleive.
That is, I've never had an issue like this before, and nobody (that Google has indexed) seems to be having the same issue.
Whenever I add a reference to a particular ASMX service to a VS2010 project, all of the code is generated, there is an interface ServiceSoap that represents all of the features of the service, but there is no concrete implementation of that interface anywhere in the solution!
What am I doing wrong? I just right click project, add service reference, paste url to .asmx, type 'Blah' in the namespace box, click OK.
Everything seems to happen OK. I'm just bat-shit insane, I guess...
Update:
If I go to Advanced... in the add service reference dialog, and choose to add it as a .NET 2.0 service, everything works, but I don't particularly want to do it that way.
The actual namespace I'm using is Remedy and the service .asmx file is Service.asmx.
Try this...
right click on the service reference. then go to configure service reference. then uncheck reuse types in referenced assemblies checkbox.
upd
this solved mine, hope it will help somebody else too
Try these steps:
Look in the Output window to see if there are any errors when you use the "Add Service Reference".
Look in the Reference.cs to see if there are any errors (generated as comments).
Finally, try using svcutil.exe to generate the proxies, since it will be easier to see error messages.
Have you tried clicking "Show all files"?
With this feature on, the Service Reference can be expanded to its various "source" files.
While clicking "show all files" icon. There is another folder which they hold the same name. while deleting the folder. and clean the solution. Add new services with the same name.
Now its working fine.
Right click on the reference, then - "View in Object Browser" Just double click on one of the methods/properties inside the object explorer.

Circular file references are not allowed. Publish ASP.NET (2.0) Website

When I re/build my ASP.NET website I do not receive any errors.
However when I PUBLISH the site, it gives me a 'Circular file references are not allowed.' error.
I read a little on the web about this, and it provided a batch='false' option, which I tried and does nothing.
The page, has a master page, which may call on the same control twice; however, this control does not refer back to anything
TY - Theo
Theo, I also received this error quite a few times which is very annoying, even though I searched for ages for circular file references I couldn't find any. In the end I decided that although there are no definite circular file references, the compiler did not like it when I referenced a control in a parent folder e.g. I have a control in the folder /UserControls/Panels/ManagerPanels/ which references a control in the folder /UserControls/Panels/. This works ok when coding but trying to publish or debug brought about the Circular file reference problem. Sorry to say the only solution I found was to move the referencing control back a folder into the same folder as the control it was referencing, this fixed the problem (although it is extremely frustrating as I like a nice folder structure for my controls, of which there are many). Hope this helps
The reason that batch=false won't fix anything is publishing a website precompiles it so the batch attribute is irrelevant.
You can get more details on the error by using the aspnet_compiler command. I think this only works if you've hosted your website locally in IIS.
aspnet_compiler -v /
The above command would precompile your website locally if it's running on port 80 and show you where the problems are.
If you have Project A and Project B in the same solution, and you add a reference from Project A to Project B and also a reference from Project B to Project A then you’ll get this error. References work like a parent\child relationship so a project cannot be both the parent and the child of another project.
You’ll need to work out where the circular reference is and maybe move some code around, or even create a new project in order to resolve it.
if you add multiple project, one project depend another one project means check your reference. if u gave circular form means that error will come
There actually was a circular refernce in my case. As correctly highlighted by Doug Domeny, and Starjumper. My folder structures were:
UI > Templates > Header.ascx
Login.ascx
About.aspx
Inside Header.ascx we were using Login.ascx, the Header.ascx was then being used inside About.aspx and since for each folder there is a DLL, it became circular. I feel the error message could have been more elaborate.
To resolve, I created a copy of Login.ascx inside UI > Template folder and renamed it to Login1.ascx, and started using Login1.ascx inside Header.ascx

Categories

Resources