[RESOLVED] [Workaround found] Easy: Pass string arg to Webservice
All,
I made a webservice and can Invoke the HelloWorld that gets made by the IDE. I also made a Webmethod that returns a record set thing and that seems to work fine, I can breakpoint in the code and everything.\
However the following Webmethod does not work with the string argument:
However, if I remove the string argument, I can call the Webmethod just fine.
The Webmethod compiled with the string argument shows a text box under the Invoke button when I run from the IDE. However pressing Invoke just causes a nasty error:
HTML Code:
The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.
--------------------------------------------------------------------------------
Please try the following:
Open the localhost:1639 home page, and then look for links to the information you want.
Click the Refresh button, or try again later.
Click Search to look for information on the Internet.
You can also see a list of related sites.
HTTP 500 - Internal server error
Internet Explorer
So when I remove the string argument I can call the Webmethod just fine, and get the .PNG junk dumped back into my browser.
Any ideas?
Last edited by Dave Sell; Jun 6th, 2009 at 01:48 PM.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
When you have made the change to the WebService, have you updated the Web Reference in the application you are calling the Web Service from? If you haven't, then the Proxy Class that Visual Studio generates for you will not include the additional parameter that you have included in the method.
In solution explorer, right click on the Web Reference and click Update, that should sort you out.
Failing that, try using something like SoapUI, to independently test the Web Service.
I was unable to right-click anything in my solution explorer that offered to update my web reference. That is strange since I've seen that before recently, but not here.
So I can set breakpoints on the 2 WebServices that do basically nothing.
I can run the Hello world from the IDE/webbrowser, and get to a breakpoint.
But if I run another function with an int or string or something as an argument, and pass it into the web browser and press Invoke, I get some kind of crash, and do not even reach the breakpoint.
Next post I will show my Solution Explorer.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
Ah, I thought you might have had another application, like a web application that you added a reference to the Web Service in, in which case you would have something like this:
However, I am slightly confused by what you are showing in your solution explorer?!?! How did you go about creating the Web Service in the first place? I would have thought the contents should look something more like this:
It looks like you have simply added a .asmx file to an existing website. I don't know the ramifications of doing that, but it could be that what you are seeing is a symptom of that. I would have thought you should have selected the Web Service Application Template from the New Project wizard here:
I don't have the packaging handy here. How can I tell? I thought I had the best version we could buy, but we did get an "upgrade" version. The retailer assured us it can co-exist with my installed version of VS 2003.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
If you hit Help | About, you should be able to find out exactly what version you have.
Different Version's of Visual Studio can definitely live on the same machine, I have Visual Basic 6, Visual Studio 2003, Visual Studio 2005 and also Visual Studio 2008 on the same machine.
Try doing the same thing with the new Application Template and see how you get on.
On a side note, it's good to try and keep Visual Studio up to date, as you get the the benefit of all the new additions, as well as security fixes. If you use Microsoft Update, rather than Windows Update, any new updates for Visual Studio will be included.
Good luck with the Web Service, post back if you are still having problems.
Also, as I mentioned earlier, have a look at SoapUI. This will allow you to independently verify the operation of the Web Service. SoapUI is a java application, and I have found it to be a great tool for testing my web services, and best of all, it's free
Ugh - same problem. Made new WebService Application this time, added a simple WebMethod:
Code:
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
namespace WebService1
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public string HelloWorldInt(int argc)
{
return "Hello World";
}
}
}
But still I cannot Invoke the method with an int for an argument...!!!
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
I am really sorry, but I really don't know what to tell you...
I have literally copied and pasted the code that you have there into a new project, and it works. Out of curiosity, can you try SoapUI, or some other way of testing the Service outside of Visual Studio and Internet Explorer?
OK so I noticed theres no Web Reference so in the project explorer, I Add Web Reference... after I publish this to my localhost.
I browse to it and get this wierdo error:
Code:
There was an error downloading 'http://localhost/WebService1/Service1.asmx'.
The request failed with the error message:
--
<html>
<head>
<title>Configuration Error</title>
<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana"
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
In this instance, you don't need a Web Reference. You only need a Web Reference if you are trying to consume the Web Service from another application, such as a Windows Form Application, or a Web Application. Here you are testing the Web Service as a stand alone entity using the built in mechanism within ASP.Net.
Doing what you are doing here would essentially create a Web Reference to itself, which is not needed.
OK I installed the other kb patch and still no luck. I rebooted and made a new Web Service Application. I can run the HelloWorld Web Mothod, but if I make a new one with any kind of parameter, I cannot Invoke it from the IDE/Browser.
Can you post your web.config?
Any other ideas?
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
Re: [Still Unresolved] Easy: Pass string arg to Webservice
Hey,
The web.config is just the one that is rolled out with the default template, I didn't make any changes to it:
Code:
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true" />
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows" />
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
</configuration>
The only other suggestion would be as I said, test it with SoapUI, or it's equivalent. This would tell you whether this is an issue with the Web Service itself, or the testing mechanism that you are using.
Re: [Still Unresolved] Easy: Pass string arg to Webservice
No further. Have not tried SoapUI yet. The web services work perectly fine when my FLEX clients or .NET clients access them, so it's not really a matter of whether or not the web services work.
This is mostly a pain-point for me as I like to test the things I create in the IDE in debug mode before I send them out for consumption.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
Re: [Still Unresolved] Easy: Pass string arg to Webservice
Hey,
Yeah, I know what you mean, it is definitely good to be able to debug things as you are creating them. Have you got access to a colleagues machine that you could run a test on? I hesitate to suggest that there is something wrong with your setup, but it is looking more and more like that.
Re: [Still Unresolved] Easy: Pass string arg to Webservice
That is a great idea, but I have the only license and installation of VS 2005. I could possibly set VS up on a test system and see if the problem persists. I am really hoping that I just have something configured improperly.
I am pretty stumped.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
Re: [Still Unresolved] Easy: Pass string arg to Webservice
Hey,
If you get a chance, you could try running a Virtual Machine with a fresh install of Visual Studio and see how you get on, and obviously, wipe the VM once you have completed your testing, so as to not break any licensing rules
I have got a standard installation of Visual Studio, and it worked out of the box, so I suspect it is something on your machine that is causing the problem. However, in these situations, by the time you have figured out exactly what is going on, you could have completely re-installed your machine.
Re: [Still Unresolved] Easy: Pass string arg to Webservice
Ha ha, we are lucky enough to have three ESX Servers in the building, but if you don't have the funds, download and install VMWare Server, it is completely free (after a registration) and let's you create and run VM's on your own laptop, you can find it here:
I have it on my own machine for the times when the ESX Server isn't justified. You can use it solely on your own machine, or set it up on a machine that everyone can access. It has a web based interface which makes it very easy to configure. The one draw back is that you are only able to take on snapshot.
Re: [Still Unresolved] Easy: Pass string arg to Webservice
Are you admin on your machine?
Can you set your project (in properties > web tab) to use IIS virtual directories so that when you run it, it invoked an IIS address instead of the built-in web server?
Re: [Still Unresolved] Easy: Pass string arg to Webservice
Originally Posted by mendhak
Are you admin on your machine?
Can you set your project (in properties > web tab) to use IIS virtual directories so that when you run it, it invoked an IIS address instead of the built-in web server?
That sounded like a great idea, but when I tried it, I unfortunately get the same erroneous behavior!
Any other ideas? I'd really like to get past this problem...
Thanks!
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
Re: [Still Unresolved] Easy: Pass string arg to Webservice
To elaborate a bit, I did set up the project to run from an IIS VD as suggested.
I verified the VD was created an is using ASP.NET 2.0 in IIS.
If I click the play button (start debugging) from the IDE, the web service launches, and I can Invoke memebers with no arguments. But any member with any simple argument yields the same error page.
However if I use IE to browse to the web service, then I can Invoke the members with simple arguments and they work perfectly.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
Re: [Still Unresolved] Easy: Pass string arg to Webservice
OK after some brute force random things I am trying I discovered that if I "start debugging" from the IDE it loads up an IE window pointing to the localhost/webservice, as normal.
However if I close that or minimize that and instead launch my own independant IE browser from the desktop shortcut, and browse to localhost/webservice, then I can call the members with simple arguments, and if I set a breakpoint, my IDE really does handle the call and breakpoints properly.
This odd discovery is enough to get around my problem, as now I can run quick tests of my service members, essentially from the IDE.
To be a stickler, my original problem is not solved, but this workaround is enough for me to resolve the thread.
Thanks to all!
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)