我不确定这对我意味着什么。我在过去的一两天里一直在挑选它。我还有其他与“GET”一起使用的功能,但这是流程链中的第一个“POST”命中。有谁知道出了什么问题?
错误输出:
{"ExceptionDetail":{
"HelpLink":null,
"InnerException":{
"HelpLink":null,
"InnerException":null,
"Message":"The data at the root level is invalid. Line 1, position 1.",
"StackTrace":" at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)\u000d\u000a at System.Xml.XmlUTF8TextReader.Read()\u000d\u000a at System.Xml.XmlBaseReader.IsStartElement()\u000d\u000a at System.Xml.XmlBaseReader.IsStartElement(XmlDictionaryString localName, XmlDictionaryString namespaceUri)\u000d\u000a at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeRequest(XmlDictionaryReader reader, Object[] parameters)\u000d\u000a at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeRequest(Message message, Object[] parameters)",
"Type":"System.Xml.XmlException"},
"Message":"The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'SaveXml'. The data at the root level is invalid. Line 1, position 1.",
"StackTrace":" at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeRequest(Message message, Object[] parameters)\u000d\u000a at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)\u000d\u000a at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)\u000d\u000a at System.ServiceModel.Dispatcher.CompositeDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)\u000d\u000a at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)","Type":"System.ServiceModel.Dispatcher.NetDispatcherFaultException"},
"ExceptionType":"System.ServiceModel.Dispatcher.NetDispatcherFaultException",
"Message":"The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'SaveXml'. The data at the root level is invalid. Line 1, position 1.","StackTrace":" at System.ServiceModel.Dispatcher.PrimitiveOperationFormatter.DeserializeRequest(Message message, Object[] parameters)\u000d\u000a at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)\u000d\u000a at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)\u000d\u000a at System.ServiceModel.Dispatcher.CompositeDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)\u000d\u000a at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)\u000d\u000a at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)"}
称呼:
//when stringified, it looks correct. No real obvious holes.
//the variables in data are strings, and are recognized correctly in the request payload of the file.
var settings = {
url: "webservices/FormServices.svc/SaveXml",
type: "POST",
contentType: "text/xml",
data: JSON.stringify({ auth: auth, server: server, datasource: datasource, FileId:FileId, XML:xml }),
success: success,
error: error
};
console.log("Settings", settings);
return $.ajax(settings);
服务:
//this is of a class i made with a [ServiceContract]
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json)]
string SaveXml(string auth, string server, string datasource, string FileId, string XML);
服务:
public string SaveXml(string auth, string server, string datasource, string FileId, string XML)
{
string response = "-1";
return response;
}
捆绑:
<system.serviceModel>
<services>
<service name="test.webservices.FormServices" behaviorConfiguration="debug">
<endpoint address="" behaviorConfiguration="test.webservices.FormServicesAspNetAjaxBehavior"
binding="webHttpBinding" contract="test.webservices.IFormServices"/>
</service>
</services>
<bindings />
<client />
<behaviors>
<endpointBehaviors>
<behavior name="test.webservices.FromRequestAspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="test.webservices.FormServicesAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="debug">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />