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.
Loading
gzathegeeniahzPosted Dec 21, 2005, 9:15 AM
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var url="http://localhost/test/Service1.asmx/Hi"; //here is the service call
xmlhttp.open("POST", url, false);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-Length","12");
xmlhttp.send("a=3");//here are the parameters
var returnValue=xmlhttp.responseText; //xml response will be here
document.Form1.t.value=returnValue;
I've been using GET,and I cannot use parameters with GET requests.