CollaborateKnowledge Byte    In this section, you will learn about:         •   JAXB API         •   SAAJ API ©NIIT       ...
CollaborateJAXB API    •    Is a Java technology that provides an API and tool that binds an XML schema         to a repre...
CollaborateJAXB API (Contd.)    •    Working of JAXB          •   Components used while processing XML document are:      ...
CollaborateJAXB API (Contd.)         •   The following figure shows the working of JAXB API: ©NIIT                        ...
CollaborateJAXB API (Contd.)    •    JAXB API          •   Is defined in javax.xml.bind package, which contains classes an...
CollaborateSAAJ API    •    Enables you to write SOAP messaging applications.    •    Is a low-level API that contains met...
CollaborateSAAJ API (Contd.)    •    SAAJ API          •   SAAJ API is defined in the package, javax.xml.soap, which provi...
CollaborateSAAJ API (Contd.)          •   The table list various interfaces present in the javax.xml.soap package         ...
CollaborateSAAJ API (Contd.)           •   The table list various interfaces present in the javax.xml.soap package        ...
CollaborateSAAJ API (Contd.)         •   The following table describes the classes present in the javax.xml.soap          ...
CollaborateSAAJ API (Contd.)         •   The following table describes the classes present in the javax.xml.soap          ...
CollaborateSAAJ API (Contd.)         •   The following figure shows the components of SOAPMessage object: ©NIIT           ...
CollaborateFrom the Expert’s Desk    This section will introduce the following:         •   Best Practices on processing X...
CollaborateBest PracticesProcessing XML Documents    •    You can process XML documents using either SAX or DOM parsers.  ...
CollaborateTipsCaching Techniques in XSLT to EnhancePerformance    •    You can implement caching by loading transformatio...
CollaborateTips (Contd.)Development Techniques to Make XSLTStylesheets Manageable    •    Techniques to make XSLT styleshe...
CollaborateTips (Contd.)Techniques to Use the Import and IncludeStatements for Combining Stylesheets    •    Two methods t...
CollaborateTips (Contd.)Techniques to Use the Import and IncludeStatements for Combining Stylesheets (Contd.)         •   ...
CollaborateTips (Contd.)Techniques to Use the Import and IncludeStatements for Combining Stylesheets (Contd.)         •   ...
CollaborateFAQs    •    How can you retrieve status and error information when a SOAP message does         not reach its d...
CollaborateChallenge         3.   Consider the following two statements:                   Statement A: A registry is a di...
CollaborateChallenge (Contd.)         2.   What does the fault string element of a SOAP message represent?         3.   Th...
CollaborateSolution         •   b. Both statement A and B are false         •   The fault string element represents an err...
Upcoming SlideShare
Loading in...5
×

Deawsj 7 ppt-1_c

273

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

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

No notes for slide

