Answer the question
In order to leave comments, you need to log in
Why is Wcf returning an empty response body?
I’ll say right away that I’m not very good at c# and .Net.
there is a WCF Rest service (targetFramework="4.5.2")
one of the methods returns a Stream, well, or should return.
created a method for checking with one string input parameter - everything is fine, and with two string parameters - an empty response body.
this method returns data
[OperationContract]
[WebInvoke(Method = "GET",
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/pdf/{fname}")]
Stream getPDFile(string fname);
public Stream getPDFile(string fname)
{
return fs.getfile(fname);
}
and a method that has 2 parameters as input is an empty body. while the response status is 200 OK.
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate
= "/pdf/{fname}?token={token}")]
(string token, string fname);
public Stream Pdf(string token, string fname)
{
dataclass dc = dcList.SingleOrDefault(x => x.Token == token);
string fnameB = dc.PdfFile.ToString();
return fs.getfile(fnameB);
}
the service is accessed from PHP. tested with a small app
Answer the question
In order to leave comments, you need to log in
Let's be honest - you didn't just add one parameter to the address bar, but rewrote the entire logic. You are requesting Stream already for a file with a different name. Based on this, this behavior may even be correct within the described logic.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question