目前我的wcf服务端代码如下:
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest, UriTemplate = "CallbackInvoice?AuthData={AuthData}")]
[OperationContract]
string CallbackInvoice (string AuthData,string req);
但是只能接收 application/json
的数据格式 不支持其他的
参考 WCF WebInvoke which can accept content-type: text/plain?
namespace StackOverflow36216464
{
public class RawContentTypeMapper : WebContentTypeMapper
{
public override WebContentFormat GetMessageFormatForContentType(string contentType)
{
switch (contentType.ToLowerInvariant())
{
case "text/plain":
case "application/json":
return WebContentFormat.Json;
case "application/xml":
return WebContentFormat.Xml;
default:
return WebContentFormat.Default;
}
}
}
}