我正在尝试将基于WCF的REST服务器转换为ASP.NET Web API2 . 现有的基于WCF的是:

public Message ProcessReportRequest(Stream inputStream) {
...
}

客户端发送一个byte [](下面的Java代码),客户端无法在使用时进行更改:

HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.setChunkedStreamingMode(0);
urlConnection.setRequestProperty("Content-Type", "text/plain");
urlConnection.setRequestMethod("POST");
OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream());
out.write(encryptedByteData);
out.flush();

我按如下方式设置了控制器:

public class LicenseController : ApiController
    {
        [Route("about")]
        public JsonResult<About> GetTest()
        {
            return Json(new About());
        }

        [Route("LicenseService.svc/v1/device")]
        public byte[] PostVer1Device(byte[] request)
        {
            Trap.trap();
            return request;
        }
}

如果我到了localhost \ about,JSON会回来,并且fiddler会显示请求并返回 .

当我调用Java代码发布到localhost / LicenseService.svc / v1 / device时,它会调用该方法 . 但无论我设置为参数(byte [],object,string,Stream),request的值都为null . 此外,Fiddler没有显示任何内容,尽管这可能是因为它在显示正在发生的事情之前等待返回 .

无论我返回什么,从响应中读回的流都显示0个字节 .

如何将数据发布给我?我如何发回数据?

谢谢 - 戴夫