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 .. 142 143 144 145 146 147 < 148 > 149 150 151 152 153 154 .. 166 >> Next

100 Iterator svcIter = org.getServices().iterator();
101 while ( svcIter.hasNext() )
102 {
103 Service svc = (Service)svcIter.next();
104 System.out.println(" Service Name: " +
105 convertToString(svc.getName()));
106
107
108 //Let's get the service binding object
109 Iterator bindit = svc.getServiceBindings().iterator();
110 while ( bindit.hasNext() )
111 {
112 ServiceBinding sb = (ServiceBinding)bindit.next();
113 System.out.println(" Service Binding Name: " +
114 convertToString(sb.getName()));
115 System.out.println(" Service Binding Desc: " +
116 convertToString(sb.getDescription())),
117 System.out.println(" Service Binding Access URI:\n’ +
118 " " + sb.getAccessURI());
119
120 Iterator speclinkit =
121 sb.getSpecificationLinks().iterator();
122 while ( speclinkit.hasNext() )
123 {
124 SpecificationLink slink =
125 (SpecificationLink)speclinkit.next();
126
127 RegistryObject ro = slink.getSpecificationObject();
128 Iterator extlinkit =
ro.getExternalLinks().iterator();
129 while ( extlinkit.hasNext() )
130 {
131 ExternalLink extlink = 2
(ExternalLink)extlinkit.next();
132 System.out.println(" WSDL: " +
133 extlink.getExternalURI());
134 }
135 }
136 }
137 }
138 }
139 }
140 }
Listing 47.4 (continued)
Where's the WSDL? Pitfalls of Using JAXR with UDDI 411
Unfortunately, the programmer was wrong again. As you can see in the output of the program in Listing 47.5, the first response from the 'truman' query returned no WSDL document. The second response from the 'truman' query returned an HTML document on line 17. Strangely, the first and second responses from the 'sched' query did return the WSDL document. What went wrong?
01:
02: Made an organizational query for 'truman'...
03: 1) Organization Name: TrumanTruck.com
04: Organization Desc: Restoration of Truman Schermerhorn's Truck
05: Service Name: TrumanTruck Page
06: Service Binding Name: null
07: Service Binding Desc: hyperlink
08: Service Binding Access URI:
09: http://www.trumantruck.com
10: 2) Organization Name: Harry S. Truman Scholarship Foundation
11: Organization Desc:
12: Service Name: Web home page
13: Service Binding Name: null
14: Service Binding Desc: hyperlink
15: Service Binding Access URI:
16: http://www.truman.gov/welcome.htm
17: WSDL: http://www.uddi.org/specification.html
18: -- ---------SECOND QUERY--------------
19: Made an organizational query for 'sched'...
20: 1) Organization Name: LFC Scheduling
21: Organization Desc:
22: Service Name: Classroom Scheduling
23: Service Binding Name: null
24: Service Binding Desc:
25: Service Binding Access URI:
26: http://www.contest.eraserver.net/Scheduling/Scheduler.asmx
27: WSDL: 2
http://www.contest.eraserver.net/Scheduling/Scheduler.asmxPwsdl
28: 2) Organization Name: Interactive Scheduler
29: Organization Desc:
30: Service Name: Interactive Schedule
31: Service Binding Name: null
32: Service Binding Desc:
33: Service Binding Access URI:
34:
http://www.contest.eraserver.net/InteractiveScheduler/service1.asmx
35: WSDL:
http://www.contest.eraserver.net/InteractiveScheduler/ 2
InteractiveScheduler.wsdl
Listing 47.5 Output of our second attempt
412 Item 47
The problem from our second attempt to find WSDL documents revolves around the concept of classifications. Because both registry objects for our first query were not classified as the UDDI "wsdlspec" type, they do not have WSDL documents. Unfortunately, this is a common programming mistake. If the programmer had assumed that these were both Web services registered with a WSDL URL, the program would have mixed results—the program may work for one query, but not for another. In the case of the false WSDL document output on line 17, if the program had tried to dynamically call the Web service using JAX-RPC, the program would have failed.
The answer to our dilemma lies in our call from the Classification object to the RegistryObject in Figure 47.2. If you call getClassifications() from the returned RegistryObject, and if the classification of that object is the "wsdlspec" classification, then you can call getClassifiedObject() to then get the WSDL-classified object, and then retrieve the external link. Listing 47.6 does just that in lines 123 to 150.
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 orgIterator = response.getCollection().iterator();
084
Previous << 1 .. 142 143 144 145 146 147 < 148 > 149 150 151 152 153 154 .. 166 >> Next