ASP.NET Web Service returning Bad Request in Windows Azure - web-services

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.

Related

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.

Wsdl never updates

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.

Pocket PC 2003 application with webservice

I am working on a Pocket PC 2003 application that is referencing a Webservice.
I was figuring out ways to debug the Webmethods but not successful.
-I checked the URL property of the Service in WebReferences and made sure it is correct.
-I started debugging the PocketPC application, then built the Webservice as start without debugging, after that went to Debuh> Attach process and attached devenv-"Pocket PC app"
-I also tried attaching to the aspwp.exe process but couldn't seem to hit the break points in Web Methods.
-The webservice is deployed to IIS virtual directory.
-I copy pasted the entire webservice folder in the virtual directory. Then I am opening the solution file in Visual Studio. Start without debugging, when the webmethods show in browser, click on it, then click Invoke
Can someone guide me the proper way to debug a Webservice of this type? Thanks in advance.
If you're using Visual Studio 2005 or higher, instead of IIS, use the toy Web service that comes with Visual Studio. In the properties of your ASP.NET project with the Web services, under "Web", check the "Use Visual Stuidio Development server". In order to make the toy server start, you have so start the ASP.NET project from Visual Studio.
Then you attach to the process called Webdev.Webserver.exe using Managed code debugging.

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

ASMX + external dll

I am working on Silverlight client to Microsoft Team Foundation Server. I am using an ASMX web service to make the actual calls using the TFS api.
Everything works fine when I run it with the visual studio development server, but I cannot figure out how to deploy the app to IIS.
I can get the ASMX web service to work unless it is a call that uses the TFS api. I have tried putting all of the TFS api DLLs in like every directory that I can think of, and even installing the visual studio sdk. Nothing works!
UPDATE 11/15/09 7:50PM EST:
Turns out that the TFS api was trying to create a cache at c:\Documents and Settings\Default User\Local Settings\Application Data\Microsoft\Team Foundation\2.0\Cache\, and the IIS_WPG user didn't have access to do so. Easy fix.
The only supported way of installing the TFS API is to install Team Explorer. You could try to GAC just the assemblies you need, but you're on your own [and technically violating the EULA]...
Other things to check:
IIS is running in 32 bit mode
Impersonation is working correctly
Proxy settings
What error do you get? Have you tried attaching a debugger to IIS?