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

Listing 47.2 shows the makeCall() method where we are attempting to get the WSDL document from a search of the registry. Our search constraint, the query string, is set up to be a pattern on lines 74 and 75. At the same time, we qualify our search on line 74 by setting our responses to be sorted alphabetically by name. Our example then queries the BusinessQueryManager's findOrganizations() method with these parameters. Because a collection of Organization objects will be returned from the collection in the BulkResponse object, and because organizations contain services that can be retrieved by the organization's getServices() method, we will be able to get the services. Because the Service object inherits the getExternalLinks() method from RegistryObject, the programmer in this example assumes that we should be able to get the WSDL document with that method on the service. Just to make certain, the programmer calls that method from the service's ServiceBinding objects, which was returned from getServiceBindings() on the service on line 123.
064 public void makeCall(String query) throws Exception
065 {
066 if ( m_querymgr == null )
067 {
068 throw new Exception("No query manager!!!!! Exiting ^
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
Listing 47.2 Our first attempt for WSDL, in makeCall()
Where's the WSDL? Pitfalls of Using JAXR with UDDI 405
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
099 //Now get the services provided by the organization
100 Iterator svclter = 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 //External links are associated with every registry
object,
108 //so maybe it's in the external link of service..
109 Iterator extlinkit = svc.getExternalLinks().iterator();
110 if ( !extlinkit.hasNext() )
111 {
112 System.out.println(" ? - " +
113 "No WSDL document at
svc getExternalLinks()..");
114 }
115 while ( extlinkit.hasNext() )
116 {
117 ExternalLink extlink = (ExternalLink)extlinkit.next() ;
118 System.out.println("WSDL Document: " +
119 extlink.getExternalURI());
120 }
121
122 //Let's get the service binding object
123 Iterator bindit = svc.getServiceBindings().iterator();
124 while ( bindit.hasNext() )
125 {
126 ServiceBinding sb = (ServiceBinding)bindit.next();
127 System.out.println(" Service Binding Name: " +
128 convertToString(sb.getName()));
129 System.out.println(" Service Binding Desc: " +
130 convertToString(sb.getDescription()));
Listing 47.2 (continued)
406 Item 47
131 System.out.println(" Service Binding Access URI:\n" +
132 " " + sb.getAccessURI());
133
134 //Maybe WSDL is on the external link here..
135 Iterator extlinkit2 = sb.getExternalLinks().iterator();
136 if ( !extlinkit2.hasNext() )
137 {
138 System.out.println(" ? - " +
139 "No WSDL document at \n" +
140 " svc.getServiceBindings().getExternalLinks()..");
141 }
142 while ( extlinkit2.hasNext() )
143 {
144 ExternalLink extlink = ^
(ExternalLink)extlinkit2.next();
145 System.out.println("WSDL Document: " +
146 extlink.getExternalURI());
147 }
148
149
150 }
151
152
153 }
154
155 }
156 }
157 }
Listing 47.2 (continued)
Our example in Listing 47.2 shows a search of the UDDI registry, and printing organization, service, and service binding information for the result of our search. Listing
47.3 shows the output of our program. There are two calls to makeCall(): a query including the string 'truman' and a query including the string 'sched'. Both queries return two results. As you can see by the bolded content in Listing 47.3, the programmer got it wrong.
01: Made an organizational query for 'truman1... 02: 1) Organization Name: TrumanTruck.com
03: Organization Desc: Restoration of Truman Schermerhorn's Truck
04: Service Name: TrumanTruck Page
05: ? - No WSDL document at svc.getExternalLinks()..
06: Service Binding Name: null
Listing 47.3 Output of our first attempt
Where's the WSDL? Pitfalls of Using JAXR with UDDI 407
Previous << 1 .. 140 141 142 143 144 145 < 146 > 147 148 149 150 151 152 .. 166 >> Next