[Mono-aspnet-list] Post multiple parameters to RESTful service return error 500

alexzhu imthezc at gmail.com
Thu Aug 1 14:21:41 UTC 2013


Hi all
I built a RESTful service using mono(linux) WCF, weird thing is it always
return error 500 when post it multiple parameters, further, this self-hosted
cli crashes if post it a invalid format json request. But everything is fine
in .NET.
>From the exception, I guess /WebInvoke.WebMessageBodyStyle.Wrapped /ain't
works correctly, or maybe /RequestFormat/. Sadly, my skill level can't shoot
such a bug. 
Please help, thank you :)

*CLI exception when post multiple parameters*
Exception 'Element' is an invalid node type.  Line 1, position 53.   at
System.Xml.XmlReader.ReadEndElement () [0x00000] in <filename unknown>:0 
  at System.ServiceModel.Dispatcher.WebMessageFormatter.DeserializeObject
(System.Runtime.Serialization.XmlObjectSerializer serializer,
System.ServiceModel.Channels.Message message,
System.ServiceModel.Description.MessageDescription md, Boolean isWrapped,
WebContentFormat fmt) [0x00000] in <filename unknown>:0 
  at
System.ServiceModel.Dispatcher.WebMessageFormatter+WebDispatchMessageFormatter.DeserializeRequest
(System.ServiceModel.Channels.Message message, System.Object[] parameters)
[0x00000] in <filename unknown>:0 
  at
System.ServiceModel.Description.WebHttpBehavior+DispatchPairFormatter.DeserializeRequest
(System.ServiceModel.Channels.Message message, System.Object[] parameters)
[0x00000] in <filename unknown>:0 
  at
System.ServiceModel.Dispatcher.OperationInvokerHandler.BuildInvokeParams
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc,
System.Object[]& parameters) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.Dispatcher.OperationInvokerHandler.DoProcessRequest
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in
<filename unknown>:0 
  at System.ServiceModel.Dispatcher.OperationInvokerHandler.ProcessRequest
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in
<filename unknown>:0 
  at
System.ServiceModel.Dispatcher.BaseRequestProcessorHandler.ProcessRequestChain
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in
<filename unknown>:0 
  at
System.ServiceModel.Dispatcher.BaseRequestProcessorHandler.ProcessRequestChain
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in
<filename unknown>:0 
  at System.ServiceModel.Dispatcher.HandlersChain.ProcessRequestChain
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in
<filename unknown>:0 
  at System.ServiceModel.Dispatcher.BaseRequestProcessor.ProcessRequest
(System.ServiceModel.Dispatcher.MessageProcessingContext mrc) [0x00000] in
<filename unknown>:0 

*Fiddler Request*
User-Agent: Fiddler
Host: 192.168.1.99:18688
Content-Length: 35
Content-Type: application/json

{
"name":"alex",
"say":"hello"
}

*Interface*
 [OperationContract]
 [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json,
ResponseFormat =                      WebMessageFormat.Json, BodyStyle =
WebMessageBodyStyle.Wrapped)]
 string Echo(string name, string say);

*App.config*
<?xml version="1.0"?>
<configuration>
  <system.serviceModel>      
    <services>
      <service name="Contracts.MyService"
behaviorConfiguration="MEXBehavior">
        <endpoint address="" binding="webHttpBinding"
contract="Contracts.IMyService" behaviorConfiguration="MyRestBehavior" />
        
        <host>
          <baseAddresses>
            <add baseAddress="http://192.168.1.250:18688/MyService"/>
          </baseAddresses>
        </host>
      </service>
    </services>

    <behaviors>
      <endpointBehaviors>
        <behavior name="MyRestBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      
      <serviceBehaviors>
        <behavior name="MEXBehavior">
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceMetadata/>
        </behavior>
      </serviceBehaviors>
    </behaviors>    
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup></configuration>



--
View this message in context: http://mono.1490590.n4.nabble.com/Post-multiple-parameters-to-RESTful-service-return-error-500-tp4660353.html
Sent from the Mono - ASP.NET mailing list archive at Nabble.com.


More information about the Mono-aspnet-list mailing list