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

085 System.out.println("Made an organizational query for '" +
086 query + "'...");
087
088 int orgcnt = 0;
089 while ( orgIterator.hasNext() )
090 {
091 String orgname = null;
092 String orgdesc = null;
Listing 47.6 The solution to our dilemma
Where's the WSDL? Pitfalls of Using JAXR with UDDI 413
093 String svcname = null;
094
095 //Let's get every organization that matches the query!
096 Organization org = (Organization) orgIterator.next();
097
098 orgname = convertToString(org.getName());
099 orgdesc = convertToString(org.getDescription());
100
101 //Now get the services provided by the organization
102 Iterator svcIter = org.getServices().iterator();
103 while ( svcIter.hasNext() )
104 {
105 Service svc = (Service)svcIter.next();
106 svcname = convertToString(svc.getName());
107
108 //Let's get the service binding object from service
109 Iterator bindit = svc.getServiceBindings().iterator();
110 while ( bindit.hasNext() )
111 {
112 ServiceBinding sb = (ServiceBinding)bindit.next();
113
114 Iterator speclinkit =
115 sb.getSpecificationLinks().iterator();
116 while ( speclinkit.hasNext() )
117 {
118 SpecificationLink slink =
119 (SpecificationLink)speclinkit.next();
120
121 RegistryObject ro = slink.getSpecificationObject();
122
123 //Now, let's see the classification object..
124 Iterator classit = ro.getClassifications().iterator();
125 while ( classit.hasNext() )
126 {
127 Classification classif =
128 (Classification)classit.next();
129 if ( classif.getValue().equalsIgnoreCase("wsdlspec") )
130 {
131: orgcnt++;
132 System.out.println(orgcnt +
133 ") Organization Name: " + orgname);
134 System.out.println(
135 " Organization Desc: " + orgdesc);
136 System.out.println(
137 " Service Name: " + svcname);
138
139 RegistryObject ro2 = classif.getClassifiedObject();
Listing 47.6 (continued)
414 Item 47
140
141 Iterator extlinkit =
142 ro2.getExternalLinks().iterator();
143 while ( extlinkit.hasNext() )
144 {
145 ExternalLink extlink =
146 (ExternalLink)extlinkit.next();
147
148 System.out.printlnC WSDL: " +
149 extlink.getExternalURI());
150 }
151
152 }
153 }
154 }
155 }
156 }
157 }
158 }
159 }
Listing 47.6 (continued)
The result of our example is shown in Listing 47.7. In our output, our program only prints the listing of Web services that have WSDL documents.
01: Made an organizational query for 'trumantruck'...
02: -----------SECOND QUERY--------------
03: Made an organizational query for 'sched'...
04: 1) Organization Name: LFC Scheduling 05: Organization Desc:
06: Service Name: Classroom Scheduling
07: WSDL: 2
http://www.contest.eraserver.net/Scheduling/Scheduler.asmx?wsdl 08: 2) Organization Name: Interactive Scheduler 09: Organization Desc:
10: Service Name: Interactive Schedule 11: WSDL:
http://www.contest.eraserver.net/InteractiveScheduler/ InteractiveScheduler.wsdl
Listing 47.7 The output of our solution
uu
Where's the WSDL? Pitfalls of Using JAXR with UDDI 415
It is important to note that we could get to the service much easier. If we knew the name of the service, for example, and we wanted to go directly to the RegistryOb-ject that has the "wsdlspec" classification, we could do a concept query. The Reg-istryObject, shown in Figure 47.2, on page 408, is always a Concept object when using UDDI registries (even though the getSpecificationObject() from the SpecificationLink interface returns the RegistryObject interface to be more flexible for other registries).
To demonstrate this, we will show another example of the makeCall() method in Listing 47.8. We will call the findConcepts() method on the BusinessQueryMan-ager object. To constrain the search, we will use the same namePatterns query pattern that we used in the previous examples, but we will add a classification constraint on lines 83 to 100. In doing so, the objects that are returned will be Concept objects that have WSDL documents and that match the query pattern passed in as a parameter.
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: /*
079: * Find the classification scheme defined by
080: * the UDDI spec
081: */
082:
083: String schemeName = "uddi-org:types";
084: ClassificationScheme uddiOrgTypes =
085: m_querymgr.findClassificationSchemeByName(null,
086: schemeName);
087: /*
088: * Create a classification, specifying the scheme
089: * and the taxonomy name and value defined for
090: * WSDL documents by the UDDI spec
091: */
092: BusinessLifeCycleManager blm =
093: m_regserv.getBusinessLifeCycleManager();
Listing 47.8 Good example of querying by concept (continued)
Previous << 1 .. 143 144 145 146 147 148 < 149 > 150 151 152 153 154 155 .. 166 >> Next