Your SlideShare is downloading. ×
0
2310 b xd
2310 b xd
2310 b xd
2310 b xd
2310 b xd
2310 b xd
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

2310 b xd

320

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
320
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Appendix D: XML Web Service Responses
  • 2. Lesson: XML Web Service Responses <ul><li>XML Web Service Responses </li></ul><ul><li>Default Formatted XML Web Service Responses </li></ul><ul><li>Reshaping XML Web Service Responses </li></ul><ul><li>Demonstration: Reshaping XML Web Service Responses </li></ul>
  • 3. XML Web Service Responses <ul><li>Web services respond to direct HTTP-GET calls with simple XML documents </li></ul><ul><li>Web services respond to application-to-application calls with SOAP envelopes </li></ul><ul><ul><li>Envelope definition </li></ul></ul><ul><ul><li>Encoding rules </li></ul></ul><ul><ul><li>RPC representation </li></ul></ul><ul><ul><li>Protocol bindings </li></ul></ul>
  • 4. Default Formatted XML Web Service Responses &lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&gt; &lt;ArrayOfContact&gt; &lt;Contact&gt;   &lt;name&gt;Janet&lt;/name&gt;   &lt;address&gt;Seattle, WA&lt;/address&gt;   &lt;/Contact&gt; &lt;Contact&gt;   &lt;name&gt;Joe&lt;/name&gt;   &lt;address&gt;Attleboro, MA&lt;/address&gt;   &lt;/Contact&gt; &lt;/ArrayOfContact&gt; <ul><li>XML Web service code for an array </li></ul><ul><li>Resulting XML data </li></ul>Public Structure Contact Public name As String Public address As String End Structure &lt;WebMethod()&gt;Public Function _ GetContacts() As Contact() Dim x(1) As Contact x(0).name = &amp;quot;Janet&amp;quot; x(0).address = &amp;quot;Seattle, WA&amp;quot; x(1).name = &amp;quot;Joe&amp;quot; x(1).address = &amp;quot;Attleboro, MA&amp;quot; Return x End Function public struct Contact { public string name; public string address; } [WebMethod()]public Contact[] GetContacts() { Contact[] x; x = new Contact[2]; x[0].name = &amp;quot;Janet&amp;quot;; x[0].address = &amp;quot;Seattle, WA&amp;quot;; x[1].name = &amp;quot;Joe&amp;quot;; x[1].address = &amp;quot;Attleboro, MA&amp;quot;; return x; }
  • 5. Reshaping XML Web Service Responses <ul><li>XML Web service revised code </li></ul><ul><li>Resulting XML response </li></ul>&lt;XmlType(&amp;quot;MyContact&amp;quot;)&gt;Public Structure Contact &lt;XmlAttributeAttribute(&amp;quot;ContactName&amp;quot;)&gt; _ Public name As String &lt;XmlAttributeAttribute(&amp;quot;ContactAddress&amp;quot;)&gt; _ Public address As String End Structure &lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&gt; &lt;ArrayOfMyContact&gt;   &lt;MyContact ContactName=&amp;quot;Janet&amp;quot; ContactAddress=&amp;quot;Seattle, WA&amp;quot; /&gt;   &lt;MyContact ContactName =&amp;quot;Joe&amp;quot; ContactAddress=&amp;quot;Attleboro, MA&amp;quot; /&gt; &lt;/ArrayOfMyContact&gt; [XmlType(&amp;quot;MyContact&amp;quot;)]public struct Contact{ [XmlAttributeAttribute(&amp;quot;ContactName&amp;quot;)] public string name; [XmlAttributeAttribute(&amp;quot;ContactAddress&amp;quot;)] public String address; }
  • 6. Demonstration: Reshaping XML Web Service Responses <ul><li>Add a Web method that returns a list of contacts (structure) </li></ul><ul><li>Reshape the returned XML </li></ul>

×