T
T
timusKul2016-06-22 08:29:40
.NET
timusKul, 2016-06-22 08:29:40

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

2 answer(s)
D
Dmitry Kovalsky, 2016-06-22
@dmitryKovalskiy

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.

T
timusKul, 2016-06-22
@timusKul

if you do it like this: UriTemplate = "/pdf/{fname}/{token}", then everything works correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question