[RESOLVED] VB Web Service "beginner" help
All,
OK I made a new website in VS 2005, as a VB.NET WebService. By default, the HelloWorld function thingy is available. I click the play button which opens up a web page. I go to click the Invoke button (this is all pre-built by VS for me), but the next thing I get is a big fat error... See below.
Server Error in '/MyWebService' Application.
--------------------------------------------------------------------------------
Request format is unrecognized for URL unexpectedly ending in '/HelloWorld'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/HelloWorld'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/HelloWorld'.]
System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +743
System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +281
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +401
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +183
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +191
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
Re: VB Web Service "beginner" help
OK I seem to have gotten past this problem by an web.config edit (see in red):
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
Re: VB Web Service "beginner" help
Although when I publish the webservice to my wwwroot, this does not seem to help...
Re: VB Web Service "beginner" help
What is the URL in the browser window when you get that error?
To confirm, this is SOAP and not WCF, yes?
Re: VB Web Service "beginner" help
http://localhost/MyFlexService/Service.asmx
Umm.. SOAP? How could I know the answer to this? Is it a property of the VS Project?
Re: VB Web Service "beginner" help
It's soap because it ends in ASMX.
Are you sure you're giving me the right URL? The error states that the URL ends in /HelloWorld, but yours is .asmx. Or is it as below:
Code:
http://localhost/MyFlexService/Service.asmx/HelloWorld
Re: VB Web Service "beginner" help
OK so I go to VS 2005, begin a new Web Service Webiste project. Seems to behave the same for VB and C# projects. I "run" the project and a web page comes up with the HelloWorld link, press that and I got the Invoke button.
This is the 1st URL VD sends me to: http://localhost:1760/WebSite2/Service.asmx
This is the URL after clicking the HelloWorld link: http://localhost:1760/WebSite2/Servi...?op=HelloWorld
Pressing the Invoke button gives me the post#1 error, and the URL in the erroneous browser is:
http://localhost:1760/WebSite2/Service.asmx/HelloWorld
Re: VB Web Service "beginner" help
Right, so, it appears to be a default setting in ASP.NET 2.0 onwards which is why you need to do that web.config change.
To fix it 'everywhere' on your machine, you can edit the machine.config file, according to this KB article.
Code:
<protocols>
<add name="HttpSoap"/>
<add name="HttpPost"/>
<add name="HttpGet"/>
<add name="HttpPostLocalhost"/>
<!-- Documentation enables the documentation/test pages -->
<add name="Documentation"/>
</protocols>
Re: VB Web Service "beginner" help
OK So I found my .NET 2.0 machine.config file but it doesn't look like my web config file. There is this section:
Code:
<section name="protocols" type="System.Web.Configuration.ProtocolsSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" allowDefinition="MachineToWebRoot"/>
How do I edit that to represent the XML-ish output from the KB article:
Code:
<protocols>
<add name="HttpSoap"/>
<add name="HttpPost"/>
<add name="HttpGet"/>
<add name="HttpPostLocalhost"/>
<!-- Documentation enables the documentation/test pages -->
<add name="Documentation"/>
</protocols>
Re: VB Web Service "beginner" help
That section bit you see is what allows a section named <protocols> to exist. If you don't find a protocols section in the machine.config, you can make one, simply by pasting that node in.
Re: VB Web Service "beginner" help
see Post #2 - If I add the following lines to my web.config after the project is already built, I can indeed Invoke the web service successfully:
Code:
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
However, I am unable to place these sections anywhere in the machine.config file. I have tried inserting them many different places. Each time I make a new website seb-service 2005 project, and it asks to create a web.config for me. No matter where I place the sections, I get erroneous results. I have yet to get a web.config that actually contains the sections in them.
Any idea exactly where to place the sections in the machine.config?
1 Attachment(s)
Re: VB Web Service "beginner" help
Well, turns out the KB article was only partially helpful. I edited my machine config this way, just at the end of the system.web item, my inserted text in red:
Code:
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
Now when I run my new webservice website from the IDE, I can Invoke the web service properly, with no errors.
Also I attach my .NET 2.0 machine.config (located in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config)
I am not sure what affect this will have on deployed websites yet. I will test that next.
Thanks for helping out!
Re: VB Web Service "beginner" help
This will affect all websites on your computer and enable the GET/POST for those applications (because machine.config is like a master config file, which web.config files 'inherit' from).
Re: VB Web Service "beginner" help
OK I think this is resolved