示例#1
0
 /**
  * Register a tModel. Note, if registration fails, no exception is
  * thrown
  * @param tModel
  * @param node
  * @return
  */
 public org.uddi.apiv3.tModelDetail register(org.uddi.apiv3.tModel tModel, org.apache.juddi.apiv3.node node)
 {
     org.uddi.apiv3.tModelDetail tModelDetail = null;
     log.info("Registering tModel with key " + tModel.tModelKey);
     try
     {
         String authToken = getAuthToken(node.securityUrl);
         save_tModel saveTModel = new save_tModel();
         saveTModel.authInfo = (authToken);
         saveTModel.tModel = new tModel[1];
         saveTModel.tModel[0] = (tModel);
         using (UDDI_Publication_SoapBinding pub = getUDDINode().getTransport().getUDDIPublishService(node.publishUrl))
         {
             tModelDetail = pub.save_tModel(saveTModel);
         }
         if (log.isDebugEnabled())
         {
             log.debug("Registering tModel " + tModel.tModelKey + " completed.");
         }
     }
     catch (Exception e)
     {
         log.error("Unable to register tModel " + tModel.tModelKey
                 + " ." + e.Message, e);
     }
     return tModelDetail;
 }
示例#2
0
        public static void main(string[] args)
        {
            UDDIClient clerkManager = null;
            Transport transport = null;
            UDDIClerk clerk = null;
            try
            {
                clerkManager = new UDDIClient("uddi.xml");

                transport = clerkManager.getTransport("default_non_root");

                UDDI_Security_SoapBinding security = transport.getUDDISecurityService();
                UDDI_Inquiry_SoapBinding inquiry = transport.getUDDIInquiryService();
                UDDI_Publication_SoapBinding publish = transport.getUDDIPublishService();

                clerk = clerkManager.getClerk("default_non_root");

                //Wadl Import example

                application app = WADL2UDDI.ParseWadl("..\\..\\..\\juddi-client.net.test\\resources\\sample.wadl");
                List<Uri> urls = WADL2UDDI.GetBaseAddresses(app);
                Uri url = urls[0];
                String domain = url.Host;

                tModel keygen = UDDIClerk.createKeyGenator("uddi:" + domain + ":keygenerator", domain, "en");
                //save the keygen
                save_tModel stm = new save_tModel();
                stm.authInfo = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
                stm.tModel = new tModel[] { keygen };

                publish.save_tModel(stm);
                Properties properties = new Properties();

                properties.put("keyDomain", domain);
                properties.put("businessName", domain);
                properties.put("serverName", url.Host);
                properties.put("serverPort", url.Port.ToString());
                //wsdlURL = wsdlDefinition.getDocumentBaseURI();
                WADL2UDDI wadl2UDDI = new WADL2UDDI(clerk, properties);

                businessService businessServices = wadl2UDDI.createBusinessService(new QName("MyWasdl.namespace", "Servicename"), app);

                HashSet<tModel> portTypeTModels = wadl2UDDI.createWADLPortTypeTModels(url.ToString(), app);

                //When parsing a WSDL, there's really two things going on
                //1) convert a bunch of stuff (the portTypes) to tModels
                //2) convert the service definition to a BusinessService

                //Since the service depends on the tModel, we have to save the tModels first
                save_tModel tms = new save_tModel();
                tms.authInfo = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
                HashSet<tModel>.Enumerator it = portTypeTModels.GetEnumerator();
                List<tModel> ts = new List<tModel>();
                while (it.MoveNext())
                {
                    ts.Add(it.Current);
                }
                tModel[] tmodels = ts.ToArray();

                tms.tModel = tmodels;
                if (tms.tModel.Length > 0)
                    //important, you'll need to save your new tModels, or else saving the business/service may fail
                    publish.save_tModel(tms);

                //finaly, we're ready to save all of the services defined in the WSDL
                //again, we're creating a new business, if you have one already, look it up using the Inquiry getBusinessDetails

                // inquiry.find_tModel(new find_tModel

                save_business sb = new save_business();
                //  sb.setAuthInfo(rootAuthToken.getAuthInfo());
                businessEntity be = new businessEntity();
                be.businessKey = (businessServices.businessKey);
                //TODO, use some relevant here
                be.name = new name[] { new name(domain, "en") };

                be.businessServices = new businessService[] { businessServices };
                sb.authInfo = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
                sb.businessEntity = new businessEntity[] { be };
                publish.save_business(sb);
                Console.Out.WriteLine("Saved!");
            }
            catch (Exception ex)
            {
                while (ex != null)
                {
                    System.Console.WriteLine("Error! " + ex.Message);
                    ex = ex.InnerException;
                }
            }
            finally
            {
                if (transport != null && transport is IDisposable)
                {
                    ((IDisposable)transport).Dispose();
                }
                if (clerk != null)
                    clerk.Dispose();
            }
        }
示例#3
0
 /// <remarks/>
 public void save_tModelAsync(save_tModel save_tModel1, object userState)
 {
     if ((this.save_tModelOperationCompleted == null))
     {
         this.save_tModelOperationCompleted = new System.Threading.SendOrPostCallback(this.Onsave_tModelOperationCompleted);
     }
     this.InvokeAsync("save_tModel", new object[] {
             save_tModel1}, this.save_tModelOperationCompleted, userState);
 }
示例#4
0
 /// <remarks/>
 public void save_tModelAsync(save_tModel save_tModel1)
 {
     this.save_tModelAsync(save_tModel1, null);
 }
示例#5
0
 /// <remarks/>
 public System.IAsyncResult Beginsave_tModel(save_tModel save_tModel1, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("save_tModel", new object[] {
             save_tModel1}, callback, asyncState);
 }
