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.samples;
1819import org.apache.juddi.v3.client.config.UDDIClerk;
20import org.apache.juddi.v3.client.config.UDDIClient;
21import org.apache.juddi.v3.client.config.UDDIClientContainer;
22import org.apache.juddi.v3.client.transport.Transport;
23import org.apache.juddi.v3_service.JUDDIApiPortType;
24import org.uddi.api_v3.AccessPoint;
25import org.uddi.api_v3.AuthToken;
26import org.uddi.api_v3.BindingTemplate;
27import org.uddi.api_v3.BindingTemplates;
28import org.uddi.api_v3.BusinessEntity;
29import org.uddi.api_v3.BusinessService;
30import org.uddi.api_v3.BusinessServices;
31import org.uddi.api_v3.GetAuthToken;
32import org.uddi.api_v3.Name;
33import org.uddi.api_v3.SaveBusiness;
34import org.uddi.api_v3.SaveTModel;
35import org.uddi.api_v3.TModel;
36import org.uddi.v3_service.UDDIPublicationPortType;
37import org.uddi.v3_service.UDDISecurityPortType;
3839/**40 * This class was created to demonstrate that UDDI entities's keys do not need41 * to be from the same key domain. I.e. Business key = "uddi:1234:business"42 * which owns Service key "uddi:4567:service1"43 *44 * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>45 */46publicclassBusinessServiceKeymismatch {
4748privatestaticUDDISecurityPortType security = null;
49privatestaticJUDDIApiPortType juddiApi = null;
50privatestaticUDDIPublicationPortType publish = null;
5152publicstaticvoid main(String[] args) throws Exception {
5354// create a manager and read the config in the archive; 55// you can use your config file name56UDDIClient clerkManager = newUDDIClient("META-INF/simple-publish-uddi.xml");
57// The transport can be WS, inVM etc which is defined in the uddi.xml58Transport transport = clerkManager.getTransport("default");
59// Now you create a reference to the UDDI API60 security = transport.getUDDISecurityService();
61 publish = transport.getUDDIPublishService();
6263//step one, get a token64GetAuthToken getAuthTokenRoot = newGetAuthToken();
65 getAuthTokenRoot.setUserID("uddi");
6667 getAuthTokenRoot.setCred("uddi");
68AuthToken authToken = security.getAuthToken(getAuthTokenRoot);
69TModel createKeyGenator = UDDIClerk.createKeyGenator("uddi:testdomain:keygenerator", "a name", "en");
7071TModel createKeyGenator2 = UDDIClerk.createKeyGenator("uddi:testdomain2:keygenerator", "a name", "en");
7273SaveTModel st = newSaveTModel();
74 st.setAuthInfo(authToken.getAuthInfo());
75 st.getTModel().add(createKeyGenator);
76 st.getTModel().add(createKeyGenator2);
77 publish.saveTModel(st);
7879SaveBusiness sb = newSaveBusiness();
80 sb.setAuthInfo(authToken.getAuthInfo());
81BusinessEntity be = newBusinessEntity();
82 be.setBusinessKey("uddi:testdomain:biz1");
83 be.getName().add(new Name("test", "en"));
84 be.setBusinessServices(newBusinessServices());
85BusinessService bs = newBusinessService();
86 bs.setServiceKey("uddi:testdomain2:svc");
87 bs.setBusinessKey("uddi:testdomain:biz1");
88 bs.getName().add(new Name("svc", "en"));
89 bs.setBindingTemplates(newBindingTemplates());
90BindingTemplate bt = newBindingTemplate();
91 bt.setAccessPoint(newAccessPoint("http://localhost", "wsdlDeployment"));
92 bt = UDDIClient.addSOAPtModels(bt);
93 bs.getBindingTemplates().getBindingTemplate().add(bt);
94 be.getBusinessServices().getBusinessService().add(bs);
95 sb.getBusinessEntity().add(be);
96 publish.saveBusiness(sb);
97 }
98 }