none
WCF deserialization RRS feed

  • Question

  • Please help me out to get this fixed... Its been ages I'm trying to solve this. 

    I'm writing a wcf service which consumes a third party service as service reference.  And this wcf service will be used in a client to send soap xml messages.

    While using xml serializer the client code to deserialize an xml file works but some of the properties are null; which worked while using a asmx web service.  Please let me know if I'm missing something.

    The wcf service is below,

    [ServiceBehavior(Namespace = "http://somethirdparty.com/2011")] [SoapDocumentService(ParameterStyle=SoapParameterStyle.Bare)] public class Service : IService { [SoapDocumentMethod(ParameterStyle=SoapParameterStyle.Bare)] public OTA_HotelResNotifRS ReservationNotification(OTA_HotelResNotifRQ OTA_HotelResNotifRQ) { ........... }

    [ServiceContract(Namespace = "http://somethirdparty.com/2011")]
        [XmlSerializerFormat]
        public interface IService
        {           
            [OperationContract (Action="http://somethirdparty.com/2011/RS/HotelResNotif")]
            [return: MessageParameter(Name = "OTA_HotelResNotifRS")]
            OTA_HotelResNotifRS ReservationNotification(OTA_HotelResNotifRQ OTA_HotelResNotifRQ);        

        }

    The client code is below

    LotusResNotifService.OTA_HotelResNotifRQ OTA_HotelResNotifRQ = new LotusResNotifService.OTA_HotelResNotifRQ();
    
                XmlRootAttribute xRoot = new XmlRootAttribute();
                xRoot.ElementName = "OTA_HotelResNotifRQ";
                xRoot.IsNullable = true;
                xRoot.Namespace = "http://www.opentravel.org/OTA/2003/05";
    
                XmlSerializer deserializer = new XmlSerializer(OTA_HotelResNotifRQ.GetType(), xRoot);
                StreamReader reader = new StreamReader(@"D:\HotelResNotifRQ_SOAP_RQ.xml");
                object deserialized = deserializer.Deserialize(reader.BaseStream);
                OTA_HotelResNotifRQ = (LotusResNotifService.OTA_HotelResNotifRQ)deserialized;
                
    The OTA_HotelResNotifRQ has some of the properties returned as null...

    Friday, December 26, 2014 4:33 AM

Answers

  • Hi AsdRA,

    >>While using xml serializer the client code to deserialize an xml file works but some of the properties are null; which worked while using a asmx web service.

    Please try to use the DataContractSerializer to see if it works.

    #DataContractSerializer Sample:
    http://msdn.microsoft.com/en-us/library/ms752244(v=vs.110).aspx .

    It will be better if you can try to tell us which properties are null.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, December 29, 2014 6:52 AM
    Moderator