示例#6
0
        internal static void Run(string[] args)
        {
            UDDIClient clerkManager = null;
            Transport transport = null;
            UDDIClerk clerk = null;
            try
            {
                clerkManager = new UDDIClient("uddi.xml");

                transport = clerkManager.getTransport("uddiv2");

                UDDI_Security_SoapBinding security = transport.getUDDISecurityService();
                UDDI_Inquiry_SoapBinding inquiry = transport.getUDDIInquiryService();
                UDDI_Publication_SoapBinding publish = transport.getUDDIPublishService();

                clerk = clerkManager.getClerk("uddiv2");

                save_business sb = new save_business();
                get_authToken rq=new get_authToken();
                rq.cred = "username";
                rq.userID="username";
                String token=security.get_authToken(rq).authInfo;
                System.Console.WriteLine("Got an auth token...");
                sb.authInfo = token;
                sb.businessEntity = new businessEntity[1];
                sb.businessEntity[0] = new businessEntity();
                sb.businessEntity[0].name = new name[] { new name("test business from .net via uddi2 translation", "en") };
                sb.businessEntity[0].description = new description[] { new description("a description", "en") };
                businessDetail detail=  publish.save_business(sb);
                System.Console.WriteLine("business saved");
                PrintUDDI<businessDetail> p = new PrintUDDI<businessDetail>();
                Console.Out.WriteLine(p.print(detail));

                save_service ss = new save_service();
                ss.authInfo = token;
                ss.businessService = new businessService[1];
                ss.businessService[0] = new businessService();
                ss.businessService[0].name = new name[] { new name("hello world", "en") };
                ss.businessService[0].businessKey = detail.businessEntity[0].businessKey;
                serviceDetail sd = publish.save_service(ss);
                System.Console.WriteLine("service saved");
                PrintUDDI<serviceDetail> p1 = new PrintUDDI<serviceDetail>();
                Console.Out.WriteLine(p1.print(sd));

                save_binding sbd = new save_binding();
                sbd.authInfo = token;
                sbd.bindingTemplate = new bindingTemplate[1];
                sbd.bindingTemplate[0] = new bindingTemplate();
                sbd.bindingTemplate[0].Item = new accessPoint("http://localhost", "endPoint");
                sbd.bindingTemplate[0].serviceKey = sd.businessService[0].serviceKey;
                bindingDetail bd = publish.save_binding(sbd);
                System.Console.WriteLine("binding saved");
                PrintUDDI<bindingDetail> p2 = new PrintUDDI<bindingDetail>();
                Console.Out.WriteLine(p2.print(bd));

                save_tModel stm = new save_tModel();
                stm.authInfo = token;
                stm.tModel = new tModel[1];
                stm.tModel[0] = new tModel();
                stm.tModel[0].name = new name("a uddiv2 tmodel", "en");
                tModelDetail td = publish.save_tModel(stm);
                System.Console.WriteLine("tModel saved");
                PrintUDDI<tModelDetail> p3 = new PrintUDDI<tModelDetail>();
                Console.Out.WriteLine(p3.print(td));

            }
            catch (Exception ex)
            {
                while (ex != null)
                {
                    System.Console.WriteLine("Error! " + ex.Message);
                    ex = ex.InnerException;
                }
            }
            finally
            {
                if (transport != null && transport is IDisposable)
                {
                    ((IDisposable)transport).Dispose();
                }
                if (clerk != null)
                    clerk.Dispose();
            }
        }
示例#7
0
        public static void main(string[] args)
        {
            Console.Out.Write("Enter WSDL url: >");
            String input = Console.In.ReadLine();
            if (String.IsNullOrEmpty(input))
                input = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL";
            //String wsdlURL = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL";
            //if (String.IsNullOrEmpty(input))
            Uri url = null;
            String host = "localhost";
            int port = 80;
            try
            {
                url = new Uri(input);
                host = url.Host;
                port = url.Port;
            }
            catch { }
            ReadWSDL wsi = new ReadWSDL();
            tDefinitions wsdlDefinition = wsi.readWSDL(input);
            Properties properties1 = new Properties();
            properties1.put("serverName", host);
            properties1.put("businessName", host);
            properties1.put("keyDomain", "uddi:" + host);

            if (port <= 0)
            {
                if (url.ToString().StartsWith("https", StringComparison.CurrentCultureIgnoreCase))
                    port = 443;
                else port = 80;
            }
            properties1.put("serverPort", port.ToString());

            tModel keypart = UDDIClerk.createKeyGenator(host, host + "'s key partition", "en");

            WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizer(), properties1);
            List<tModel> tModels1 = new List<tModel>();

            Dictionary<QName, tPortType> portTypes1 = (Dictionary<QName, tPortType>)wsdlDefinition.getAllPortTypes();
            List<tModel> portTypeTModels1 = wsdl2UDDI.createWSDLPortTypeTModels(input, portTypes1);

            tModels1.AddRange(portTypeTModels1);

            Dictionary<QName, tBinding> allBindings1 = wsdlDefinition.getAllBindings();
            List<tModel> createWSDLBindingTModels1 = wsdl2UDDI.createWSDLBindingTModels(input, allBindings1);

            tModels1.AddRange(createWSDLBindingTModels1);
            businessService[] services = wsdl2UDDI.createBusinessServices(wsdlDefinition);

            save_service ss = new save_service();
            ss.businessService = services;
            Console.Out.WriteLine(new PrintUDDI<save_service>().print(ss));

            save_tModel st = new save_tModel();
            st.tModel = tModels1.ToArray();
            Console.Out.WriteLine(new PrintUDDI<save_tModel>().print(st));

            //save keypart

            //save tmodels
            //save business

            //TODO register the stuff
        }