I am using AngularJS and WCF Services. My problem is related to post method and the response I am getting back from the WCF Service.
The declaration of the method in Interface in WCF Servvice looks like this:
[OperationContract]
[WebInvoke(
Method = "POST",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "UpdateBusiness")]
void UpdateBusiness(Business business);
The Method looks like this:
public void UpdateBusiness(Business business)
{
BusinessManager manager = new BusinessManager();
manager.UpdateBusiness(business);
}
The call from AngularJS looks like this:
$http({
url: app.service + '/UpdateBusiness',
method: "POST",
headers: {
'Content-Type': 'application/json; charset=utf-8'
},
data: $scope.business
})
.success(function (data, status, headers, config) {
console.log("Done status: " + status);
console.log("Done status: " + data);
})
.error(function (data, status, headers, config) {
console.log("Error status: " + status);
console.log("Error status: " + data);
});
Now the problems is: When I post data to WCF Service, it actually receives the data correctly, further down, it updates correct records in the DB. Now, in the browser, after backend process is completed and the response is returned from the server I get this error in the console:
no element found
"Done status: 200"
"Done status: "
So basically, at first look it looks like that there is no error returned from the server, but when I check the details I see this:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Service</title>
<style>
//I have removed the styling code to keep the post short
</style>
</head>
<body>
<div id="content">
<p class="heading1">Service</p>
<p xmlns="">Method not allowed. Please see the <a rel="help-page" href="http://localhost/Server/Production.svc/help">service help page</a> for constructing valid requests to the service.</p>
</div>
</body>
</html>
What should I do to remove these errors. Thanks
EDIT: The headers and response look like this:
Request URL: http://localhost/Service/Production.svc/UpdateBusiness
Request Method: POST
Status Code: HTTP/1.1 200 OK
Request Headers 09:23:21.000:
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Referer: http://localhost/AdminPanel/
Pragma: no-cache
Host: localhost
Content-Type: application/json; charset=utf-8
Content-Length: 379
Connection: keep-alive
Cache-Control: no-cache
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Accept: application/json, text/plain, */*
Request Body:
{"BusinessID":3,"BusinessName":"My Business ","BusinessTags":{"ErrorCode":0,"ErrorDetail":"","ErrorMessage":"","BusinessTags":[]},"BusinessTagsText":"","CategoryID":9,"Email":"[email protected]","Embed":true,"Enabled":false,"Facebook":"www.facebook.com/mybusiness","Phone":"111 622 422","PhoneType":"Delivery","Twitter":"www.twitter.com/mybusiness","URL":"www.mybusiness.com"}
Response Headers Δ67ms:
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Server: Microsoft-IIS/8.5
Date: Mon, 16 Jun 2014 04:23:21 GMT
Content-Length: 0
Cache-Control: private
No Response Body
EDIT 2: Fiddler response: I have change the return type to String to see if something is returned as well and here is the raw view:
HTTP/1.1 200 OK
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 16 Jun 2014 04:39:38 GMT
f
"Done is done."
0
curlor a similar tool?