asp.net - The remote server returned an error: (504) Gateway Timeout -
i have created web service using http://visualstudiogallery.msdn.microsoft.com/fbc7e5c1-a0d2-41bd-9d7b-e54c845394cd. hosted on iis , created test app deployed on iis , works. now, hosted wcf service , trying use/consume localhost gives error on following line:
var response = request.getresponse() httpwebresponse;
and error is
the remote server returned error: (504) gateway timeout.
in fiddler shows:
fiddler] readresponse() failed: server did not return response request.
request header in fiddler is: post /notifications/recordingcompleted http/1.1 entity: content-length: 792 content-type: application/json transport connection: keep-alive expect: 100-continue
code is:
string servicebaseurl = serviceurlhere string conversationid = 2342423 string resourceurl = ""; string method = "post"; string jsontext = "json here";
string success = usehttpwebapproach(servicebaseurl, resourceurl, method, jsontext); private string usehttpwebapproach(string serviceurl, string resourceurl, string method, string requestbody) { string responsemessage = null; var request = webrequest.create(string.concat(serviceurl, resourceurl)) httpwebrequest; if (request != null) { request.contenttype = "application/json"; request.method = method; } //var objcontent = httpcontentextensions.createdatacontract(requestbody); if (method == "post" && requestbody != null) { byte[] requestbodybytes = tobytearrayusingjsoncontractser(requestbody); request.contentlength = requestbodybytes.length; using (stream poststream = request.getrequeststream()) poststream.write(requestbodybytes, 0, requestbodybytes.length); } if (request != null) { var response = request.getresponse() httpwebresponse; if (response.statuscode == httpstatuscode.ok) { stream responsestream = response.getresponsestream(); if (responsestream != null) { var reader = new streamreader(responsestream); responsemessage = reader.readtoend(); } } else { responsemessage = response.statusdescription; } } return responsemessage; } private static byte[] tobytearrayusingjsoncontractser(string requestbody) { byte[] bytes = null; var serializer1 = new datacontractjsonserializer(typeof(string)); var ms1 = new memorystream(); serializer1.writeobject(ms1, requestbody); ms1.position = 0; var reader = new streamreader(ms1); bytes = ms1.toarray(); return bytes; }
service code is:
[servicecontract] [aspnetcompatibilityrequirements(requirementsmode = aspnetcompatibilityrequirementsmode.allowed)] [servicebehavior(instancecontextmode = instancecontextmode.percall)] public class recordingcompleted { [webinvoke(uritemplate = "", method = "post")] public string processcall(string jsondata) { return string result } }
Comments
Post a Comment