获取内容 WCF 响应的类型
我有一个从服务器下载内容的 WCF 客户端。
服务合同是;
[OperationContract]
[WebGet(
UriTemplate = "/my/service/url/{method}/{filename}?tradeId={tradeId}&docType={docType}&language={language}&version={version}",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare)]
Stream GetDocument(string method, string filename, string tradeId, string docType, string version, string language);
返回类型是 Stream。我所做的只是将该流写入文件即可工作。
现在,我想对此进行修改。我想知道下载文档的 MIME 类型。我知道它在服务器上设置正确。我只需要取回它。
我对 WCF 缺乏经验,不知道该怎么做。有人可以告诉我吗?
非常感谢
I have a WCF client that download content from the server.
the service contract is;
[OperationContract]
[WebGet(
UriTemplate = "/my/service/url/{method}/{filename}?tradeId={tradeId}&docType={docType}&language={language}&version={version}",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare)]
Stream GetDocument(string method, string filename, string tradeId, string docType, string version, string language);
The return type is a Stream. What I do is simply just write that stream to a file and it works.
Now, I want to make modification on this. I want to know the MIME type of the downloaded document. I know it is set properly on the server. I simply need to retrieve it.
I have little experience with WCF and don't know how to do that. Can someone let me know?
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须有权访问
OperationContext
或WebOperationContext
。要在客户端上实现此目的,请使用OperationContextScope
:You must get access to
OperationContext
orWebOperationContext
. To achieve that on a client useOperationContextScope
: