Web services with javascript using .net

Dec 21 2005 7:45 AM
Hi.
I have an active web services called test.

So I have this piece of code in HTML writen in Javascript:

var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var url="http://localhost/test/Service1.asmx/Hello";
xmlhttp.open("GET", url, false);
var returnValue=xmlhttp.responseText;
document.Form1.t.value=returnValue;


And i have an HTML control with a name 't' where I preview the result.


This code works cause the method Hello which I'm invoking is without parameters.
But if I invoke one other mathod called 'Hi' which has one paremeter,like this:

var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var url="http://localhost/test/Service1.asmx/Hi?a=3";
xmlhttp.open("GET", url, false);
var returnValue=xmlhttp.responseText;
document.Form1.t.value=returnValue;

I get this response:"Request format is invalid": Any ideas?Anyone?

P.S:I am using visual studio.net,and i am inserting the next code in web.config file:

<webServices>
<
protocols>
<
add name="HttpGet"/>
<
add name="HttpPost"/>
</
protocols>
</
webServices>

It wont work without it.


Answers (1)