How do I solve this error, “error while trying to deserialize parameter”

后端 未结 8 1805
轻奢々
轻奢々 2020-12-09 02:50

I have a web service that is working fine in one environment but not in another.

The web service gets document meta data from SharePoint, it running on a server wher

相关标签:
8条回答
  • 2020-12-09 03:36

    I have a solution for this but not sure on the reason why this would be different from one environment to the other - although one big difference between the two environments is WSS svc pack 1 was installed on the environment where the error was occurring.

    To fix this issue I got a good clue from this link - http://silverlight.net/forums/t/22787.aspx ie to "please check the Xml Schema of your service" and "the sequence in the schema is sorted alphabetically"

    Looking at the wsdl generated I noticed that for the serialized class that was causing the error, the properties of this class were not visible in the wsdl.

    The Definition of the class had private setters for most of the properties, but not for CustomFields property ie..

    [Serializable]
    public class FileMetaDataDto
    {
        .
        . a constructor...   etc and several other properties edited for brevity
        . 
    
        public int Id { get; private set; }
        public string Version { get; private set; }
        public List<MetaDataValueDto> CustomFields { get; set; }
    
    }
    

    On removing private from the setter and redeploying the service then looking at the wsdl again, these properties were now visible, and the original error was fixed.

    So the wsdl before update was

    - <s:complexType name="ArrayOfFileMetaDataDto">
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="FileMetaDataDto" nillable="true" type="tns:FileMetaDataDto" /> 
      </s:sequence>
      </s:complexType>
    - <s:complexType name="FileMetaDataDto">
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="CustomFields" type="tns:ArrayOfMetaDataValueDto" /> 
      </s:sequence>
      </s:complexType>
    

    The wsdl after update was

    - <s:complexType name="ArrayOfFileMetaDataDto">
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="FileMetaDataDto" nillable="true" type="tns:FileMetaDataDto" /> 
      </s:sequence>
      </s:complexType>
    - <s:complexType name="FileMetaDataDto">
    - <s:sequence>
      <s:element minOccurs="1" maxOccurs="1" name="Id" type="s:int" /> 
      <s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="Title" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="ContentType" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="Icon" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="ModifiedBy" type="s:string" /> 
      <s:element minOccurs="1" maxOccurs="1" name="ModifiedDateTime" type="s:dateTime" /> 
      <s:element minOccurs="1" maxOccurs="1" name="FileSizeBytes" type="s:int" /> 
      <s:element minOccurs="0" maxOccurs="1" name="Url" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="RelativeFolderPath" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="DisplayVersion" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="Version" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="CustomFields" type="tns:ArrayOfMetaDataValueDto" /> 
      <s:element minOccurs="0" maxOccurs="1" name="CheckoutBy" type="s:string" /> 
      </s:sequence>
      </s:complexType>
    
    0 讨论(0)
  • 2020-12-09 03:46

    Are you sure your web service is deployed correctly to the enviornment that is NOT working. Looks like the type is out of date.

    0 讨论(0)
提交回复
热议问题