代码之家  ›  专栏  ›  技术社区  ›  Adam

在V2升级中,我们可以用什么Java API连接到Judii V3?

  •  0
  • Adam  · 技术社区  · 15 年前

    我们正在升级一些系统,包括从v2升级到juddi v3。在过去,我们在Java代码中使用UDDI4J来访问UDDI服务器,但是UDDI4J似乎没有继续V3。大量的谷歌时间让我觉得没有替代品。是这样吗?如果有其他选择,你能推荐一个吗?

    3 回复  |  直到 10 年前
        1
  •  1
  •   jens walter    15 年前

    据我所知,Juddiv3自带了自己的UDDI客户机。

    见: http://www.redhat.com/docs/en-US/JBoss_SOA_Platform/5.0.0-Beta1/html/jUDDI_User_Guide/chap-Using_jUDDI-Client.html

    我没有找到作为单独下载的lib,但它包含在juddi门户包中。

        2
  •  0
  •   spy    11 年前

    是的,Juddi有自己的uddiv3客户机。

    这是Maven的详细信息 <相关性> <groupid>org.apache.juddi</groupid> <artifactid>Juddi客户端</artifactid> <版本>3.1.5</version> </dependency>

    在当前的源主干中有大量的示例,所有这些示例都将与未来的版本捆绑在一起。示例如下: http://svn.apache.org/repos/asf/juddi/trunk/juddi-examples/

    Juddi用户指南也是一个很好的参考。

        3
  •  0
  •   Simmant    10 年前

    我在3.0.4 Juddi门户包中尝试以下代码

    /*
     * Copyright 2001-2010 The Apache Software Foundation.
     * 
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     * 
     *      http://www.apache.org/licenses/LICENSE-2.0
     * 
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     *
     */
    
    
    import org.apache.juddi.api_v3.Publisher;
    import org.apache.juddi.api_v3.SavePublisher;
    import org.apache.juddi.v3.client.ClassUtil;
    import org.apache.juddi.v3.client.config.UDDIClientContainer;
    import org.apache.juddi.v3.client.transport.Transport;
    import org.apache.juddi.v3_service.JUDDIApiPortType;
    import org.uddi.api_v3.AuthToken;
    import org.uddi.api_v3.BusinessDetail;
    import org.uddi.api_v3.BusinessEntity;
    import org.uddi.api_v3.BusinessService;
    import org.uddi.api_v3.GetAuthToken;
    import org.uddi.api_v3.Name;
    import org.uddi.api_v3.SaveBusiness;
    import org.uddi.api_v3.SaveService;
    import org.uddi.api_v3.ServiceDetail;
    import org.uddi.v3_service.UDDIPublicationPortType;
    import org.uddi.v3_service.UDDISecurityPortType;
    
    public class SimplePublish {
        private static UDDISecurityPortType security = null;
    
        private static JUDDIApiPortType juddiApi = null;
        private static UDDIPublicationPortType publish = null;
    
        public SimplePublish() {
            try {
                String clazz = UDDIClientContainer.getUDDIClerkManager(null).
                    getClientConfig().getUDDINode("default").getProxyTransport();
                Class<?> transportClass = ClassUtil.forName(clazz, Transport.class);
                if (transportClass!=null) {
                    Transport transport = (Transport) transportClass.
                        getConstructor(String.class).newInstance("default");
    
                    security = transport.getUDDISecurityService();
                    juddiApi = transport.getJUDDIApiService();
                    publish = transport.getUDDIPublishService();
                }   
            } catch (Exception e) {
                e.printStackTrace();
            }   
        }
    
        public void publish() {
            try {
                // Setting up the values to get an authentication token for the 'root' user ('root' user has admin privileges
                // and can save other publishers).
                GetAuthToken getAuthTokenRoot = new GetAuthToken();
                getAuthTokenRoot.setUserID("root");
                getAuthTokenRoot.setCred("");
    
                // Making API call that retrieves the authentication token for the 'root' user.
                AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
                System.out.println ("root AUTHTOKEN = " + rootAuthToken.getAuthInfo());
    
                // Creating a new publisher that we will use to publish our entities to.
                Publisher p = new Publisher();
                p.setAuthorizedName("my-publisher");
                p.setPublisherName("My Publisher");
    
                // Adding the publisher to the "save" structure, using the 'root' user authentication info and saving away. 
                SavePublisher sp = new SavePublisher();
                sp.getPublisher().add(p);
                sp.setAuthInfo(rootAuthToken.getAuthInfo());
                juddiApi.savePublisher(sp);
    
                // Our publisher is now saved, so now we want to retrieve its authentication token
                GetAuthToken getAuthTokenMyPub = new GetAuthToken();
                getAuthTokenMyPub.setUserID("my-publisher");
                getAuthTokenMyPub.setCred("");
                AuthToken myPubAuthToken = security.getAuthToken(getAuthTokenMyPub);
                System.out.println ("myPub AUTHTOKEN = " + myPubAuthToken.getAuthInfo());
    
                // Creating the parent business entity that will contain our service.
                BusinessEntity myBusEntity = new BusinessEntity();
                Name myBusName = new Name();
                myBusName.setValue("My Business");
                myBusEntity.getName().add(myBusName);
    
                // Adding the business entity to the "save" structure, using our publisher's authentication info and saving away.
                SaveBusiness sb = new SaveBusiness();
                sb.getBusinessEntity().add(myBusEntity);
                sb.setAuthInfo(myPubAuthToken.getAuthInfo());
                BusinessDetail bd = publish.saveBusiness(sb);
                String myBusKey = bd.getBusinessEntity().get(0).getBusinessKey();
                System.out.println("myBusiness key:  " + myBusKey);
    
                // Creating a service to save.  Only adding the minimum data: the parent business key retrieved from saving the business 
                // above and a single name.
                BusinessService myService = new BusinessService();
                myService.setBusinessKey(myBusKey);
                Name myServName = new Name();
                myServName.setValue("My Service");
                myService.getName().add(myServName);
                // Add binding templates, etc...
    
                // Adding the service to the "save" structure, using our publisher's authentication info and saving away.
                SaveService ss = new SaveService();
                ss.getBusinessService().add(myService);
                ss.setAuthInfo(myPubAuthToken.getAuthInfo());
                ServiceDetail sd = publish.saveService(ss);
                String myServKey = sd.getBusinessService().get(0).getServiceKey();
                System.out.println("myService key:  " + myServKey);
    
                // Now you have a publisher saved who in turn published a business and service via the jUDDI API!
            } 
            catch (Exception e) {
                e.printStackTrace();
            }
        }       
    
        public static void main (String args[]) {
            SimplePublish sp = new SimplePublish();
            sp.publish();   
        }
    }
    

    并使用以下库

    马文脱贫

    <dependency>
            <groupId>org.apache.juddi</groupId>
            <artifactId>juddi-client</artifactId>
            <version>3.0.2</version>
          </dependency>
    

    还有这个JAR文件

    轴2-adb-1.5.4.jar

    就这样,我的代码运行良好

    推荐文章