Deawsj 7 ppt-1_c

  1. 1. CollaborateKnowledge Byte In this section, you will learn about: • JAXB API • SAAJ API ©NIIT Collaborate Lesson 1C / Slide 1 of 23
  2. 2. CollaborateJAXB API • Is a Java technology that provides an API and tool that binds an XML schema to a representation in Java code. • Provides the method for unmarshalling and marshalling. • Used for developing an application that can read, manipulate, or recreate XML documents. • Works as an abstraction layer between Java and an XML document because you do not need to know about the XML syntax or XML processing. ©NIIT Collaborate Lesson 1C / Slide 2 of 23
  3. 3. CollaborateJAXB API (Contd.) • Working of JAXB • Components used while processing XML document are: • XML Schema • Binding Compiler • Binding Declarations • Binding Implementation Framework • XML Input Document • XML Output Document ©NIIT Collaborate Lesson 1C / Slide 3 of 23
  4. 4. CollaborateJAXB API (Contd.) • The following figure shows the working of JAXB API: ©NIIT Collaborate Lesson 1C / Slide 4 of 23
  5. 5. CollaborateJAXB API (Contd.) • JAXB API • Is defined in javax.xml.bind package, which contains classes and interfaces for unmarshalling, validating, and marshalling an XML document. • Various classes contained in javax.xml.bind package are: • JAXBContext • Unmarshaller • Validator • Marshaller ©NIIT Collaborate Lesson 1C / Slide 5 of 23
  6. 6. CollaborateSAAJ API • Enables you to write SOAP messaging applications. • Is a low-level API that contains methods to exchange messages between the clients and the Web applications. • Enables you to write SOAP messaging applications. ©NIIT Collaborate Lesson 1C / Slide 6 of 23
  7. 7. CollaborateSAAJ API (Contd.) • SAAJ API • SAAJ API is defined in the package, javax.xml.soap, which provides the primary abstraction for SOAP messages with attachments. • The table list various interfaces present in the javax.xml.soap package: Interface Description Detail Represents a container to store the DetailEntry objects. DetailEntry Stores information about SOAPFault objects. ©NIIT Collaborate Lesson 1C / Slide 7 of 23
  8. 8. CollaborateSAAJ API (Contd.) • The table list various interfaces present in the javax.xml.soap package (Contd.): Interface Description Name Represents an XML name. Node Represents a node element of an XML document. SOAPBody Represents an object that stores the SOAP body element of a SOAP message. SOAPBodyElement Stores information about a SOAPBody object. ©NIIT Collaborate Lesson 1C / Slide 8 of 23
  9. 9. CollaborateSAAJ API (Contd.) • The table list various interfaces present in the javax.xml.soap package (Contd.): Interface Description SOAPElement Represents an element of a SOAP message. SOAPHeader Stores information about the header of a SOAP element. Text Represents a node that stores text. ©NIIT Collaborate Lesson 1C / Slide 9 of 23
  10. 10. CollaborateSAAJ API (Contd.) • The following table describes the classes present in the javax.xml.soap package: Class Description AttachmentPart Creates an object to attach a single attachment to a SOAPMessage object. MimeHeader Creates an object to store the name of the MIME header and its value. MessageFactory Contains methods to initialize the SOAPMessage objects. SOAPConnection Creates a connection object that represents a point-to-point connection. The objects of this class enable clients to send messages directly to the remote destination. ©NIIT Collaborate Lesson 1C / Slide 10 of 23
  11. 11. CollaborateSAAJ API (Contd.) • The following table describes the classes present in the javax.xml.soap package (Contd.): Class Description SOAPMessage Creates an object to store a SOAP message. SOAPException Creates an object that represents a SOAP exception. ©NIIT Collaborate Lesson 1C / Slide 11 of 23
  12. 12. CollaborateSAAJ API (Contd.) • The following figure shows the components of SOAPMessage object: ©NIIT Collaborate Lesson 1C / Slide 12 of 23
  13. 13. CollaborateFrom the Expert’s Desk This section will introduce the following: • Best Practices on processing XML documents. • Tips on caching techniques in XSLT to enhance performance. • Tips on development techniques to make XSLT stylesheets manageable. • Tips on techniques to use the import and include statements for combining stylesheets. • FAQs on retrieving status and error information related to SOAP messages. ©NIIT Collaborate Lesson 1C / Slide 13 of 23
  14. 14. CollaborateBest PracticesProcessing XML Documents • You can process XML documents using either SAX or DOM parsers. • Use SAX parser: • To parse large sized XML documents. • When XML document is not nested. • Do not use SAX parser to modify the structure of an XML document. • Use DOM parser: • To parse small sized XML documents. • When you know that the entire document is to be parsed. • When you want to access the particular element in an XML document. ©NIIT Collaborate Lesson 1C / Slide 14 of 23
  15. 15. CollaborateTipsCaching Techniques in XSLT to EnhancePerformance • You can implement caching by loading transformation information into the object of JAXP’s javax.xml.transform.Templates interface. • You can then use the Templates object to obtain a Transformer object. • You can reuse the Templates object to produce more transformers later and save time on stylesheet parsing and compilation. • The following syntax shows the declaration of Templates object to obtain a Transformer object: Source source_xslt = new StreamSource(xslt_File); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Templates cached_XSLT=transformerFactory.newTemplates(source_xslt); Transformer transformer = cached_XSLT.newTransformer(); ©NIIT Collaborate Lesson 1C / Slide 15 of 23
  16. 16. CollaborateTips (Contd.)Development Techniques to Make XSLTStylesheets Manageable • Techniques to make XSLT stylesheets easily readable and manageable are: • Using syntax highlighting editor can make the XSLT stylesheets readable. • Adding comment blocks can make XSLT templates descriptive and breaks the repetitiveness of scanning < and > characters page by page. • Using naming conventions for variables and parameters. • Breaking the functionalities into different stylesheets for reusing the code with the help of <xsl:import> ©NIIT Collaborate Lesson 1C / Slide 16 of 23
  17. 17. CollaborateTips (Contd.)Techniques to Use the Import and IncludeStatements for Combining Stylesheets • Two methods to combine stylesheets are: • The include mechanism • The import mechanism ©NIIT Collaborate Lesson 1C / Slide 17 of 23
  18. 18. CollaborateTips (Contd.)Techniques to Use the Import and IncludeStatements for Combining Stylesheets (Contd.) • The include mechanism: • A stylesheet is combined without changing the syntax of the stylesheet. • A stylesheet can include another stylesheet with the help of element, <xsl:include>. • The <xsl:include> element accepts a parameter, href whose value is a URI reference. ©NIIT Collaborate Lesson 1C / Slide 18 of 23
  19. 19. CollaborateTips (Contd.)Techniques to Use the Import and IncludeStatements for Combining Stylesheets (Contd.) • The import mechanism: • A stylesheet overrides the other stylesheet. • A stylesheet can be imported with the help of the statement, <xsl:import>. • You need to use the statement, <xsl:import> within the CSS file or STYLE element. • The statement, <xsl:import> should occur at the start of the stylesheet. ©NIIT Collaborate Lesson 1C / Slide 19 of 23
  20. 20. CollaborateFAQs • How can you retrieve status and error information when a SOAP message does not reach its destination properly? • An object of the SOAPFault class is used to receive status and error information when the message does not reach its destination successfully. • A SOAPFault object is present in the SOAPBody object of the message. • A SOAPFault object informs the end user about a problem, such as an exception object. • A SOAPFault object contains a: • fault code: Represents the code that indicates a problem. • fault string: Represents the fault as a String object. • fault actor: Identifies the source of the fault. • detail object: Represents the fault that occurs because of a SOAPBody object. ©NIIT Collaborate Lesson 1C / Slide 20 of 23
  21. 21. CollaborateChallenge 3. Consider the following two statements: Statement A: A registry is a directory provided by a service provider to publish their Web service. Statement B: A registry is a directory provided by a service provider to allow clients to bind with its Web service. Identify the correct option: a. Both statements A and B are true b. Both statements A and B are false c. Statement A is true while statement B is false d. Statement A is false while statement B is true ©NIIT Collaborate Lesson 1C / Slide 21 of 23
  22. 22. CollaborateChallenge (Contd.) 2. What does the fault string element of a SOAP message represent? 3. The classes and interfaces of the ____________ package can be used to create and send SOAP messages from a Java application. 4. The ___________ method allows you to parse an XML document using both SAX and DOM parsers. 5. A ___________ document defines a Web service and are used by service providers to publish their Web service in registries. ©NIIT Collaborate Lesson 1C / Slide 22 of 23
  23. 23. CollaborateSolution • b. Both statement A and B are false • The fault string element represents an error in the SOAP message • javax.xml.soap • parse() • WSDL ©NIIT Collaborate Lesson 1C / Slide 23 of 23

×