Ejemplo n.º 1
0
        /// <summary>
        /// Creates the UDDI connection .
        /// </summary>
        /// <param name="UDDIURL">The UDDIURL with uddi authentication.</param>
        /// <param name="UDDICUsername">The UDDIC username.</param>
        /// <param name="UDDICPassword">The UDDIC password.</param>
        /// <returns></returns>
        public static UddiConnection CreateUDDIConnection(string UDDIURL, string UDDICUsername, string UDDICPassword)
        {
            UddiSiteLocation usc = new UddiSiteLocation(
                UDDIURL + "/inquire.asmx",
                UDDIURL + "/publish.asmx",
                UDDIURL + "/extension.asmx",
                "UDDI",
                AuthenticationMode.UddiAuthentication);
            UddiConnection UDDIConnection = new UddiConnection(usc, UDDICUsername, UDDICPassword);

            return(UDDIConnection);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the UDDI connection with windows authentication.
        /// </summary>
        /// <param name="UDDIURL">The UDDIURL.</param>
        /// <returns></returns>
        public static UddiConnection CreateUDDIConnection(string UDDIURL)
        {
            UddiSiteLocation usc = new UddiSiteLocation(
                UDDIURL + "/inquire.asmx",
                UDDIURL + "/publish.asmx",
                UDDIURL + "/extension.asmx",
                "UDDI",
                AuthenticationMode.WindowsAuthentication);
            UddiConnection UDDIConnection = new UddiConnection(usc);

            return(UDDIConnection);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Safely invoke a function that performs a UDDI SOAP call for a business service.
        /// </summary>
        /// <param name="businessService">The business service instance.</param>
        /// <param name="siteLocation">
        /// The site location.
        /// </param>
        /// <param name="loggingData">
        /// Additional strings to be logged.
        /// </param>
        /// <returns>A wrapped version of the function with additional error handling.</returns>
        public static Func <BusinessService> SafeInvoke(
            this Func <BusinessService> businessService,
            UddiSiteLocation siteLocation,
            params string[] loggingData)
        {
            return(() =>
            {
                try
                {
                    return businessService();
                }
                catch (Exception ex)
                {
                    HandleSafeInvokeException(ex, "find business service", siteLocation, loggingData);
                }

                return null;
            });
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles an exception returned from the overloaded SafeInvoke methods.
        /// </summary>
        /// <param name="ex">
        /// The exception.
        /// </param>
        /// <param name="requestType">
        /// The UDDI request type.
        /// </param>
        /// <param name="siteLocation">
        /// The site Location.
        /// </param>
        /// <param name="loggingData">
        /// Additional strings to be logged.
        /// </param>
        private static void HandleSafeInvokeException(Exception ex, string requestType, UddiSiteLocation siteLocation, string[] loggingData)
        {
            // Precondition
            if (UddiEventLog.DefaultLog == null)
            {
                throw new Exception(Resources.ExceptionUDDIDefaultEventLogNotInitialised_);
            }

            ////////// Define pre-condition.
            ////////Contract.Assume(UddiEventLog.DefaultLog != null);

            var exception = ex as ArgumentNullException;

            if (exception != null)
            {
                // A null UDDI connection was passed when trying to invoke a UDDI service.
                UddiEventLog.DefaultLog.WriteUddiConnectionIsNullError(exception, requestType, siteLocation, loggingData);
                return;
            }

            var argEx = ex as ArgumentException;

            if (argEx != null)
            {
                // An unknown message type was passed when trying to invoke a UDDI service.
                UddiEventLog.DefaultLog.WriteUddiUnknownMessageTypeError(argEx, requestType, siteLocation, loggingData);
                return;
            }

            var operationEx = ex as InvalidOperationException;

            if (operationEx != null)
            {
                // A null site location or Inquiry URL was passed when trying to invoke a UDDI service.
                UddiEventLog.DefaultLog.WriteUddiInvalidSiteError(operationEx, requestType, siteLocation, loggingData);
                return;
            }

            var keyEx = ex as InvalidKeyPassedException;

            if (keyEx != null)
            {
                // An invalid key value was passed when trying to invoke a UDDI service.
                UddiEventLog.DefaultLog.WriteUddiInvalidKeyError(keyEx, requestType, siteLocation, loggingData);
                return;
            }

            var unkEx = ex as UnknownErrorException;

            if (unkEx != null)
            {
                // An unexpected error occurred when invoking a UDDI service.
                UddiEventLog.DefaultLog.WriteUddiUnknownError(unkEx, requestType, siteLocation, loggingData);
                return;
            }

            var uddiEx = ex as UddiException;

            if (uddiEx != null)
            {
                // A SOAP fault occurred when invoking a UDDI service.
                UddiEventLog.DefaultLog.WriteUddiError(uddiEx, requestType, siteLocation, loggingData);
                return;
            }

            // An unexpected error occurred when invoking a UDDI service.
            UddiEventLog.DefaultLog.WriteUddiUnexpectedError(ex, requestType, siteLocation, loggingData);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns a UDDI business service for the given site location, treating the
        /// string as a service key.
        /// </summary>
        /// <param name="serviceKey">The service key.</param>
        /// <param name="siteLocation">The UDDI site location.</param>
        /// <returns>The UDDI business service.</returns>
        public static BusinessService UddiBusinessServiceByKey(this string serviceKey, UddiSiteLocation siteLocation)
        {
            // The UDDI business service for the given key.
            Func <BusinessService> uddiBusinessServiceByKey =
                () =>
                new GetServiceDetail(serviceKey)
                .Send(new UddiConnection(siteLocation))
                .BusinessServices
                .FirstOrDefault();

            return(uddiBusinessServiceByKey.SafeInvoke(
                       siteLocation,
                       string.Format("UDDI service key: {0}", serviceKey))());
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns a UDDI business entity for the given site location, treating the
        /// string as a business key.
        /// </summary>
        /// <param name="businessKey">The business entity key.</param>
        /// <param name="siteLocation">The UDDI site location.</param>
        /// <returns>The UDDI business entity.</returns>
        public static BusinessEntity UddiBusinessEntityByKey(this string businessKey, UddiSiteLocation siteLocation)
        {
            // The UDDI business entity for the given key.
            Func <BusinessEntity> uddiBusinessEntityByKey =
                () =>
                new GetBusinessDetail(businessKey)
                .Send(new UddiConnection(siteLocation))
                .BusinessEntities
                .FirstOrDefault();

            return(uddiBusinessEntityByKey.SafeInvoke(
                       siteLocation,
                       string.Format("UDDI business key: {0}", businessKey))());
        }
Ejemplo n.º 7
0
        /// <summary>
        ///		Entry Point
        /// </summary>
        public static void Main( )
        {
            //
            // Attempt to find the first site listed in Active Directory
            //
            UddiSiteLocation location = GetFirstLocation(AuthenticationMode.WindowsAuthentication);

            //
            // Create a location if no location was returned from Active Directory
            // These settings use the default access points for UDDI Services and Windows Authentication
            // TODO: Update with actual servername
            //

            string httpServerName  = "http://servername/uddi/";
            string httpsServerName = "https://servername/uddi/";

            if (null == location)
            {
                location = new UddiSiteLocation(
                    httpServerName + "inquire.asmx",
                    httpsServerName + "publish.asmx",
                    httpServerName + "extension.asmx",
                    "My Site",
                    AuthenticationMode.WindowsAuthentication);
            }

            //
            // Create the connection object.
            //
            _connection = new UddiConnection(location);


            Console.WriteLine("Current Data");

            //
            // Display the current entities owned by this publisher
            //
            DisplayOwnedEntities();

            Console.WriteLine("Saving New Data");

            //
            // Create a new Provider.
            //
            BusinessEntity entity = SaveNewProvider("My New Provider Name", "Description of my new Provider");

            //
            // Add a new Service to that provider
            //
            AddService(entity, "My New Service", "Description for my new Service");

            Console.WriteLine("New Data");

            //
            // Display the currently owned entities again.
            //
            DisplayOwnedEntities();

            Console.WriteLine("Taxonomy Data");

            //
            // Display the taxonomy information for UddiOrgTypes.
            //
            DisplayTaxonomy(CommonCanonical.UddiOrgTypes);
        }
Ejemplo n.º 8
0
        private void WriteUddiError(string messageString, Exception ex, string requestType, UddiSiteLocation siteLocation, string[] loggingData)
        {
            Func <string> flattenLoggingData =
                () =>
                string.Format(
                    "{0}{1}",
                    string.IsNullOrWhiteSpace(loggingData.FirstOrDefault(s => !string.IsNullOrWhiteSpace(s)))
                        ? string.Empty
                        : "\r\n",
                    loggingData.Length > 0
                        ? loggingData.Aggregate(
                        (stringOut, stringItem) =>
                        string.IsNullOrWhiteSpace(stringItem)
                                ? stringOut
                                : string.Format("{0}\r\n{1}", stringOut, stringItem))
                        : string.Empty);

            this.LogErrorMessage(
                string.Format(
                    MessageStrings.UddiErrorTemplate,
                    ex == null ? (object)"<unknown exception>" : ex.WithInnerExceptions(),
                    string.IsNullOrWhiteSpace(messageString) ? (object)"<unknown message>" : messageString,
                    flattenLoggingData(),
                    string.IsNullOrWhiteSpace(requestType) ? (object)"<unknown>" : requestType,
                    siteLocation != null ? siteLocation.AuthenticationMode : (object)"<unknown>",
                    siteLocation != null && !string.IsNullOrWhiteSpace(siteLocation.Description) ? siteLocation.Description : (object)"<unknown>",
                    siteLocation != null && !string.IsNullOrWhiteSpace(siteLocation.InquireUrl) ? siteLocation.InquireUrl : (object)"<unknown>",
                    siteLocation != null && !string.IsNullOrWhiteSpace(siteLocation.PublishUrl) ? siteLocation.PublishUrl : (object)"<unknown>",
                    siteLocation != null && !string.IsNullOrWhiteSpace(siteLocation.ExtensionsUrl) ? siteLocation.ExtensionsUrl : (object)"<unknown>"));
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Log an error for a SOAP fault when invoking a UDDI service.
 /// </summary>
 /// <param name="uddiEx">
 /// The UDDI exception.
 /// </param>
 /// <param name="requestType">
 /// The UDDI request type.
 /// </param>
 /// <param name="siteLocation">
 /// The site location.
 /// </param>
 /// <param name="loggingData">
 /// Additional strings to be logged.
 /// </param>
 public void WriteUddiError(UddiException uddiEx, string requestType, UddiSiteLocation siteLocation, string[] loggingData)
 {
     this.WriteUddiError(MessageStrings.Uddi, uddiEx, requestType, siteLocation, loggingData);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Log an unexpected error when invoking a UDDI service.
 /// </summary>
 /// <param name="ex">
 /// The exception.
 /// </param>
 /// <param name="requestType">
 /// The UDDI request type.
 /// </param>
 /// <param name="siteLocation">
 /// The site location.
 /// </param>
 /// <param name="loggingData">
 /// Additional strings to be logged.
 /// </param>
 public void WriteUddiUnexpectedError(Exception ex, string requestType, UddiSiteLocation siteLocation, params string[] loggingData)
 {
     this.WriteUddiError(MessageStrings.UddiUnexpected, ex, requestType, siteLocation, loggingData);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Log an unexpected error when invoking a UDDI service.
 /// </summary>
 /// <param name="unkEx">
 /// The unknown error exception.
 /// </param>
 /// <param name="requestType">
 /// The UDDI request type.
 /// </param>
 /// <param name="siteLocation">
 /// The site location.
 /// </param>
 /// <param name="loggingData">
 /// Additional strings to be logged.
 /// </param>
 public void WriteUddiUnknownError(UnknownErrorException unkEx, string requestType, UddiSiteLocation siteLocation, params string[] loggingData)
 {
     this.WriteUddiError(MessageStrings.UddiUnknown, unkEx, requestType, siteLocation, loggingData);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Log an error for an invalid key value passed when trying to invoke a UDDI service.
 /// </summary>
 /// <param name="keyEx">
 /// The invalid key exception.
 /// </param>
 /// <param name="requestType">
 /// The UDDI request type.
 /// </param>
 /// <param name="siteLocation">
 /// The site location.
 /// </param>
 /// <param name="loggingData">
 /// Additional strings to be logged.
 /// </param>
 public void WriteUddiInvalidKeyError(InvalidKeyPassedException keyEx, string requestType, UddiSiteLocation siteLocation, params string[] loggingData)
 {
     this.WriteUddiError(MessageStrings.UddiInvalid, keyEx, requestType, siteLocation, loggingData);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Log an error for a null site location or Inquiry URL passed when trying to invoke a UDDI service.
 /// </summary>
 /// <param name="operationEx">
 /// The invalid operation exception.
 /// </param>
 /// <param name="requestType">
 /// The UDDI request type.
 /// </param>
 /// <param name="siteLocation">
 /// The site location.
 /// </param>
 /// <param name="loggingData">
 /// Additional strings to be logged.
 /// </param>
 public void WriteUddiInvalidSiteError(InvalidOperationException operationEx, string requestType, UddiSiteLocation siteLocation, params string[] loggingData)
 {
     this.WriteUddiError(MessageStrings.UddiInvalidSiteError, operationEx, requestType, siteLocation, loggingData);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Log an error for an unknown message type passed when trying to invoke a UDDI service.
 /// </summary>
 /// <param name="argEx">
 /// The argument exception.
 /// </param>
 /// <param name="requestType">
 /// The UDDI request type.
 /// </param>
 /// <param name="siteLocation">
 /// The site location.
 /// </param>
 /// <param name="loggingData">
 /// Additional strings to be logged.
 /// </param>
 public void WriteUddiUnknownMessageTypeError(ArgumentException argEx, string requestType, UddiSiteLocation siteLocation, params string[] loggingData)
 {
     this.WriteUddiError(MessageStrings.UddiUnknownMessageType, argEx, requestType, siteLocation, loggingData);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Log an error for a null UDDI connection passed when trying to invoke a UDDI service.
 /// </summary>
 /// <param name="argEx">
 /// The null argument exception.
 /// </param>
 /// <param name="requestType">
 /// The UDDI request type.
 /// </param>
 /// <param name="siteLocation">
 /// The site location.
 /// </param>
 /// <param name="loggingData">
 /// Additional strings to be logged.
 /// </param>
 public void WriteUddiConnectionIsNullError(ArgumentNullException argEx, string requestType, UddiSiteLocation siteLocation, params string[] loggingData)
 {
     this.WriteUddiError(MessageStrings.UddiConnectionIsNull, argEx, requestType, siteLocation, loggingData);
 }