Wsdl never updates - web-services

No matter what I change in an asmx service in Visual Studio, the WSDL file stays always the same. Deleting methods, changing method signatures don't have any effect when I browse to service definition.

I have had a simular problem.
When removing an enum and replacing it by a string, the enum wouldn't go away from the wsdl. No matter what I tried (clean, rebuild, clear browser cache, other browser), it kept returning the enum as a complex type within the WSDL.
The solution in my case was remove the local folders of the project via windows explorer, then perform a get latest from TFS. After this the problem was solved.
Of course this solution only aplies when using a sourcecontrol system.

After changing your service, you must build it and ensure that the new version is running. One shortcut would be to build it (and make sure there are no errors), then right-click the .ASMX file and choose "View in Browser".
Also, although I'm sure you're aware of it, you should not be using ASMX web services for new development. Microsoft now considers ASMX to be a legacy technology. Use WCF instead.

I have encountered this problem and have a solution.
Cause: When you create a new "Web Service" project in Visual Studio, it automatically adds a "Service1.asmx" file to your project. You rename this file and change the class declaration inside of it, but Studio still thinks it's "Service1" wnd will only ever display the web service definition for "Service1".
Solution:
Delete all "bin" and "obj" folders in your project.
Copy the methods from your existing asmx file to notepad.
Remove the service from your project.
Add a new service to your project, with the name you want.
Paste the code from Notepad into the new service.
Rebuild All
Your asmx should now accurately reflect your web service and update normally on future builds.

I had today the very same issue. It was caused by a GACed version of the assembly that contained the type definitions exposed by the web service. I had to remove the assembly from the Global Assembly Cache first, like:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\gacutil.exe" /u YourAssemblyNameWithouthDllExtebsion /f
Be sure to restart the web server hosting the web service to reload the new version of the assembly, for example, in case of IIS Express, you can kill the former process instance by PowerShell:
(Get-Process -Name iisexpress).Kill()
After that, the updated WSDL version was displayed as expected.

Related

How to "Run" a .svc WCF Web Service

I am working on a project that was last worked on by someone who hasn't been on the team in some time. Having gotten a hold of him to ask him questions about the project and next steps in general, I was told I need to run a Java web service. After not being able to find any .jws files in our network, I asked if a particular .svc (WCF Web Service) file was the right service and was told to "run [filename]" which is the .svc file. This file is in a directory with some relevant Java class files that appear to have been part of an eclipse project (which I am unable to open).
Now I've looked around and all tutorials I can find about running a .svc file involve a visual studio project and creating the project from scratch, not just running a single .svc file as a web service. I'm new to Windows in general and haven't seen a .svc file. Does it make since to say to simply "run" a .svc WCF Web Service? And does it make since that a .svc file would be created from a Java project? If so, how would I simply run that service?
I hope this question made sense. Thanks for any help!

Can not update web reference in Visual Studio 2013

My project in Visual studio 2013 consumes Acumatica web service APIs on another server. I had no problem with adding web reference and calling Acumatica web service API in my code, until recently I added new API into the web service in Acumatica, and then tried to update web service reference in my project. I right clicked on "web service" in Visual studio and then click on "update web reference" to update, however, I was still getting the old APIs, even though I used exactly same URL. I put the URL in browser and I could see the new APIs but when I tried to update, I just couldn't get them into Visual Studio.
When I put that URL into browser to view the WSDL XML, I noticed I only got new APIs after I logged into Acumatica and I was getting old APIs before I logged in. It seems Acumatica only sends updated WSDL xml after users log in, which causes problem to Visual Studio, since there is no way to log in first in Visual studio.
Actually I had successfully updated my web reference before, but almost every time I tried to update reference, I got this problem, then after keeping trying many times, the reference eventually got updated...but this time, the problem seems to just hang on there and doesn't go...
By the way, I tried to go to command line to use wsdl.exe to generate reference class but still got old APIs.
I just don't understand why Acumatica requires logging in to give out new APIs...
If anybody could give me any clue to solve this problem, that would be really appreciated.
(Converting my solution from a comment to an answer)
I believe the Visual Studio GUI frontend for wsdl.exe does allow you to perform a login action (by showing a WebBrowser control) prior to downloading the .wsdl file, but in the event that doesn't work you can always manually download the .wsdl via your desktop browser and then invoke wsdl.exe from the command-line, providing the downloaded file as a command-line argument.

