接口定义:

[OperationContract]
[WebInvoke(UriTemplate = "AddTask?taskId={taskId}&processGuid={processGuid}", Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
Stream AddTask(Stream request, string taskId, string processGuid);

 

处理完任务,输出流返回的时候加上System.ServiceModel.Web.WebOperationContext.Current.OutgoingResponse.ContentType = "application/json";就行了

/// <summary>
/// 辅助方法,用于输出流
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
private Stream GetJsonStream(string str)
{
MemoryStream ms = new MemoryStream();
StreamWriter sw = new StreamWriter(ms);
sw.AutoFlush = true;
sw.Write(str);
ms.Position = 0;
System.ServiceModel.Web.WebOperationContext.Current.OutgoingResponse.ContentType = "application/json";
return ms;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
  • 2021-12-05
  • 2021-06-08
  • 2022-12-23
相关资源
相似解决方案