Java 2EE and XML Development

Скачать в pdf «Java 2EE and XML Development»


The client in this scenario ф can be anything capable of sending a SOAP request. In this scenario, the client is our repair diagnostic application. It sends a single string parameter with the SOAP request, which represents the name of the machine for which we are requesting information. The SOAP server at


Case study

Figure 6.9 Amaya web service integration


Amaya @ receives SOAP requests and passes them to the appropriate component. In this case, the CommonIssuesBean is the target of our SOAP request. The CommonIssuesBean @ accesses XML data regarding support information for Amaya’s computers. It returns an org.w3c.dom.Document to the SOAP server, which in turn sends this information back to the requesting client.


Listing 6.8 is the implementation of the CommonIssuesBean. As with our previous listing, we omit the source for the home and remote interfaces.


Listing 6.8 CommonIssuesBean implementation


public class CommonIssuesBean implements SessionBean {


/**


*    Get the list of issues from the file system


*    and return the XML document.


*/


public Document getIssuesList( String name ) throws RemoteException { try {


DocumentBuilderFactory dFactory


= DocumentBuilderFactory.newInstance();


DocumentBuilder dBuilder


Retrieves document from file system and returns it


= dFactory.newDocumentBuilder();


Document issueDoc = dBuilder.parse


(«config/mydomain/applications/amaya/»


+ name + «.xml»); return issueDoc; |#1 } catch (Exception e) {


System.out.println(«Error in common issues bean: » + e.getMessage())


}


return null;


The data that this bean sends back to RepairCo (amaya.xml) is listing 6.9. Notice that it contains an issue with the id equal to 0004; an additional problem with the Amaya Workstation that RepairCo’s list does not contain (see listing 6.7). This issue will be added to the list when RepairCo calls the Amaya web service.

Скачать в pdf «Java 2EE and XML Development»