Books
in black and white
Main menu
Share a book About us Home
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

More Java Pitfalls Share Reactor - Daconta M,C.

Daconta M,C. More Java Pitfalls Share Reactor - Wiley publishing, 2003. - 476 p.
ISBN: 0-471-23751-5
Download (direct link): morejavapitfallssharereactor2003.pdf
Previous << 1 .. 141 142 143 144 145 146 < 147 > 148 149 150 151 152 153 .. 166 >> Next

07 Service Binding Desc: hyperlink
08 Service Binding Access URI:
09 http://www.trumantruck.com
10 ? - No WSDL document at
11 svc.getServiceBindings().getExternalLinks()..
12 2) Organization Name: Harry S. Truman Scholarship Foundation
13 Organization Desc:
14 Service Name: Web home page
15 ? - No WSDL document at svc.getExternalLinks()..
16 Service Binding Name: null
17 Service Binding Desc: hyperlink
18 Service Binding Access URI:
19 http://www.truman.gov/welcome.htm
20 ? - No WSDL document at
21 svc.getServiceBindings().getExternalLinks()..
22 -----------SECOND QUERY--------------
23 Made an organizational query for ’sched'...
24 1) Organization Name: LFC Scheduling
25 Organization Desc:
26 Service Name: Classroom Scheduling
27 ? - No WSDL document at svc.getExternalLinks()..
28 Service Binding Name: null
29 Service Binding Desc:
30 Service Binding Access URI:
31 http://www.contest.eraserver.net/Scheduling/Scheduler.asmx
32 ? - No WSDL document at
33 svc.getServiceBindings().getExternalLinks()..
34 2) Organization Name: Interactive Scheduler
35 Organization Desc:
36 Service Name: Interactive Schedule
37 ? - No WSDL document at svc.getExternalLinks()..
38 Service Binding Name: null
39 Service Binding Desc:
40 Service Binding Access URI:
41 2
http://www.contest.eraserver.net/InteractiveScheduler/service1.asmx
42 ? - No WSDL document at
43 44 svc.getServiceBindings().getExternalLinks()..
Listing 47.3 (continued)
The problem in that example demonstrates the programmer's misunderstanding of where the WSDL document lives in the JAXR object hierarchy. This is a common problem with developers new to JAXR and UDDI. Luckily, Appendix D of the JAXR specification (found at http://java.sun.com/xml/jaxr/) shows the mappings of JAXR to UDDI. In Figure 47.2, we have provided a graphical depiction of where the WSDL document is located. To get the WSDL document for a Web service, you need to somehow
408 Item 47
traverse the structures to get to the registry object classified as a "wsdlspec", and get that object's ExternalLink. Because our organizational query returns a collection of organizations, we have shown a logical "road map" from the Organization object. For the sake of eliminating confusion, we have left out potential paths to ExternalLink and SpecificationLink that are available from every object (since they all realize the RegistryObject interface).
TI P| If you are used to UDDI terminology, there are different terms for each of these interfaces. For example, a JAXR Organization is known in UDDI as a "businessEntity." A JAXR Service is known as a UDDI "businessService." A UDDI "bindingTemplate" is a JAXR ServiceBinding. There are many more of these mappings. For more information, download the JAXR specification at http://java.sun.com/jaxr/.
Figure 47.2 Navigating through JAXR objects to get WSDL .
Where's the WSDL? Pitfalls of Using JAXR with UDDI 409
Now that we have provided the "traversal road map" in Figure 47.2, we will demonstrate another potential programming pitfall. In Listing 47.4, the programmer traverses the objects as shown from the figure. On line 83, we get our collection of organizations from our BulkResponse object. On line 100, we get a collection of services from each organization. On line 109, we get a collection of service bindings from each service. On lines 120 and 121, we get a collection of specification links from each service binding. On line 127, we get a registry object from the specification link with the getSpecifica-tionObject() method. Finally, on lines 128 to 134, we get the external link from the registry object, and we call the getExternalURI() method on the specification link.
064 public void makeCall(String query) throws Exception
065 {
066 if ( m_querymgr == null )
067 {
068 throw new Exception("No query manager!!!!! Exiting 2
makeCall() ");
069 }
070 else
071 {
072
073 Collection findQualifiers = new ArrayList();
074 findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
075 Collection namePatterns = new ArrayList();
076 namePatterns.add("%" + query + "%");
077
078 BulkResponse response =
079 m_querymgr.findOrganizations(findQualifiers,
080 namePatterns,
081 null, null, null, null);
082
083 Iterator orglterator = response.getCollection().iterator();
084
085 System.out.println("Made an organizational query for '" +
086 query + "'...");
087
088 int orgcnt = 0;
089 while ( orgIterator.hasNext() )
090 {
091 orgcnt ++;
092 //Let's get every organization that matches the query!
093 Organization org = (Organization) orgIterator.next();
094 System.out.println(orgcnt + ") Organization Name: " +
095 convertToString(org.getName()));
096 System.out.println(" Organization Desc: " +
097 convertToString(org.getDescription()));
098
Listing 47.4 Our second attempt for WSDL, in makeCall() (continued)
410 Item 47
099 //Now get the services provided by the organization
Previous << 1 .. 141 142 143 144 145 146 < 147 > 148 149 150 151 152 153 .. 166 >> Next