ASP.NET Web Service returning Bad Request in Windows Azure

After a Windows 7 fresh restart, I open the Visual Studio 2010 as administrator, create a new project of Windows Azure Project with ASP.NET Web Role, then at the WebRole1 project I add a WebService1.asmx and press F5 (run).
The Windows Azure services starts OK and the browser open the http:/127.0.0.1:8080/WebService1.asmx perfectly. But when I click at Invoke button to test the webservice method I always receive a Bad Request - Invalid Hostname, with a http:/127.0.0.1:8081/WebService1.asmx/HelloWorld.
The most likely cause is ASMX's WSDL file doesn't stand by load balanced environment such as Windows Azure. The test feature relies on WSDL. You will see similar issues if you add a web/service reference. It is recommended to upgrade to WCF. In WCF, you can use useRequestHeadersForMetadataAddress (http://msdn.microsoft.com/en-us/library/ee816894.aspx) to fix the issue. If you need to use ASMX, please try to manually provide a correct WSDL file.

How to publish a Web Service from Visual Studio into IIS?

I have written a WCF web service in C#. I had originally self-hosted it and then decided to host it on IIS running locally on my PC. While the service is working, there are several aspects of the deployment process that I don't understand:
Firstly, the URL of this service when hosted in IIS does not correspond to what I specified in my web.config. I had specified "http://localhost:8000/MyServices/OrderService" there and this was used when I self-hosted. Now that I've deployed to IIS, the URL has become "http://localhost/MyServices/OrderService". Why is the URL not picked up from my config file?
Secondly, to host the Web Service, I created a new web site within IIS (in addition to the existing 'Default Web Site'). I set the physical path to c:\inetpub\wwwroot (no idea if this is correct) and left the other parameters as default. I then copied my /bin folder, my .svc file and my web.config to this folder. Is this the equivalent of a 'Virtual Directory'?
Finally, the service didn't work until (within IIS) I selected 'Convert to application'. Why is it necessary to select 'Convert to application'?
Can anyone explain what the correct procedure is to publish a simple web service from Visual Studio into IIS, or point me at some good documentation so I can understand the process?
****EDIT TO ORIGINAL*****
Having spent more time looking into this, I have found the following:
When I create a web site in IIS, I give it a physical directory of c:\inetpub\wwwroot....etc
If I then "publish" from within Visual studio, all it's doing is copying all the required filed (like the /bin directory, web.config and .svc file) into the physical directory of the website i.e. - c:\inetpub\wwwroot...
You can perform the copy manually to the same affect.
Lastly, with regard to the URL of my service not corresponding to the baseAddress section of my web.config file, this has been answered on stackoverflow previously.
The answer is that the baseAddress is completely ignored when hosting on IIS.
If using Visual Studio 2010 you can right-click on the project for the service, and select properties. Then select the Web tab. Under the Servers section you can configure the URL. There is also a button to create the virtual directory.

Web service on iis not updated

I deployed a web service to iis 7, it was working all the way right.
Then I wanted to update the code of a web method in the web service.
I recompiled the service and updated the dll in the iis directory with the new one.
My problem is when I invoke the service, it invokes the older code.
I tried changing the number of parameters passed to a web method inside the service, and when invoking it still sees the older parameters which I erased.
Web services after Framework 2.0, are compiled as DLL files by default as far as I know. Normally, this happens when you PUBLISH the website and webservice, or when you use Web Applications.. But in WebServices, Visual Studio compiles the output as DLL. Therefore, you should compile your dll and update on the IIS. Even though you see the CS code files on IIS folder, they are not being used. Only the asmx file (not asmx.cs) are used to map the code in the dll.
I am guessing that the old code is cached. Try restarting IIS. That should cleanup any remnants of the old code.
It seems that you need to update your service reference.
Go to the project who's using the service, left-click the service reference in your solution explorer and finally choose "Update Service Reference".
Maybe I'm wrong and you did it, but as you don't mention that in your question, this is my suggestion.
rebuild the solution, And deploy the service on IIS. It will work definitily