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

416 Item 47
094
095 Classification wsdlSpecClass =
096 blm.createClassification(uddiOrgTypes,
097 "wsdlSpec", "wsdlSpec");
098
099 Collection classifications = new ArrayList();
100 classifications.add(wsdlSpecClass);
101
102 // Find concepts
103 BulkResponse response =
104 m_querymgr.findConcepts(null, namePatterns,
105 classifications, null, null);
106
107 System.out.println("Made an wsdlSpec concept query for \n’" +
108 "services matching '" +query + "'");
109
110 // Display information about the concepts found
111 int itnum = 0;
112 Iterator iter = response.getCollection().iterator();
113 if ( !iter.hasNext())
114 {
115 System.out.println(" No matching items!");
116 }
117 while ( iter.hasNext() )
118 {
119 itnum++;
120 Concept concept = (Concept) iter.next();
121 System.out.println(itnum + ") Name: " +
122 convertToString(concept.getName()));
123 System.out.println(" Description: " +
124 convertToString(concept.getDescription()));
125
126 Iterator linkit = concept.getExternalLinks().iterator();
127 if ( linkit.hasNext() )
128 {
129 ExternalLink link =
130 (ExternalLink) linkit.next();
131 System.out.println(" WSDL: '" +
132 link.getExternalURI() + "'");
133 }
134
135 }
136 }
137 }
Listing 47.8 (continued)
The result of our program is shown in Listing 47.9. On our concept query for services with the string 'sched' in them with WSDL documents, we had four results.
Performance Pitfalls in JAX-RPC Application Clients 417
01 Made an wsdlSpec concept query for
02 'services matching 'truman'
03 No matching items!
04 -----------SECOND QUERY--------------
05 Made an wsdlSpec concept query for
06 'services matching 'sched'
07 1) Name: Continental-com:Schedule-v1
08 Description: Flight schedule
09 WSDL: 2
'http://webservices.continental.com/schedule/schedule.asmxPWSDL'
10 2) Name: Interactive Scheduler
11 Description: A Web Service that provides a method to schedule meetings into someone else's calendar. 2
12 WSDL: 2
'http://www.contest.eraserver.net/InteractiveScheduler/ 2
InteractiveScheduler.wsdl'
13 3) Name: Lake Forest College-com:SchedulingInterface-v1
14 Description: Scheduling Web Service for Institutions- 2
Scheduling Classes to appropriate rooms
15 WSDL: 2
'http://www.contest.eraserver.net/Scheduling/Scheduler.asmxPwsdl'
16 4) Name: Metric-com:Aeroflot Flights Schedule
17 Description: Web service deliver on-line flights schedule 2
information
18 WSDL: 'http://webservices.aeroflot.ru/flightSearch.wsdl'
Listing 47.9 Output of querying by concept
In this pitfall, we demonstrated problems that developers encounter when using the JAXR API with UDDI registries. We showed two examples of potential pitfalls while traversing the data structures of the registry and provided solutions for these problems. Because of the difficulty that some programmers have with JAXR and UDDI, reading the JAXR specification is highly recommended.
Item 48: Performance Pitfalls in JAX-RPC Application Clients
The Java API for XML-based Remote Procedure Calls (JAX-RPC) allows us to continue to think like Java developers when we develop, deploy, and communicate with RPC-based Web services. Although JAX-RPC relies on underlying protocols (HTTP and SOAP), the API hides this complexity from the application developer. Using basic programming techniques that enterprise developers are accustomed to, you can create a Web service easily. Building a client that communicates with the Web service is also
418 Item 48
easy—proxy stubs for the Web service can be compiled prior to runtime, they can be dynamically generated at runtime, or the Dynamic Invocation Interface (DII) can be used to discover a Web service's API on-the-fly.
In this pitfall item, we use different techniques in building clients for a simple Web service. We run a timing experiment on each of the techniques and give recommendations for building clients using JAX-RPC. As a result of reading this pitfall item, you will understand the performance implications of using each technique—and hopefully use this to your advantage in your projects.
Example Web Service
For this pitfall item, we used Sun's Java Web Services Developer Pack (WSDP) and created a simple Web service called "SimpleTest." The Web service has one method called doStuff(), and the interface used to develop this Web service is shown in Listing 48.1.
001 package org.javapitfalls.item48;
002
003 import java.rmi.Remote;
004 import java.rmi.RemoteException;
005
006 public interface SimpleTestIF extends Remote
007 {
008 public String doStuff(String s) throws RemoteException;
009 }
Listing 48.1 Interface to our simple Web service.
The Web Service Description Language (WSDL) that was automatically generated from the tools available with the developer's pack is shown in Listing 48.2. Because this was automatically generated and deployed with the developer tools that generated this from our Java interface, our implementation class, and deployment descriptors, we weren't forced to write it by hand. As JAX-RPC defines Web services as collections of remote interfaces and methods, WSDL defines Web services as a collection of ports and operations. The WSDL provided in Listing 48.2 is for your reference, as we develop our Web service clients later in the pitfall examples.
Previous << 1 .. 144 145 146 147 148 149 < 150 > 151 152 153 154 155 156 .. 166 >> Next