|
C:\uddi\inspireit\uddi\examples\Axis10Example.java
|
1 package inspireit.uddi.examples;
2
3 import java.net.*;
4
5 import inspireit.uddi.base.*;
6 import inspireit.uddi.collections.*;
7 import inspireit.uddi.request.*;
8 import inspireit.uddi.request.base.*;
9 import inspireit.uddi.response.*;
10 import inspireit.uddi.response.base.*;
11
12 /**
13 * This example is derived from the FindBusinessExample example. It shows how
14 * Apache Axis 1.0 can be used instead of the default SOAP transport layer
15 * provided with the library. The Apache Axis 1.0 JAR archives have to be
16 * in the CLASSPATH in order for this example to run.
17 *
18 * @author Bertrand Fontaine, <a href="http://www.inspireit.biz" target="INSPIREIT">INSPIRE IT</a>
19 */
20 public class Axis10Example {
21
22 public Axis10Example(String queryURL) throws Exception {
23 // define the appropriate UDDI profile
24 UDDIProfile profile = new UDDIProfile();
25
26 // use Apache Axis 1.0 as the SOAP transport technology
27 // the rest of the application is exactly the same as the original
28 // FindBusinessExample example !!!
29 profile.setProperty("inspireit.uddi.transport","inspireit.uddi.transport.Axis10Transport" );
30 profile.setQueryURL(new URL(queryURL));
31
32 // uncomment one of the following lines to use UDDI V2 or V3 messaging instead of the default V1
33 // profile.setVersion(UDDIConstants.UDDI_V2);
34 // profile.setVersion(UDDIConstants.UDDI_V3);
35
36 UDDIQuerier querier = UDDIQuerier.getQuerier(profile);
37
38 try {
39 // find max. 5 businesses starting with "S", sorted by name descending
40 int max = 5;
41 Name name = new Name("S%");
42 FindQualifiers findQualifiers = new FindQualifiers();
43 findQualifiers.add(FindQualifier.sortByNameDesc);
44
45 // the following is required for UDDI V3 and will be ignored if another UDDI version is used
46 findQualifiers.add(FindQualifier.approximateMatch);
47
48 BusinessList businessList = querier.findBusiness(name, findQualifiers, max);
49 BusinessInfos businessInfos = businessList.getBusinessInfos();
50
51 if ((businessInfos == null) || (businessInfos.size() == 0)) {
52 System.out.println("Sorry, no business found.");
53 } else {
54 BusinessInfo businessInfo[] = businessInfos.toArray();
55
56 for(int i=0; i< businessInfo.length; i++) {
57 BusinessInfo bi = businessInfo[i];
58 Names names = bi.getNames();
59 Name _name[] = names.toArray();
60 System.out.println("BusinessInfo #" + i + ": " + _name[0]);
61 }
62 }
63 } catch(UDDIException e) {
64 e.printStackTrace();
65 }
66 }
67
68 public static void main(String args[]) throws Exception {
69 if (args.length != 1) {
70 System.out.println("Axis10Example usage: java Axis10Example <queryURL>");
71 System.exit(0);
72 }
73
74 new Axis10Example(args[0]);
75 return;
76 }
77 }
78