We help IT Professionals succeed at work.
Get Started

XSD Serialize/Deserialize issue

breezback
breezback asked
on
421 Views
Last Modified: 2012-08-13
     
I'm trying to deserialize a message from a schema which define request and response messages (CustomerLookup and CustomerLookupResponse both defined in the same schema as CustomerLookupServiceType).

I have generate cs files from xsd using the xsd tool straight forward without making changes. It seems that it's not good enough. While the serialization of the request passes, the deserialization of the response doesn't work. XMl are compliant to schema according to XMLSpy.

       
[Test]
        public void DeserializeAndValidateResponse()
        {
            string fileName = @"Data\CustomerLookup\CustomerLookupResponseSample1.xml";
            
            var response = XmlGenericSerializer.Deserialize<CustomerLookupServiceType>(fileName);
            Assert.IsNotNull(response);
            string officialName = response.CustomerBody[0].PersonalIdentification[0].Name.OfficialName;
            
            Assert.IsNotNullOrEmpty(officialName);
            Assert.IsTrue(officialName.Contains(LastName));

            bool result = XML_XSD_Validator.Validate(fileName, @"Data\CustomerLookup\CustomerLookupV3.0.0.xsd");
            Assert.IsTrue(result);
        }

Open in new window

SourcesWithUnitTest.zip
Comment
Watch Question
Full stack Software Engineer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE