Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5990021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:11:03+00:00 2026-05-22T23:11:03+00:00

I’m getting a strange error, and I cannot figure out the problem. I’m sending

  • 0

I’m getting a strange error, and I cannot figure out the problem. I’m sending an array of objects to my wcf service in json format.

   var calendarItemsString = JSON.stringify(calendarItems);
            $.ajax({
                    cache: false,
                    async: true,
                    url: 'webService.svc/SaveCalendarItems',
                type: "POST",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                data: '{"jsonCalendarItems": ' + calendarItemsString + '}',
                success: function () {
                    alert('Save was performed.');
                },
                error: onPageError
               });

Below is the post that is being sent, it is valid JSON.

{
"jsonCalendarItems": [
    {
        "ImageId": 119,
        "Image": {
            "Id": 119,
            "Big": "Apple.jpg",
            "SmallThumbnail": "Apple.jpg",
            "Thumbnail": "Apple.jpg",
            "Full": "Apple.jpg",
            "Name": "apple"
        },
        "YearMonth": "2011-01-01T00:00:00.000Z"
    },
    {
        "ImageId": 366,
        "Image": {
            "Id": 366,
            "Big": "BabyWateringCan.jpg",
            "SmallThumbnail": "BabyWateringCan.jpg",
            "Thumbnail": "BabyWateringCan.jpg",
            "Full": "BabyWateringCan.jpg",
            "Name": "BabyWateringCan"
        },
        "YearMonth": "2011-02-01T00:00:00.000Z"
    },
    {
        "ImageId": 368,
        "Image": {
            "Id": 368,
            "Big": "BarBell.jpg",
            "SmallThumbnail": "BarBell.jpg",
            "Thumbnail": "BarBell.jpg",
            "Full": "BarBell.jpg",
            "Name": "BarBell"
        },
        "YearMonth": "2011-03-01T00:00:00.000Z"
    },
    {
        "ImageId": 66,
        "Image": {
            "Id": 66,
            "Big": "Bauble.jpg",
            "SmallThumbnail": "Bauble.jpg",
            "Thumbnail": "Bauble.jpg",
            "Full": "Bauble.jpg",
            "Name": "bauble"
        },
        "YearMonth": "2011-03-31T23:00:00.000Z"
    },
    {
        "ImageId": 116,
        "Image": {
            "Id": 116,
            "Big": "Coffee Cup.jpg",
            "SmallThumbnail": "Coffee Cup.jpg",
            "Thumbnail": "Coffee Cup.jpg",
            "Full": "Coffee Cup.jpg",
            "Name": "coffee cup"
        },
        "YearMonth": "2011-04-30T23:00:00.000Z"
    },
    {
        "ImageId": 115,
        "Image": {
            "Id": 115,
            "Big": "Clouds.jpg",
            "SmallThumbnail": "Clouds.jpg",
            "Thumbnail": "Clouds.jpg",
            "Full": "Clouds.jpg",
            "Name": "clouds"
        },
        "YearMonth": "2011-05-31T23:00:00.000Z"
    },
    {
        "ImageId": 73,
        "Image": {
            "Id": 73,
            "Big": "Champagne.jpg",
            "SmallThumbnail": "Champagne.jpg",
            "Thumbnail": "Champagne.jpg",
            "Full": "Champagne.jpg",
            "Name": "champagne"
        },
        "YearMonth": "2011-06-30T23:00:00.000Z"
    },
    {
        "ImageId": 69,
        "Image": {
            "Id": 69,
            "Big": "Bubbles.jpg",
            "SmallThumbnail": "Bubbles.jpg",
            "Thumbnail": "Bubbles.jpg",
            "Full": "Bubbles.jpg",
            "Name": "bubbles"
        },
        "YearMonth": "2011-07-31T23:00:00.000Z"
    },
    {
        "ImageId": 297,
        "Image": {
            "Id": 297,
            "Big": "DivingBoard.jpg",
            "SmallThumbnail": "DivingBoard.jpg",
            "Thumbnail": "DivingBoard.jpg",
            "Full": "DivingBoard.jpg",
            "Name": "DivingBoard"
        },
        "YearMonth": "2011-08-31T23:00:00.000Z"
    },
    {
        "ImageId": 298,
        "Image": {
            "Id": 298,
            "Big": "Duckweed.jpg",
            "SmallThumbnail": "Duckweed.jpg",
            "Thumbnail": "Duckweed.jpg",
            "Full": "Duckweed.jpg",
            "Name": "Duckweed"
        },
        "YearMonth": "2011-09-30T23:00:00.000Z"
    },
    {
        "ImageId": 78,
        "Image": {
            "Id": 78,
            "Big": "Easter Egg Card.jpg",
            "SmallThumbnail": "Easter Egg Card.jpg",
            "Thumbnail": "Easter Egg Card.jpg",
            "Full": "Easter Egg Card.jpg",
            "Name": "easter egg card"
        },
        "YearMonth": "2011-11-01T00:00:00.000Z"
    },
    {
        "ImageId": 106,
        "Image": {
            "Id": 106,
            "Big": "Fireworks.jpg",
            "SmallThumbnail": "Fireworks.jpg",
            "Thumbnail": "Fireworks.jpg",
            "Full": "Fireworks.jpg",
            "Name": "fireworks"
        },
        "YearMonth": "2011-12-01T00:00:00.000Z"
    }
] }

