Clement ALBERT

Clement ALBERT

  • NA
  • 2
  • 3.6k

WCF Client unable to serialize (object is always null)

Apr 7 2019 5:01 AM
Hello Techies,

Below is the code snippet of the WCF proxy that I created with "SvcUtil" with XmlSerializer. I call the "upload" method using the proxy class and the method returns "uploadResponse" object. Within this object the "informations" object is always null. I verfied with fiddler and I noticed my call had valid Request and Response SOAP XML.
  1. [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel""4.0.0.0")]  
  2. [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]  
  3. [System.ServiceModel.MessageContractAttribute(WrapperName="uploadResponse", WrapperNamespace="http://services.ws.svgeda.bdf.fr/", IsWrapped=true)]  
  4. public partial class uploadResponse  
  5. {  
  6.   
  7.     [System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://services.ws.svgeda.bdf.fr/", Name = "informations")]     
  8.     [System.Xml.Serialization.XmlElement(Namespace = "http://services.ws.svgeda.bdf.fr/", ElementName= "informations")]     
  9.     public ResponseUpload informations;  
  10.   
  11.     public uploadResponse()  
  12.     {  
  13.     }  
  14.   
  15.     public uploadResponse(ResponseUpload informations)  
  16.     {  
  17.         this.informations = informations;  
  18.     }  
  19. }  
I tried tweaking the proxy by adding "Name" element to the "MessageBodyMemberAttribute" And I set the value for the namespace which was empty. And I also added XmlElement to see if it changes something.

Below is the XML snippet that's returned by the WCF calls to the method "upload" of the WS.

  1. <?xml version='1.0' encoding='UTF8'?>    
  2. <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>    
  3.     <soapenv:Body>    
  4.         <rpcOp:uploadResponse xmlns:xsi='http://www.w3.org/2001/XMLSchemainstance' xmlns:rpcOp='http://services.ws.svgeda.bdf.fr/'>    
  5.             <informations xmlns:ns2='http://services.ws.svgeda.bdf.fr/'>    
  6.                 <idSource>?</idSource>    
  7.                 <idGeda>{E08AEC690000CB1D96BEB5C2299E9E4E}</idGeda>    
  8.             </informations>    
  9.         </rpcOp:uploadResponse>    
  10.     </soapenv:Body>    
  11. </soapenv:Envelope>   
Any idea why the informations object is empty? All the other methods in the Web service(delete, update) return a response object which also contains a property named "informations" but with different types.

Thanks & Regards,
Clement


Answers (1)