I am moved to a soap Web service ver 3.5
. The post request are working fine for .net 4.5v. But while post data to service i am getting errors:
At browser
Error: OPTIONS http://localhost/webserv/WebService1.asmx/HelloWorld
XMLHttpRequest cannot load http://localhost/webserv/WebService1.asmx/HelloWorld. Invalid HTTP status code 500
When i saw the details it is showing this
System.InvalidOperationException: Missing parameter: obj.
at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
My implementation is as:
$http({
method: 'POST',
url: 'http://localhost/webserv/WebService1.asmx/HelloWorld',
datatype: 'json',
data:JSON.stringify({obj:details})
contentType: "application/json; charset=utf-8"
}).success(function(data,status, headers, config){
if(status == '200'){
alert(data.d);
}
}).error(function(data,status, headers, config){});
And at service
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string HelloWorld(Details obj)
{
return JsonConvert.SerializeObject((new Helper()).GetDetails(obj.Id);
}
inside web config:
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
How could i be able to call post request and get result in json format?