public void Create(string FilePath, string DiscoRef)
 {
     try
     {
         if (!FilePath.EndsWith("/", StringComparison.Ordinal) && !FilePath.EndsWith(@"\", StringComparison.Ordinal))
         {
             FilePath = FilePath + @"\";
         }
         if (!File.Exists(FilePath + DiscoRef))
         {
             new SecurityPermission(SecurityPermissionFlag.RemotingConfiguration).Demand();
             string str = "<?xml version=\"1.0\" ?>\n";
             str = str + "<discovery xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://schemas.xmlsoap.org/disco/\">\n" + "</discovery>\n";
             FileStream   stream = new FileStream(FilePath + DiscoRef, FileMode.Create);
             StreamWriter writer = new StreamWriter(stream);
             writer.Write(str);
             writer.Close();
             stream.Close();
         }
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         ComSoapPublishError.Report(exception.ToString());
     }
 }
Exemple #2
0
 public void Generate()
 {
     try
     {
         if ((this.threadtoken != null) && !System.EnterpriseServices.Internal.NativeMethods.SetThreadToken(IntPtr.Zero, this.threadtoken))
         {
             throw new COMException(Resource.FormatString("Err_SetThreadToken"), Marshal.GetHRForLastWin32Error());
         }
         if (this.wsdlurl.Length > 0)
         {
             Stream    outputStream      = new MemoryStream();
             ArrayList outCodeStreamList = new ArrayList();
             MetaData.RetrieveSchemaFromUrlToStream(this.wsdlurl, outputStream);
             outputStream.Position = 0L;
             MetaData.ConvertSchemaStreamToCodeSourceStream(true, this.pathname, outputStream, outCodeStreamList);
             MetaData.ConvertCodeSourceStreamToAssemblyFile(outCodeStreamList, this.filename, null);
         }
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         ComSoapPublishError.Report(exception.ToString());
         this.SavedException  = exception;
         this.ExceptionThrown = true;
     }
 }
 public void DeleteVirtualRootEx(string rootWebServer, string inBaseUrl, string inVirtualRoot)
 {
     try
     {
         try
         {
             new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
         }
         catch (SecurityException)
         {
             ComSoapPublishError.Report(Resource.FormatString("Soap_SecurityFailure"));
             throw;
         }
         if ((inBaseUrl.Length > 0) || (inVirtualRoot.Length > 0))
         {
             int    length      = rootWebServer.Length;
             string inProtocol  = "";
             string baseUrl     = "";
             string virtualRoot = "";
             SoapServerInfo.ParseUrl(inBaseUrl, inVirtualRoot, inProtocol, out baseUrl, out virtualRoot);
         }
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         ComSoapPublishError.Report(Resource.FormatString("Soap_VRootDirectoryDeletionFailed"));
         throw;
     }
 }
Exemple #4
0
        internal static string GetCachePath(bool CreateDir)
        {
            StringBuilder lpBuf = new StringBuilder(0x400, 0x400);
            uint          uSize = 0x400;

            Publish.GetSystemDirectory(lpBuf, uSize);
            string path = lpBuf.ToString() + @"\com\SOAPCache\";

            if (CreateDir)
            {
                try
                {
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                }
                catch (Exception exception)
                {
                    if ((exception is NullReferenceException) || (exception is SEHException))
                    {
                        throw;
                    }
                    ComSoapPublishError.Report(exception.ToString());
                }
            }
            return(path);
        }
 public void Delete(string RootWeb, string PhysicalDirectory, string VirtualDirectory, out string Error)
 {
     Error = "";
     try
     {
         new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
         if (this.CheckIfExists(RootWeb, VirtualDirectory))
         {
             DirectoryEntry entry = new DirectoryEntry(RootWeb);
             new DirectoryEntry(RootWeb + "/" + VirtualDirectory).Invoke("AppDelete", null);
             object[] args = new object[] { "IIsWebVirtualDir", VirtualDirectory };
             entry.Invoke("Delete", args);
             Directory.Delete(PhysicalDirectory, true);
         }
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         Error = exception.ToString();
         ComSoapPublishError.Report(exception.ToString());
     }
 }
 public void DeleteVirtualRoot(string RootWebServer, string FullUrl, out string Error)
 {
     Error = "";
     try
     {
         if (FullUrl.Length > 0)
         {
             new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
             int    length      = RootWebServer.Length;
             string baseUrl     = "";
             string virtualRoot = "";
             ParseUrl(FullUrl, out baseUrl, out virtualRoot);
             if (virtualRoot.Length > 0)
             {
                 string physicalPath = "";
                 string binDirectory = "";
                 this.GetVRootPhysicalPath(virtualRoot, out physicalPath, out binDirectory, false);
                 if (physicalPath.Length <= 0)
                 {
                 }
             }
         }
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         Error = exception.ToString();
         ComSoapPublishError.Report(exception.ToString());
     }
 }
Exemple #7
0
 public void Create(string FilePath, string VirtualRoot, string PageName, string DiscoRef)
 {
     try
     {
         if (!FilePath.EndsWith("/", StringComparison.Ordinal) && !FilePath.EndsWith(@"\", StringComparison.Ordinal))
         {
             FilePath = FilePath + @"\";
         }
         if (!File.Exists(FilePath + PageName))
         {
             new SecurityPermission(SecurityPermissionFlag.RemotingConfiguration).Demand();
             string str  = FilePath + "web.config";
             string str2 = "<%@ Import Namespace=\"System.Collections\" %>\r\n";
             str2 = ((((((((((((((((((((((((((((((((((((((((((((((((((str2 + "<%@ Import Namespace=\"System.IO\" %>\r\n") + "<%@ Import Namespace=\"System.Xml.Serialization\" %>\r\n" + "<%@ Import Namespace=\"System.Xml\" %>\r\n") + "<%@ Import Namespace=\"System.Xml.Schema\" %>\r\n" + "<%@ Import Namespace=\"System.Web.Services.Description\" %>\r\n") + "<%@ Import Namespace=\"System\" %>\r\n" + "<%@ Import Namespace=\"System.Globalization\" %>\r\n") + "<%@ Import Namespace=\"System.Resources\" %>\r\n" + "<%@ Import Namespace=\"System.Diagnostics\" %>\r\n") + "<html>\r\n" + "<script language=\"C#\" runat=\"server\">\r\n") + "    string soapNs = \"http://schemas.xmlsoap.org/soap/envelope/\";\r\n" + "    string soapEncNs = \"http://schemas.xmlsoap.org/soap/encoding/\";\r\n") + "    string urtNs = \"urn:schemas-microsoft-com:urt-types\";\r\n" + "    string wsdlNs = \"http://schemas.xmlsoap.org/wsdl/\";\r\n") + "    string VRoot = \"" + VirtualRoot + "\";\r\n") + "    string ServiceName() { return VRoot; }\r\n" + "\r\n") + "   XmlNode GetNextNamedSiblingNode(XmlNode inNode, string name)\r\n" + "    {\r\n") + "       if (inNode == null ) return inNode;\r\n" + "      if (inNode.Name == name) return inNode;\r\n") + "       XmlNode newNode = inNode.NextSibling;\r\n" + "       if (newNode == null) return newNode;\r\n") + "       if (newNode.Name == name ) return newNode;\r\n" + "       bool found = false;\r\n") + "       while (!found)\r\n" + "       {\r\n") + "           XmlNode oldNode = newNode;\r\n" + "           newNode = oldNode.NextSibling;\r\n") + "           if (null == newNode || newNode == oldNode)\r\n" + "           {\r\n") + "               newNode = null;\r\n" + "               break;\r\n") + "           }\r\n" + "           if (newNode.Name == name) found = true;\r\n") + "       }\r\n" + "       return newNode;\r\n") + "   }\r\n" + "\r\n") + "   string GetNodes()\r\n" + "   {\r\n") + "       string retval = \"\";\r\n" + "       XmlDocument configXml = new XmlDocument();\r\n") + "      configXml.Load(@\"" + str + "\");\r\n") + "       XmlNode node= configXml.DocumentElement;\r\n" + "        node = GetNextNamedSiblingNode(node,\"configuration\");\r\n") + "        node = GetNextNamedSiblingNode(node.FirstChild, \"system.runtime.remoting\");\r\n" + "        node = GetNextNamedSiblingNode(node.FirstChild, \"application\");\r\n") + "        node = GetNextNamedSiblingNode(node.FirstChild, \"service\");\r\n" + "        node = GetNextNamedSiblingNode(node.FirstChild, \"wellknown\");\r\n") + "       while (node != null)\r\n" + "       {\r\n") + "           XmlNode attribType = node.Attributes.GetNamedItem(\"objectUri\");\r\n" + "           retval += \"<a href=\" + attribType.Value + \"?WSDL>\" + attribType.Value +\"?WSDL</a><br><br>\";\r\n") + "           node = GetNextNamedSiblingNode(node.NextSibling, \"wellknown\");\r\n" + "       }\r\n") + "        return retval;\r\n" + "    }\r\n") + "\r\n" + "</script>\r\n") + "<title><% = ServiceName() %></title>\r\n" + "<head>\r\n") + "<link type='text/xml' rel='alternate' href='" + DiscoRef + "' />\r\n") + "\r\n") + "   <style type=\"text/css\">\r\n" + " \r\n") + "       BODY { color: #000000; background-color: white; font-family: \"Verdana\"; margin-left: 0px; margin-top: 0px; }\r\n" + "       #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; }\r\n") + "       A:link { color: #336699; font-weight: bold; text-decoration: underline; }\r\n" + "       A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; }\r\n") + "       A:active { color: #336699; font-weight: bold; text-decoration: underline; }\r\n" + "       A:hover { color: cc3300; font-weight: bold; text-decoration: underline; }\r\n") + "       P { color: #000000; margin-top: 0px; margin-bottom: 12px; font-family: \"Verdana\"; }\r\n" + "       pre { background-color: #e5e5cc; padding: 5px; font-family: \"Courier New\"; font-size: x-small; margin-top: -5px; border: 1px #f0f0e0 solid; }\r\n") + "       td { color: #000000; font-family: verdana; font-size: .7em; }\r\n" + "       h2 { font-size: 1.5em; font-weight: bold; margin-top: 25px; margin-bottom: 10px; border-top: 1px solid #003366; margin-left: -15px; color: #003366; }\r\n") + "       h3 { font-size: 1.1em; color: #000000; margin-left: -15px; margin-top: 10px; margin-bottom: 10px; }\r\n" + "       ul, ol { margin-top: 10px; margin-left: 20px; }\r\n") + "       li { margin-top: 10px; color: #000000; }\r\n" + "       font.value { color: darkblue; font: bold; }\r\n") + "       font.key { color: darkgreen; font: bold; }\r\n" + "       .heading1 { color: #ffffff; font-family: \"Tahoma\"; font-size: 26px; font-weight: normal; background-color: #003366; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 10px; padding-bottom: 3px; padding-left: 15px; width: 105%; }\r\n") + "       .button { background-color: #dcdcdc; font-family: \"Verdana\"; font-size: 1em; border-top: #cccccc 1px solid; border-bottom: #666666 1px solid; border-left: #cccccc 1px solid; border-right: #666666 1px solid; }\r\n" + "       .frmheader { color: #000000; background: #dcdcdc; font-family: \"Verdana\"; font-size: .7em; font-weight: normal; border-bottom: 1px solid #dcdcdc; padding-top: 2px; padding-bottom: 2px; }\r\n") + "       .frmtext { font-family: \"Verdana\"; font-size: .7em; margin-top: 8px; margin-bottom: 0px; margin-left: 32px; }\r\n" + "       .frmInput { font-family: \"Verdana\"; font-size: 1em; }\r\n") + "       .intro { margin-left: -15px; }\r\n" + " \r\n") + "    </style>\r\n" + "\r\n") + "</head>\r\n" + "<body>\r\n") + "<p class=\"heading1\"><% = ServiceName() %></p><br>\r\n" + "<% = GetNodes() %>\r\n") + "</body>\r\n" + "</html>\r\n";
             FileStream   stream = new FileStream(FilePath + PageName, FileMode.Create);
             StreamWriter writer = new StreamWriter(stream);
             writer.Write(str2);
             writer.Close();
             stream.Close();
         }
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         ComSoapPublishError.Report(exception.ToString());
     }
 }
 public void GacRemove(string AssemblyPath)
 {
     try
     {
         new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
         string         gacName        = new AssemblyManager().GetGacName(AssemblyPath);
         IAssemblyCache ppAsmCache     = null;
         int            num            = CreateAssemblyCache(out ppAsmCache, 0);
         uint           pulDisposition = 0;
         if (num == 0)
         {
             num = ppAsmCache.UninstallAssembly(0, gacName, IntPtr.Zero, out pulDisposition);
         }
         if (num != 0)
         {
             string str2 = Resource.FormatString("Soap_GacRemoveFailed");
             ComSoapPublishError.Report(str2 + " " + AssemblyPath + " " + gacName);
         }
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         ComSoapPublishError.Report(exception.ToString());
         throw;
     }
 }
        public object CreateFromMailbox(string Mailbox, string Mode)
        {
            string s = Resource.FormatString("Soap_SmtpNotImplemented");

            ComSoapPublishError.Report(s);
            throw new COMException(s);
        }
        public static string GetClientPhysicalPath(bool CreateDir)
        {
            StringBuilder lpBuf = new StringBuilder(0x400, 0x400);
            uint          uSize = 0x400;

            GetSystemDirectory(lpBuf, uSize);
            string path = lpBuf.ToString() + @"\com\SOAPAssembly\";

            if (CreateDir)
            {
                try
                {
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                }
                catch (Exception exception)
                {
                    if ((exception is NullReferenceException) || (exception is SEHException))
                    {
                        throw;
                    }
                    path = string.Empty;
                    ComSoapPublishError.Report(exception.ToString());
                }
            }
            return(path);
        }
Exemple #11
0
        public string GenerateSigned(string strSrcTypeLib, string outPath, bool InstallGac, out string Error)
        {
            string str = "";

            this._signed = true;
            try
            {
                Error = "";
                string pwzKeyContainer = strSrcTypeLib;
                int    dwFlags         = 0;
                IntPtr zero            = IntPtr.Zero;
                int    pcbKeyBlob      = 0;
                Microsoft.Runtime.Hosting.StrongNameHelpers.StrongNameKeyGen(pwzKeyContainer, dwFlags, out zero, out pcbKeyBlob);
                byte[] destination = new byte[pcbKeyBlob];
                Marshal.Copy(zero, destination, 0, pcbKeyBlob);
                Microsoft.Runtime.Hosting.StrongNameHelpers.StrongNameFreeBuffer(zero);
                StrongNameKeyPair keyPair = new StrongNameKeyPair(destination);
                str = this.GenerateMetaData(strSrcTypeLib, outPath, null, keyPair);
            }
            catch (Exception exception)
            {
                if ((exception is NullReferenceException) || (exception is SEHException))
                {
                    throw;
                }
                Error = exception.ToString();
                ComSoapPublishError.Report(Error);
            }
            return(str);
        }
 private void PrivateGacInstall(string AssemblyPath)
 {
     try
     {
         new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
         IAssemblyCache ppAsmCache = null;
         int            num        = CreateAssemblyCache(out ppAsmCache, 0);
         if (num == 0)
         {
             num = ppAsmCache.InstallAssembly(0, AssemblyPath, IntPtr.Zero);
         }
         if (num != 0)
         {
             ComSoapPublishError.Report(Resource.FormatString("Soap_GacInstallFailed") + " " + AssemblyPath);
         }
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         ComSoapPublishError.Report(exception.ToString());
         throw;
     }
 }
Exemple #13
0
        public void Generate()
        {
            try
            {
                if (threadtoken != IntPtr.Zero)
                {
                    if (!NativeMethods.SetThreadToken(IntPtr.Zero, threadtoken))
                    {
                        throw new COMException(Resource.FormatString("Err_SetThreadToken"), Marshal.GetHRForLastWin32Error());
                    }
                }

                if (wsdlurl.Length <= 0)
                {
                    return;
                }
                Stream    oSchemaStream   = new MemoryStream();
                ArrayList aCodeStreamList = new ArrayList();
                MetaData.RetrieveSchemaFromUrlToStream(wsdlurl, oSchemaStream);
                oSchemaStream.Position = 0;
                MetaData.ConvertSchemaStreamToCodeSourceStream(true, pathname, oSchemaStream, aCodeStreamList);
                MetaData.ConvertCodeSourceStreamToAssemblyFile(aCodeStreamList, filename, null);
            }
            catch (Exception e)
            {
                ComSoapPublishError.Report(e.ToString());
                SavedException  = e;
                ExceptionThrown = true;
                throw;
            }
        }
Exemple #14
0
        public void Run(string WsdlUrl, string FileName, string PathName)
        {
            try
            {
                if (WsdlUrl.Length <= 0 || FileName.Length <= 0)
                {
                    return;
                }
                wsdlurl  = WsdlUrl;
                filename = PathName + FileName;
                pathname = PathName;

                NativeMethods.OpenThreadToken(NativeMethods.GetCurrentThread(), TOKEN_IMPERSONATE, true, ref threadtoken);

                int err = Marshal.GetLastWin32Error();
                if (err != Util.ERROR_SUCCESS && err != Util.ERROR_NO_TOKEN)
                {
                    throw new COMException(Resource.FormatString("Err_OpenThreadToken"), Marshal.GetHRForLastWin32Error());
                }

                thisthread.Start();
                thisthread.Join();

                if (ExceptionThrown == true)
                {
                    throw SavedException;
                }
            }
            catch (Exception e)
            {
                ComSoapPublishError.Report(e.ToString());
                throw;
            }
        }
Exemple #15
0
        internal bool CompareToCache(string AssemblyPath, string srcTypeLib)
        {
            bool flag = true;

            try
            {
                string cacheName = CacheInfo.GetCacheName(AssemblyPath, srcTypeLib);
                if (!File.Exists(AssemblyPath))
                {
                    return(false);
                }
                if (!File.Exists(cacheName))
                {
                    return(false);
                }
            }
            catch (Exception exception)
            {
                if ((exception is NullReferenceException) || (exception is SEHException))
                {
                    throw;
                }
                flag = false;
                ComSoapPublishError.Report(exception.ToString());
            }
            return(flag);
        }
 public void DeleteMailBox(string RootMailServer, string MailBox, out string Error)
 {
     Error = "";
     new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
     ComSoapPublishError.Report(Resource.FormatString("Soap_SmtpNotImplemented"));
     int length = MailBox.Length;
 }
 private bool WriteFile(string PhysicalDirectory, string FilePrefix, string FileSuffix)
 {
     try
     {
         string path = PhysicalDirectory + FilePrefix + FileSuffix;
         if (File.Exists(path))
         {
             File.Delete(path);
         }
         FileStream   stream = new FileStream(path, FileMode.Create);
         StreamWriter writer = new StreamWriter(stream);
         writer.Write(this.webconfig);
         writer.Close();
         stream.Close();
         return(true);
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         ComSoapPublishError.Report(exception.ToString());
         return(false);
     }
 }
Exemple #18
0
 internal static void AddComponent(string filePath, string assemblyName, string typeName, string progId, string assemblyFile, string wkoMode, bool wellKnown, bool clientActivated)
 {
     try
     {
         AssemblyManager manager   = new AssemblyManager();
         string          str       = typeName + ", " + manager.GetFullName(assemblyFile);
         string          str2      = typeName + ", " + assemblyName;
         XmlDocument     configXml = new XmlDocument();
         configXml.Load(filePath);
         XmlNode documentElement = configXml.DocumentElement;
         documentElement = FindOrCreateElement(configXml, documentElement, "system.runtime.remoting");
         documentElement = FindOrCreateElement(configXml, documentElement, "application");
         documentElement = FindOrCreateElement(configXml, documentElement, "service");
         XmlNodeList list = documentElement.SelectNodes("descendant::*[attribute::type='" + str2 + "']");
         while ((list != null) && (list.Count > 0))
         {
             XmlNode oldChild = list.Item(0);
             if (oldChild.ParentNode != null)
             {
                 oldChild.ParentNode.RemoveChild(oldChild);
                 list = documentElement.SelectNodes("descendant::*[attribute::type='" + str2 + "']");
             }
         }
         list = documentElement.SelectNodes("descendant::*[attribute::type='" + str + "']");
         while ((list != null) && (list.Count > 0))
         {
             XmlNode node3 = list.Item(0);
             if (node3.ParentNode != null)
             {
                 node3.ParentNode.RemoveChild(node3);
                 list = documentElement.SelectNodes("descendant::*[attribute::type='" + str + "']");
             }
         }
         if (wellKnown)
         {
             XmlElement newChild = configXml.CreateElement("wellknown");
             newChild.SetAttribute("mode", wkoMode);
             newChild.SetAttribute("type", str);
             newChild.SetAttribute("objectUri", progId + ".soap");
             documentElement.AppendChild(newChild);
         }
         if (clientActivated)
         {
             XmlElement element2 = configXml.CreateElement("activated");
             element2.SetAttribute("type", str2);
             documentElement.AppendChild(element2);
         }
         configXml.Save(filePath);
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         ComSoapPublishError.Report(Resource.FormatString("Soap_ConfigAdditionFailure") + " " + exception.Message);
         throw;
     }
 }
 public void AddElement(string FilePath, string AssemblyName, string TypeName, string ProgId, string WkoMode, out string Error)
 {
     Error = "";
     try
     {
         new SecurityPermission(SecurityPermissionFlag.RemotingConfiguration).Demand();
         string      str      = TypeName + ", " + AssemblyName;
         XmlDocument document = new XmlDocument();
         document.Load(FilePath);
         XmlNode documentElement = document.DocumentElement;
         while (documentElement.Name != "configuration")
         {
             documentElement = documentElement.NextSibling;
         }
         documentElement = documentElement.FirstChild;
         while (documentElement.Name != "system.runtime.remoting")
         {
             documentElement = documentElement.NextSibling;
         }
         documentElement = documentElement.FirstChild;
         while (documentElement.Name != "application")
         {
             documentElement = documentElement.NextSibling;
         }
         documentElement = documentElement.FirstChild;
         while (documentElement.Name != "service")
         {
             documentElement = documentElement.NextSibling;
         }
         XmlNodeList list = documentElement.SelectNodes("descendant::*[attribute::type='" + str + "']");
         while ((list != null) && (list.Count > 0))
         {
             XmlNode oldChild = list.Item(0);
             if (oldChild.ParentNode != null)
             {
                 oldChild.ParentNode.RemoveChild(oldChild);
                 list = documentElement.SelectNodes("descendant::*[attribute::type='" + str + "']");
             }
         }
         XmlElement newChild = document.CreateElement("", "wellknown", "");
         newChild.SetAttribute("mode", WkoMode);
         newChild.SetAttribute("type", str);
         newChild.SetAttribute("objectUri", ProgId + ".soap");
         documentElement.AppendChild(newChild);
         XmlElement element2 = document.CreateElement("", "activated", "");
         element2.SetAttribute("type", str);
         documentElement.AppendChild(element2);
         document.Save(FilePath);
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         Error = exception.ToString();
         ComSoapPublishError.Report(exception.ToString());
     }
 }
 private void ThrowHelper(string messageId, Exception e)
 {
     ComSoapPublishError.Report(Resource.FormatString(messageId));
     if (e != null)
     {
         throw e;
     }
 }
Exemple #21
0
        /// <include file='doc\factory.uex' path='docs/doc[@for="ClrObjectFactory.CreateFromMailbox"]/*' />
        public object CreateFromMailbox(string Mailbox, string Mode)
        {
            // TODO: Implement SMTP support
            string error = Resource.FormatString("Soap_SmtpNotImplemented");

            ComSoapPublishError.Report(error);
            throw new COMException(error);
        }
 public static bool Write(string DestinationDirectory, string VRoot, string BaseUrl, string AssemblyName, string TypeName, string ProgId, string Mode, string Transport)
 {
     try
     {
         new SecurityPermission(SecurityPermissionFlag.RemotingConfiguration).Demand();
         string str = "<configuration>\r\n";
         str = str + "  <system.runtime.remoting>\r\n" + "    <application>\r\n";
         string str2 = BaseUrl;
         if ((str2.Length > 0) && !str2.EndsWith("/", StringComparison.Ordinal))
         {
             str2 = str2 + "/";
         }
         str2 = str2 + VRoot;
         str = str + "      <client url=\"" + str2 + "\">\r\n";
         if ((Mode.Length <= 0) || ("WELLKNOWNOBJECT" == Mode.ToUpper(CultureInfo.InvariantCulture)))
         {
             string str4 = str + "        ";
             str = str4 + "<wellknown type=\"" + TypeName + ", " + AssemblyName + "\" url=\"" + str2;
             if (!str2.EndsWith("/", StringComparison.Ordinal))
             {
                 str = str + "/";
             }
             str = str + ProgId + ".soap\" />\r\n";
         }
         else
         {
             string str5 = str + "        ";
             str = str5 + "<activated type=\"" + TypeName + ", " + AssemblyName + "\"/>\r\n";
         }
         str = (str + "      </client>\r\n" + "    </application>\r\n") + "  </system.runtime.remoting>\r\n" + "</configuration>\r\n";
         string path = DestinationDirectory;
         if ((path.Length > 0) && !path.EndsWith(@"\", StringComparison.Ordinal))
         {
             path = path + @"\";
         }
         path = path + TypeName + ".config";
         if (File.Exists(path))
         {
             File.Delete(path);
         }
         FileStream stream = new FileStream(path, FileMode.Create);
         StreamWriter writer = new StreamWriter(stream);
         writer.Write(str);
         writer.Close();
         stream.Close();
         return true;
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         ComSoapPublishError.Report(exception.ToString());
         return false;
     }
 }
Exemple #23
0
        /// <include file='doc\SoapClientImport.uex' path='docs/doc[@for="SoapClientImport.ProcessClientTlbEx"]/*' />
        public void ProcessClientTlbEx(
            string progId,
            string virtualRoot,
            string baseUrl,
            string authentication,
            string assemblyName,
            string typeName
            )
        {
            try
            {
                SecurityPermission sp = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
                sp.Demand();
            }
            catch (Exception e)
            {
                if (e.GetType() == typeof(System.Security.SecurityException))
                {
                    string Error = Resource.FormatString("Soap_SecurityFailure");
                    ComSoapPublishError.Report(Error);
                }
                throw;
            }

            try
            {
                Platform.Assert(Platform.Whistler, "SoapClientImport.ProcessClientTlbEx");
                //if ProgId is an empty string, it means it does not go in the configuration file
                string ClientDir = GetClientPhysicalPath(true);
                if (progId.Length > 0)
                {
                    // write to the client configuration file
                    Uri    baseUri = new Uri(baseUrl);
                    Uri    fullUri = new Uri(baseUri, virtualRoot);
                    string auth    = authentication;
                    if (auth.Length <= 0 && fullUri.Scheme.ToLower(CultureInfo.InvariantCulture) == "https")
                    {
                        auth = "Windows";
                    }

                    SoapClientConfig.Write(
                        ClientDir,
                        fullUri.AbsoluteUri,
                        assemblyName,
                        typeName,
                        progId,
                        auth
                        );
                }
            }
            catch
            {
                string Error = Resource.FormatString("Soap_ClientConfigAddFailure");
                ComSoapPublishError.Report(Error);
                throw;
            }
        }
 public void CreateMailBox(string RootMailServer, string MailBox, out string SmtpName, out string Domain, out string PhysicalPath, out string Error)
 {
     SmtpName     = "";
     Domain       = "";
     PhysicalPath = "";
     Error        = "";
     new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
     ComSoapPublishError.Report(Resource.FormatString("Soap_SmtpNotImplemented"));
     int length = MailBox.Length;
 }
 public void ProcessClientTlb(string ProgId, string SrcTlbPath, string PhysicalPath, string VRoot, string BaseUrl, string Mode, string Transport, out string AssemblyName, out string TypeName, out string Error)
 {
     AssemblyName = "";
     TypeName     = "";
     Error        = "";
     try
     {
         new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
         string clientPhysicalPath = GetClientPhysicalPath(true);
         if (!SrcTlbPath.ToLower(CultureInfo.InvariantCulture).EndsWith("mscoree.dll", StringComparison.Ordinal) && (SrcTlbPath.Length > 0))
         {
             AssemblyName = new GenerateMetadata().Generate(SrcTlbPath, clientPhysicalPath);
             if (ProgId.Length > 0)
             {
                 TypeName = this.GetTypeNameFromProgId(clientPhysicalPath + AssemblyName + ".dll", ProgId);
             }
         }
         else if (ProgId.Length > 0)
         {
             string      g    = (string)Registry.ClassesRoot.OpenSubKey(ProgId + @"\CLSID").GetValue("");
             RegistryKey key2 = Registry.ClassesRoot.OpenSubKey(@"CLSID\{" + new Guid(g) + @"}\InprocServer32");
             AssemblyName = (string)key2.GetValue("Assembly");
             int index = AssemblyName.IndexOf(",");
             if (index > 0)
             {
                 AssemblyName = AssemblyName.Substring(0, index);
             }
             TypeName = (string)key2.GetValue("Class");
         }
         if (ProgId.Length > 0)
         {
             Uri baseUri = new Uri(BaseUrl);
             Uri uri2    = new Uri(baseUri, VRoot);
             if (uri2.Scheme.ToLower(CultureInfo.InvariantCulture) == "https")
             {
                 string authentication = "Windows";
                 SoapClientConfig.Write(clientPhysicalPath, uri2.AbsoluteUri, AssemblyName, TypeName, ProgId, authentication);
             }
             else
             {
                 ClientRemotingConfig.Write(clientPhysicalPath, VRoot, BaseUrl, AssemblyName, TypeName, ProgId, Mode, Transport);
             }
         }
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         Error = exception.ToString();
         ComSoapPublishError.Report(Error);
     }
 }
Exemple #26
0
 internal static void DeleteComponent(string filePath, string assemblyName, string typeName, string progId, string assemblyFile)
 {
     try
     {
         AssemblyManager manager   = new AssemblyManager();
         string          str       = typeName + ", " + manager.GetFullName(assemblyFile);
         string          str2      = typeName + ", " + assemblyName;
         XmlDocument     configXml = new XmlDocument();
         configXml.Load(filePath);
         XmlNode documentElement = configXml.DocumentElement;
         documentElement = FindOrCreateElement(configXml, documentElement, "system.runtime.remoting");
         documentElement = FindOrCreateElement(configXml, documentElement, "application");
         documentElement = FindOrCreateElement(configXml, documentElement, "service");
         XmlNodeList list = documentElement.SelectNodes("descendant::*[attribute::type='" + str2 + "']");
         while ((list != null) && (list.Count > 0))
         {
             XmlNode oldChild = list.Item(0);
             if (oldChild.ParentNode != null)
             {
                 oldChild.ParentNode.RemoveChild(oldChild);
                 list = documentElement.SelectNodes("descendant::*[attribute::type='" + str2 + "']");
             }
         }
         list = documentElement.SelectNodes("descendant::*[attribute::type='" + str + "']");
         while ((list != null) && (list.Count > 0))
         {
             XmlNode node3 = list.Item(0);
             if (node3.ParentNode != null)
             {
                 node3.ParentNode.RemoveChild(node3);
                 list = documentElement.SelectNodes("descendant::*[attribute::type='" + str + "']");
             }
         }
         configXml.Save(filePath);
     }
     catch (DirectoryNotFoundException)
     {
     }
     catch (FileNotFoundException)
     {
     }
     catch (RegistrationException)
     {
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         ComSoapPublishError.Report(Resource.FormatString("Soap_ConfigDeletionFailure") + " " + exception.Message);
         throw;
     }
 }
 public void Present()
 {
     try
     {
         new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
     }
     catch (SecurityException)
     {
         ComSoapPublishError.Report(Resource.FormatString("Soap_SecurityFailure"));
         throw;
     }
 }
 public void AddElement(string FilePath, string SoapPageRef)
 {
     try
     {
         new SecurityPermission(SecurityPermissionFlag.RemotingConfiguration).Demand();
         XmlDocument document = new XmlDocument();
         document.Load(FilePath);
         XmlNode documentElement = document.DocumentElement;
         while (documentElement.Name != "discovery")
         {
             documentElement = documentElement.NextSibling;
         }
         XmlNodeList list = documentElement.SelectNodes("descendant::*[attribute::ref='" + SoapPageRef + "']");
         while ((list != null) && (list.Count > 0))
         {
             XmlNode oldChild = list.Item(0);
             if (oldChild.ParentNode != null)
             {
                 oldChild.ParentNode.RemoveChild(oldChild);
                 list = documentElement.SelectNodes("descendant::*[attribute::ref='" + SoapPageRef + "']");
             }
         }
         list = documentElement.SelectNodes("descendant::*[attribute::address='" + SoapPageRef + "']");
         while ((list != null) && (list.Count > 0))
         {
             XmlNode node3 = list.Item(0);
             if (node3.ParentNode != null)
             {
                 node3.ParentNode.RemoveChild(node3);
                 list = documentElement.SelectNodes("descendant::*[attribute::address='" + SoapPageRef + "']");
             }
         }
         XmlElement newChild = document.CreateElement("", "contractRef", "");
         newChild.SetAttribute("ref", SoapPageRef);
         newChild.SetAttribute("docRef", SoapPageRef);
         newChild.SetAttribute("xmlns", "http://schemas.xmlsoap.org/disco/scl/");
         documentElement.AppendChild(newChild);
         XmlElement element2 = document.CreateElement("", "soap", "");
         element2.SetAttribute("address", SoapPageRef);
         element2.SetAttribute("xmlns", "http://schemas.xmlsoap.org/disco/soap/");
         documentElement.AppendChild(element2);
         document.Save(FilePath);
     }
     catch (Exception exception)
     {
         if ((exception is NullReferenceException) || (exception is SEHException))
         {
             throw;
         }
         ComSoapPublishError.Report(exception.ToString());
     }
 }
        public void DeleteServerTlb(string progId, string classId, string interfaceId, string srcTlbPath, string rootWebServer, string baseUrl, string virtualRoot, string operation, string assemblyName, string typeName)
        {
            try
            {
                new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
            }
            catch (SecurityException)
            {
                ComSoapPublishError.Report(Resource.FormatString("Soap_SecurityFailure"));
                throw;
            }
            string name = assemblyName;

            if ((((progId.Length > 0) || (classId.Length > 0)) || ((assemblyName.Length > 0) || (typeName.Length > 0))) && ((baseUrl.Length > 0) || (virtualRoot.Length > 0)))
            {
                string str3 = SoapServerInfo.ServerPhysicalPath(rootWebServer, baseUrl, virtualRoot, false);
                string str4 = srcTlbPath.ToLower(CultureInfo.InvariantCulture);
                if (!str4.EndsWith("scrobj.dll", StringComparison.Ordinal))
                {
                    if (str4.EndsWith("mscoree.dll", StringComparison.Ordinal))
                    {
                        Type typeFromProgID = Type.GetTypeFromProgID(progId);
                        typeName = typeFromProgID.FullName;
                        name     = typeFromProgID.Assembly.GetName().Name;
                    }
                    else
                    {
                        name = new GenerateMetadata().GetAssemblyName(srcTlbPath, str3 + @"\bin\");
                        if (name.Length > 0)
                        {
                            try
                            {
                                typeName = this.GetTypeName(str3 + @"\bin\" + name + ".dll", progId, classId);
                            }
                            catch (DirectoryNotFoundException)
                            {
                            }
                            catch (FileNotFoundException)
                            {
                            }
                        }
                    }
                    if ((!string.IsNullOrEmpty(progId) && !string.IsNullOrEmpty(name)) && !string.IsNullOrEmpty(typeName))
                    {
                        DiscoFile file         = new DiscoFile();
                        string    assemblyFile = str3 + @"\bin\" + name + ".dll";
                        SoapServerConfig.DeleteComponent(str3 + @"\Web.Config", name, typeName, progId, assemblyFile);
                        file.DeleteElement(str3 + @"\Default.disco", progId + ".soap?WSDL");
                    }
                }
            }
        }
 public void GetServerPhysicalPath(string rootWebServer, string inBaseUrl, string inVirtualRoot, out string physicalPath)
 {
     try
     {
         new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
         physicalPath = SoapServerInfo.ServerPhysicalPath(rootWebServer, inBaseUrl, inVirtualRoot, false);
     }
     catch (SecurityException)
     {
         ComSoapPublishError.Report(Resource.FormatString("Soap_SecurityFailure"));
         throw;
     }
 }