'传入的邮件具有意外的邮件格式' Raw'。该操作的预期消息格式是' Xml' Json'

时间:2016-01-10 08:52:40

标签: c# .net angularjs wcf api

不确定我错过了什么,但由于某种原因,WCf一直向我抛出这个错误。

服务器在处理请求时遇到错误。异常消息是'传入消息具有意外的消息格式' Raw'。该操作的预期消息格式是“Xml' Json'”。这可能是因为尚未在绑定上配置WebContentTypeMapper。有关更多详细信息,请参阅WebContentTypeMapper的文档。'。请参阅服务器日志以获取更多详异常堆栈跟踪是:

在System.ServiceModel.Dispatcher.Dispatcher.DispatchOperationRuntime上的System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(消息消息,Object []参数)处的System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(消息消息,Object []参数)处。 DeserializeInputs(MessageRpc& rpc)位于System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)的System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) )在System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

我的服务

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[UserAccessRoleValidatorAspect(Access = Otive.Subscriptions.UserAccessType.Install)]
public class PaymentProcessPublic : BaseService,IPaymentProcessPublic
{
    private PaymentProcessorInvoiceService PaymentProcessorInvoiceService = 
        new  PaymentProcessorInvoiceService(ConnectionManager.GetConnectionInfo(Otive.Consts.TenantId));

    public GetQuickInvoiceInfoResponse GetInvoiceQuickInfo (GetQuickInvoiceInfoRequest Request)
    {
        GetQuickInvoiceInfoResponse Response = new GetQuickInvoiceInfoResponse();

        Response.PaymentProcessorInvoiceInfo = this.Converter.Convert( PaymentProcessorInvoiceService.GetPaymentProcessorInvoiceInfo(Guid.Parse(Request.PaymentKey)));

        return Response;
    }
}

我的界面

[WebInvoke(RequestFormat = WebMessageFormat.Json,
    ResponseFormat = WebMessageFormat.Json,
    Method = "*", BodyStyle = WebMessageBodyStyle.Bare)]
[OperationContract]
GetQuickInvoiceInfoResponse GetInvoiceQuickInfo(GetQuickInvoiceInfoRequest Request);

请求标头 接受:application / json,text / plain, /

请求有效负载 {PaymentKey:" A4F5E417-4938-4BA6-9E4C-FEC4C6499B28"}

服务器请求对象

public class GetQuickInvoiceInfoRequest
{
    public string PaymentKey { get; set; }
}

1 个答案:

答案 0 :(得分:0)

我的问题是由于无法访问所请求的资源造成的。这条消息非常误导。