2 // System.Web.Services.Description.ServiceDescriptionImporter.cs
\r
5 // Tim Coleman (tim@timcoleman.com)
\r
6 // Lluis Sanchez Gual (lluis@ximian.com)
\r
8 // Copyright (C) Tim Coleman, 2002
\r
12 using System.CodeDom;
\r
13 using System.Web.Services;
\r
14 using System.Web.Services.Protocols;
\r
15 using System.Web.Services.Description;
\r
16 using System.Xml.Serialization;
\r
18 using System.Collections;
\r
19 using System.Configuration;
\r
21 namespace System.Web.Services.Description {
\r
22 public class ServiceDescriptionImporter {
\r
26 string protocolName;
\r
28 ServiceDescriptionCollection serviceDescriptions;
\r
29 ServiceDescriptionImportStyle style;
\r
31 ArrayList importInfo = new ArrayList ();
\r
34 #endregion // Fields
\r
36 #region Constructors
\r
38 public ServiceDescriptionImporter ()
\r
40 protocolName = String.Empty;
\r
41 schemas = new XmlSchemas ();
\r
42 serviceDescriptions = new ServiceDescriptionCollection ();
\r
43 style = ServiceDescriptionImportStyle.Client;
\r
46 #endregion // Constructors
\r
50 public string ProtocolName {
\r
51 get { return protocolName; }
\r
52 set { protocolName = value; }
\r
55 public XmlSchemas Schemas {
\r
56 get { return schemas; }
\r
59 public ServiceDescriptionCollection ServiceDescriptions {
\r
60 get { return serviceDescriptions; }
\r
63 public ServiceDescriptionImportStyle Style {
\r
64 get { return style; }
\r
65 set { style = value; }
\r
68 #endregion // Properties
\r
72 public void AddServiceDescription (ServiceDescription serviceDescription, string appSettingUrlKey, string appSettingBaseUrl)
\r
74 if (appSettingUrlKey != null && appSettingUrlKey == string.Empty && style == ServiceDescriptionImportStyle.Server)
\r
75 throw new InvalidOperationException ("Cannot set appSettingUrlKey if Style is Server");
\r
77 ImportInfo info = new ImportInfo ();
\r
78 info.ServiceDescription = serviceDescription;
\r
79 info.AppSettingUrlKey = appSettingUrlKey;
\r
80 info.AppSettingBaseUrl = appSettingBaseUrl;
\r
81 importInfo.Add (info);
\r
82 serviceDescriptions.Add (serviceDescription);
\r
84 if (serviceDescription.Types != null)
\r
85 schemas.Add (serviceDescription.Types.Schemas);
\r
88 public ServiceDescriptionImportWarnings Import (CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit)
\r
90 ProtocolImporter importer = GetImporter ();
\r
91 importer.Import (this, codeNamespace, codeCompileUnit, importInfo);
\r
93 return importer.Warnings;
\r
96 ProtocolImporter GetImporter ()
\r
98 switch ((protocolName != null && protocolName != "") ? protocolName : "Soap")
\r
100 case "Soap": return new SoapProtocolImporter ();
\r
101 default: throw new NotSupportedException ();
\r
107 internal class ImportInfo
\r
109 public ServiceDescription ServiceDescription;
\r
110 public string AppSettingUrlKey;
\r
111 public string AppSettingBaseUrl;
\r