Here is the wcf method

    <OperationContract(), WebInvoke(Method:="POST", BodyStyle:=WebMessageBodyStyle.WrappedRequest, RequestFormat:=WebMessageFormat.Json), WebMethod(EnableSession:=True)>
Public Sub SaveCalendarItems(ByVal jsonCalendarItems As String)
    Dim _calenderItems As List(Of CalenderItem) = HttpContext.Current.Session("calenderItems")
    _calenderItems = Newtonsoft.Json.JsonConvert.DeserializeObject(Of List(Of CalenderItem))(jsonCalendarItems)
    HttpContext.Current.Session("calenderItems") = _calenderItems
End Sub

And finally the error message

{
"ExceptionDetail": {
    "HelpLink": null,
    "InnerException": {
        "HelpLink": null,
        "InnerException": {
            "HelpLink": null,
            "InnerException": null,
            "Message": "End element 'jsonCalendarItems' from namespace '' expected. Found element 'item' from namespace ''.",
            "StackTrace": "   at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)\r\n   at System.Xml.XmlExceptionHelper.ThrowEndElementExpected(XmlDictionaryReader reader, String localName, String ns)\r\n   at System.Xml.XmlBaseReader.ReadEndElement()\r\n   at System.Xml.XmlBaseReader.ReadElementContentAsString()\r\n   at System.Runtime.Serialization.XmlReaderDelegator.ReadElementContentAsString()\r\n   at System.Runtime.Serialization.Json.JsonStringDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)\r\n   at System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)\r\n   at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)\r\n   at System.Runtime.Serialization.XmlObjectSerializer.InternalReadObject(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)\r\n   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)",
            "Type": "System.Xml.XmlException"
        },
        "Message": "There was an error deserializing the object of type System.String. End element 'jsonCalendarItems' from namespace '' expected. Found element 'item' from namespace ''.",
        "StackTrace": "   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)\r\n   at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)\r\n   at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part)",
        "Type": "System.Runtime.Serialization.SerializationException"
    },
    "Message": "The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter :jsonCalendarItems. The InnerException message was 'There was an error deserializing the object of type System.String. End element 'jsonCalendarItems' from namespace '' expected. Found element 'item' from namespace ''.'.  Please see InnerException for more details.",
    "StackTrace": "   at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part)\r\n   at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeParameter(XmlDictionaryReader reader, PartInfo part)\r\n   at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, Object[] parameters, PartInfo returnInfo, Object& returnValue)\r\n   at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeBodyCore(XmlDictionaryReader reader, Object[] parameters, Boolean isRequest)\r\n   at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)\r\n   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)\r\n   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)\r\n   at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)\r\n   at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)\r\n   at System.ServiceModel.Dispatcher.CompositeDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)\r\n   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)\r\n   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: There was an error while trying to deserialize parameter :jsonCalendarItems. The InnerException message was 'There was an error deserializing the object of type System.String. End element 'jsonCalendarItems' from namespace '' expected. Found element 'item' from namespace ''.'.  Please see InnerException for more details.",
"StackTrace": "   at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part)\r\n   at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeParameter(XmlDictionaryReader reader, PartInfo part)\r\n   at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, Object[] parameters, PartInfo returnInfo, Object& returnValue)\r\n   at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeBodyCore(XmlDictionaryReader reader, Object[] parameters, Boolean isRequest)\r\n   at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)\r\n   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)\r\n   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)\r\n   at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)\r\n   at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)\r\n   at System.ServiceModel.Dispatcher.CompositeDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)\r\n   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)\r\n   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)"

}

Anyone get any ideas as to what this error means?

Update:

SeviceModel

 <system.serviceModel>
<behaviors>
  <endpointBehaviors>
    <behavior name="PhotoCreator.HelloWorldServiceAspNetAjaxBehavior">
      <enableWebScript />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="PhotoCreator.HelloWorldServiceAspNetAjaxBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
  multipleSiteBindingsEnabled="true" />
<services>
  <service behaviorConfiguration="PhotoCreator.HelloWorldServiceAspNetAjaxBehavior"
    name="PhotoCreator.WebService">
    <endpoint address="" behaviorConfiguration="PhotoCreator.HelloWorldServiceAspNetAjaxBehavior"
      binding="webHttpBinding" bindingConfiguration="LargeString"
      contract="PhotoCreator.WebService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="PhotoCreator.WebService" />
  </service>
</services>
<bindings>
  <webHttpBinding>
    <binding name="LargeString" maxReceivedMessageSize="1000000">
      <readerQuotas maxStringContentLength="16000" />
      <security mode="None" />
    </binding>
  </webHttpBinding>
  <wsHttpBinding>
    <binding name="mexBinding" maxReceivedMessageSize="5000000">
      <security mode="None" />
    </binding>
  </wsHttpBinding>
</bindings>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:11:04+00:00Added an answer on May 22, 2026 at 11:11 pm

    The problem is that your operation is expecting a String parameter (i.e. a JSON string), but the value of the jsonCalendarItems is an array. You can either create a class to represent the array items and change the parameter type to an array of that class, or you can convert the JSON array to a string (which can be done by calling JSON.stringify again on calendarItemsString)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.