This project has retired. For details please refer to its Attic page.
UddiFindEndpoints xref
View Javadoc
1   /*
2    * Copyright 2001-2013 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   */
17  package org.apache.juddi.samples;
18  
19  import java.util.List;
20  import org.apache.juddi.v3.client.config.UDDIClerk;
21  import org.apache.juddi.v3.client.config.UDDIClient;
22  import org.apache.juddi.v3.client.transport.Transport;
23  import org.uddi.v3_service.UDDIInquiryPortType;
24  import org.uddi.v3_service.UDDISecurityPortType;
25  
26  /**
27   * This class show you how get all available Access Points/Endpoints for a
28   * service. This is harder than it sounds due to the complexity of UDDI's data
29   * structure. The output is the list of URLs given a service's key
30   *
31   * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
32   */
33  public class UddiFindEndpoints {
34  
35          private UDDIClerk clerk = null;
36  
37          public UddiFindEndpoints() {
38                  try {
39                          // create a manager and read the config in the archive; 
40                          // you can use your config file name
41                          UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
42                          clerk = clerkManager.getClerk("default");
43  
44                  } catch (Exception e) {
45                          e.printStackTrace();
46                  }
47          }
48  
49          public void fire(String authtoken, String key) {
50                  try {
51                          if (key == null) {
52                                  key = "uddi:juddi.apache.org:services-inquiry";
53                          }
54  
55                          List<String> endpoints = clerk.getEndpoints(key);
56                          System.out.println("Endpoints returned: " + endpoints.size());
57                          for (int i = 0; i < endpoints.size(); i++) {
58                                  System.out.println(endpoints.get(i));
59                          }
60  
61                  } catch (Exception e) {
62                          e.printStackTrace();
63                  }
64          }
65  
66          public static void main(String args[]) {
67                  UddiFindEndpoints sp = new UddiFindEndpoints();
68                  sp.fire(null, null);
69          }
70  }