70 likes | 154 Vues
Explore strategies for seamless consumption and processing of XML data transmitted via web services in collaboration with business partners. Learn how to efficiently handle XML documents without traditional parsing methods by leveraging XSD and class generation techniques.
E N D
Web Services: Beyond the Obvious Communicating with Business Partners and other Providers
Scenario: • We need to consume and work with an Xml document provided by a Business Partner via its proprietary Web Service
The Task… • We will communicate to a Web Service that receives as input a Customer Number • The Web Service will return an Xml document containing Customer header and related sales detail information • The detail information will contain 0 to any number of sales records • We need to be able to process this data on a record by record basis
Let’s look at the Xml we will receive… <Test> <ID>4567</ID> <FirstName>Neil</FirstName> <LastName>Young</LastName> <Sales> <Sale> <ID>4567</ID> <SaleDate>2007-06-01T00:00:00</SaleDate> <Amount>567.12</Amount> </Sale> <Sale> <ID>4567</ID> <SaleDate>2007-06-23T00:00:00</SaleDate> <Amount>78.99</Amount> </Sale> <Sale> <ID>4567</ID> <SaleDate>2007-06-25T00:00:00</SaleDate> <Amount>11.89</Amount> </Sale> <Sale> <ID>4567</ID> <SaleDate>2007-06-30T00:00:00</SaleDate> <Amount>104.01</Amount> </Sale> <Sale> <ID>4567</ID> <SaleDate>2007-07-01T00:00:00</SaleDate> <Amount>789.99</Amount> </Sale> </Sales> </Test>
Consuming the Xml without “parsing” the Xml Document • Receive an XSD (Xml Schema Definition) from the Business Partner • Generate a class that represents the Xml data we are going to receive • De-Serialize the Xml data into classes that we can work with
How can we create an XSD from our Avr.Net Classes? Receive an XSD (Xml Schema Definition) from the Business Partner Generate a class that represents the Xml data we are going to receive De-Serialize the Xml data into classes that we can work with 6
Web Services: Beyond the Obvious Communicating with Business Partners and other Providers 7