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 at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 *16 */17package org.apache.juddi.v3.client.cli;
1819import org.apache.juddi.v3.client.UDDIConstants;
20import org.apache.juddi.v3.client.config.UDDIClient;
21import org.apache.juddi.v3.client.transport.Transport;
22import org.uddi.api_v3.*;
23import org.uddi.v3_service.UDDIInquiryPortType;
24import org.uddi.v3_service.UDDISecurityPortType;
2526/**27 * This class shows you how to find an endpoint by searching through all28 * services29 *30 * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>31 */32publicclassUddiFindBinding {
3334privateUDDISecurityPortType security = null;
35privateUDDIInquiryPortType inquiry = null;
3637publicUddiFindBinding() {
38try {
39// create a manager and read the config in the archive; 40// you can use your config file name41UDDIClient clerkManager = newUDDIClient("META-INF/simple-publish-uddi.xml");
42Transport transport = clerkManager.getTransport();
43// Now you create a reference to the UDDI API44 security = transport.getUDDISecurityService();
45 inquiry = transport.getUDDIInquiryService();
46 } catch (Exception e) {
47 e.printStackTrace();
48 }
49 }
5051publicvoid fire(String token) {
52try {
53// Setting up the values to get an authentication token for the 'root' user ('root' user has admin privileges54// and can save other publishers).55GetAuthToken getAuthTokenRoot = newGetAuthToken();
56 getAuthTokenRoot.setUserID("root");
57 getAuthTokenRoot.setCred("root");
5859if (token == null) {
60// Making API call that retrieves the authentication token for the 'root' user.61AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
62 System.out.println("root AUTHTOKEN = " + "don't log auth tokens!");
63 token = rootAuthToken.getAuthInfo();
64 }
65FindService fs = newFindService();
66 fs.setAuthInfo(token);
67 fs.getName().add(new Name());
68 fs.getName().get(0).setValue("%");
69 fs.setFindQualifiers(newFindQualifiers());
70 fs.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
7172ServiceList findService = inquiry.findService(fs);
73 System.out.println(findService.getServiceInfos().getServiceInfo().size());
74GetServiceDetail gs = newGetServiceDetail();
75for (int i = 0; i < findService.getServiceInfos().getServiceInfo().size(); i++) {
76 gs.getServiceKey().add(findService.getServiceInfos().getServiceInfo().get(i).getServiceKey());
77 }
7879ServiceDetail serviceDetail = inquiry.getServiceDetail(gs);
80for (int i = 0; i < serviceDetail.getBusinessService().size(); i++) {
81//System.out.println(serviceDetail.getBusinessService().get(i).getBindingTemplates().getBindingTemplate().size());82if (serviceDetail.getBusinessService().get(i).getBindingTemplates() != null) {
83for (int k = 0; k < serviceDetail.getBusinessService().get(i).getBindingTemplates().getBindingTemplate().size(); k++) {
84if (serviceDetail.getBusinessService().get(i).getBindingTemplates().getBindingTemplate().get(k).getAccessPoint() != null) {
85 System.out.println(serviceDetail.getBusinessService().get(i).getBindingTemplates().getBindingTemplate().get(k).getAccessPoint().getValue());
86 }
87 }
88 }
89 }
90 } catch (Exception e) {
91 e.printStackTrace();
92 }
93 }
9495publicstaticvoid main(String args[]) {
96UddiFindBinding sp = newUddiFindBinding();
97 sp.fire(null);
98 }
99 }