PageRenderTime 60ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/Branches/V1/Thinktecture.Tools.Web.Services.WsdlWizard/WsdlWizardForm.cs

#
C# | 3476 lines | 2576 code | 323 blank | 577 comment | 177 complexity | 47c07a079c8fb78a5dc1da4d2fcbf350 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Drawing;
  6. using System.Globalization;
  7. using System.Linq;
  8. using System.Windows.Forms;
  9. using System.IO;
  10. using System.Text;
  11. using System.Reflection;
  12. using System.Net;
  13. using Thinktecture.Tools.Web.Services.ServiceDescription;
  14. using WizardControl;
  15. using WRM.Windows.Forms;
  16. using Message = Thinktecture.Tools.Web.Services.ServiceDescription.Message;
  17. using Thinktecture.Tools.Web.Services.Wscf.Environment;
  18. namespace Thinktecture.Tools.Web.Services.WsdlWizard
  19. {
  20. /// <summary>
  21. /// Represents the user interface handler for WsdlWizardForm.
  22. /// </summary>
  23. public class WsdlWizardForm : Form
  24. {
  25. #region Private fields
  26. private int operationCount;
  27. private string schemaLocation = "";
  28. private string wsdlLocation = "";
  29. private string schemaNamespace = "";
  30. private bool openCodeGenDialog;
  31. private bool alreadyCancelled = false;
  32. private bool roundtripMode = false;
  33. private string currentFolder;
  34. private string wsdlFile = string.Empty;
  35. private string defaultPathForImports = string.Empty;
  36. private string projectRootDirectory = string.Empty;
  37. private ArrayList importedSchemaNamespaces = new ArrayList();
  38. private Wizard wsdlWizardCtrl;
  39. private WizardPage wizardPageBasicMetadata;
  40. private TextBox tbServiceName;
  41. private Label lblServiceName;
  42. private Label lblNamespace;
  43. private WizardPage wizardPageOperationsList;
  44. private GroupBox groupBox1;
  45. private TextBox tbEdit;
  46. private ComboBox cbMEPs;
  47. private Panel panel1;
  48. private ToolTip toolTip1;
  49. private IContainer components;
  50. private TextBox tbNamespace;
  51. private LinkLabel llAddOperation;
  52. private EditableListView operationsListView;
  53. private InterfaceContract serviceInterfaceContract;
  54. private InterfaceContract importedContract = null;
  55. private SchemaElements messageSchemas = new SchemaElements();
  56. private SchemaElements headerSchemas = new SchemaElements();
  57. private SchemaElements faultSchemas = new SchemaElements();
  58. private LinkLabel llRemoveOperation;
  59. private Label lblServiceDoc;
  60. private TextBox tbServiceDoc;
  61. private WizardPage wizardPageMessageMapping;
  62. private WizardControl.WizardPage wizardPageAdditionalOptions;
  63. private System.Windows.Forms.CheckBox cbNeedsServiceElement;
  64. private System.Windows.Forms.CheckBox cbCodeGenDialog;
  65. private WRM.Windows.Forms.PropertyTree ptvServiceOperations;
  66. private WizardControl.WizardPage wizardPageSchemaImports;
  67. private System.Windows.Forms.GroupBox groupBox2;
  68. private Thinktecture.Tools.Web.Services.WsdlWizard.EditableListView importsListView;
  69. private System.Windows.Forms.LinkLabel llAddImport;
  70. private System.Windows.Forms.LinkLabel llRemoveImport;
  71. private System.Windows.Forms.OpenFileDialog openFileDialog1;
  72. private WizardControl.WizardPage wizardPageAlternativeXSDPaths;
  73. private Thinktecture.Tools.Web.Services.WsdlWizard.EditableListView xsdpathsListView;
  74. private System.Windows.Forms.ToolTip toolTipPath;
  75. private System.Windows.Forms.CheckBox cbInfer;
  76. private OperationsCollection inferOperations = new OperationsCollection(10);
  77. private CheckBox cbSoap12;
  78. private CheckBox cbSoap11;
  79. private OperationsCollection oldOperations =
  80. new OperationsCollection(); // Holds a list of old operations configured by the user.
  81. #endregion
  82. #region Public properties.
  83. /// <summary>
  84. /// Gets a value indicating whether the code generation dialog should be opened or not.
  85. /// </summary>
  86. public bool OpenCodeGenDialog
  87. {
  88. get { return openCodeGenDialog; }
  89. }
  90. /// <summary>
  91. /// Gets or sets the location to create the WSDL file.
  92. /// </summary>
  93. public string WsdlLocation
  94. {
  95. get { return wsdlLocation; }
  96. set { wsdlLocation = value; }
  97. }
  98. /// <summary>
  99. /// Gets or sets the schema namespace.
  100. /// </summary>
  101. public string SchemaNamespace
  102. {
  103. get { return schemaNamespace; }
  104. set { schemaNamespace = value; }
  105. }
  106. /// <summary>
  107. /// Gets or sets the schema location.
  108. /// </summary>
  109. public string SchemaLocation
  110. {
  111. get { return schemaLocation; }
  112. set
  113. {
  114. schemaLocation = value;
  115. this.UpdateCurrentFolder(schemaLocation);
  116. }
  117. }
  118. /// <summary>
  119. /// Gets or sets a value indicating whether the round tripping mode is on or off.
  120. /// </summary>
  121. public bool RoundtripMode
  122. {
  123. get { return roundtripMode; }
  124. set { roundtripMode = value; }
  125. }
  126. /// <summary>
  127. /// Gets or sets the default path for the imported XSD files.
  128. /// </summary>
  129. public string DefaultPathForImports
  130. {
  131. get { return defaultPathForImports; }
  132. set { defaultPathForImports = value; }
  133. }
  134. /// <summary>
  135. /// Gets or sets the root directory for the project.
  136. /// </summary>
  137. public string ProjectRootDirectory
  138. {
  139. get { return projectRootDirectory; }
  140. set { projectRootDirectory = value; }
  141. }
  142. #endregion
  143. #region Constructors
  144. /// <summary>
  145. /// Initializes a new instance of WsdlWizardForm class with the specified values.
  146. /// </summary>
  147. /// <param name="xsdLocation">
  148. /// Location of the XSD file containing the message contract definitions for the WSDL.
  149. /// </param>
  150. public WsdlWizardForm(string xsdLocation)
  151. {
  152. //
  153. // Required for Windows Form Designer support.
  154. //
  155. InitializeComponent();
  156. schemaLocation = xsdLocation;
  157. this.UpdateCurrentFolder(schemaLocation);
  158. serviceInterfaceContract = new InterfaceContract();
  159. serviceInterfaceContract.SchemaNamespace = schemaLocation;
  160. }
  161. /// <summary>
  162. /// Initializes a new instance of WsdlWizardForm class with the specified values.
  163. /// </summary>
  164. /// <param name="wsdlLocation">Location of the WSDL file to modify.</param>
  165. /// <param name="roundTripping">
  166. /// Value indicating that the round tripping is required.
  167. /// </param>
  168. /// <remarks>
  169. /// The roundTripping parameter must be set to true in order to use the round tripping feature.
  170. /// </remarks>
  171. public WsdlWizardForm(string wsdlLocation, bool roundTripping)
  172. {
  173. //
  174. // Required for Windows Form Designer support.
  175. //
  176. InitializeComponent();
  177. // Import the interface contract from the selected WSDL file.
  178. try
  179. {
  180. this.importedContract =
  181. ServiceDescriptionEngine.GetInterfaceContract(wsdlLocation);
  182. this.wsdlFile = wsdlLocation;
  183. }
  184. catch(WsdlModifiedException ex)
  185. {
  186. throw new WsdlFileLoadException(
  187. "Could not import the specified WSDL file for round-triping.\nThis file is not compatible for round-tripping.", ex);
  188. }
  189. catch(WsdlNotCompatibleForRoundTrippingException ex)
  190. {
  191. throw new WsdlFileLoadException(
  192. "Could not import the specified WSDL file for round-triping.\nThis file is not compatible for round-tripping.", ex);
  193. }
  194. catch
  195. {
  196. throw new WsdlFileLoadException(
  197. "System could not import the specified WSDL file for round triping.\nThis file is either modified or not a valid WSDL file created using WSCF.exe.");
  198. }
  199. this.UpdateCurrentFolder(wsdlLocation);
  200. serviceInterfaceContract = new InterfaceContract();
  201. serviceInterfaceContract.SchemaNamespace = schemaLocation;
  202. this.roundtripMode = roundTripping;
  203. }
  204. #endregion
  205. #region Dispose
  206. /// <summary>
  207. /// Clean up any resources being used.
  208. /// </summary>
  209. protected override void Dispose( bool disposing )
  210. {
  211. if( disposing )
  212. {
  213. if(components != null)
  214. {
  215. components.Dispose();
  216. }
  217. }
  218. base.Dispose( disposing );
  219. }
  220. #endregion
  221. #region Windows Form Designer generated code
  222. /// <summary>
  223. /// Required method for Designer support - do not modify
  224. /// the contents of this method with the code editor.
  225. /// </summary>
  226. private void InitializeComponent()
  227. {
  228. this.components = new System.ComponentModel.Container();
  229. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WsdlWizardForm));
  230. this.wsdlWizardCtrl = new WizardControl.Wizard();
  231. this.wizardPageBasicMetadata = new WizardControl.WizardPage();
  232. this.tbServiceDoc = new System.Windows.Forms.TextBox();
  233. this.lblServiceDoc = new System.Windows.Forms.Label();
  234. this.lblNamespace = new System.Windows.Forms.Label();
  235. this.tbNamespace = new System.Windows.Forms.TextBox();
  236. this.lblServiceName = new System.Windows.Forms.Label();
  237. this.tbServiceName = new System.Windows.Forms.TextBox();
  238. this.wizardPageSchemaImports = new WizardControl.WizardPage();
  239. this.groupBox2 = new System.Windows.Forms.GroupBox();
  240. this.llRemoveImport = new System.Windows.Forms.LinkLabel();
  241. this.llAddImport = new System.Windows.Forms.LinkLabel();
  242. this.importsListView = new Thinktecture.Tools.Web.Services.WsdlWizard.EditableListView();
  243. this.wizardPageOperationsList = new WizardControl.WizardPage();
  244. this.groupBox1 = new System.Windows.Forms.GroupBox();
  245. this.operationsListView = new Thinktecture.Tools.Web.Services.WsdlWizard.EditableListView();
  246. this.llAddOperation = new System.Windows.Forms.LinkLabel();
  247. this.llRemoveOperation = new System.Windows.Forms.LinkLabel();
  248. this.cbInfer = new System.Windows.Forms.CheckBox();
  249. this.panel1 = new System.Windows.Forms.Panel();
  250. this.tbEdit = new System.Windows.Forms.TextBox();
  251. this.cbMEPs = new System.Windows.Forms.ComboBox();
  252. this.wizardPageMessageMapping = new WizardControl.WizardPage();
  253. this.ptvServiceOperations = new WRM.Windows.Forms.PropertyTree();
  254. this.wizardPageAdditionalOptions = new WizardControl.WizardPage();
  255. this.cbSoap12 = new System.Windows.Forms.CheckBox();
  256. this.cbSoap11 = new System.Windows.Forms.CheckBox();
  257. this.cbNeedsServiceElement = new System.Windows.Forms.CheckBox();
  258. this.cbCodeGenDialog = new System.Windows.Forms.CheckBox();
  259. this.wizardPageAlternativeXSDPaths = new WizardControl.WizardPage();
  260. this.xsdpathsListView = new Thinktecture.Tools.Web.Services.WsdlWizard.EditableListView();
  261. this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
  262. this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
  263. this.toolTipPath = new System.Windows.Forms.ToolTip(this.components);
  264. this.wsdlWizardCtrl.SuspendLayout();
  265. this.wizardPageBasicMetadata.SuspendLayout();
  266. this.wizardPageSchemaImports.SuspendLayout();
  267. this.groupBox2.SuspendLayout();
  268. this.wizardPageOperationsList.SuspendLayout();
  269. this.groupBox1.SuspendLayout();
  270. this.panel1.SuspendLayout();
  271. this.wizardPageMessageMapping.SuspendLayout();
  272. ((System.ComponentModel.ISupportInitialize)(this.ptvServiceOperations)).BeginInit();
  273. this.wizardPageAdditionalOptions.SuspendLayout();
  274. this.wizardPageAlternativeXSDPaths.SuspendLayout();
  275. this.SuspendLayout();
  276. //
  277. // wsdlWizardCtrl
  278. //
  279. this.wsdlWizardCtrl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  280. | System.Windows.Forms.AnchorStyles.Left)
  281. | System.Windows.Forms.AnchorStyles.Right)));
  282. this.wsdlWizardCtrl.BannerBitmap = ((System.Drawing.Image)(resources.GetObject("wsdlWizardCtrl.BannerBitmap")));
  283. this.wsdlWizardCtrl.CloseForm = false;
  284. this.wsdlWizardCtrl.Controls.Add(this.wizardPageBasicMetadata);
  285. this.wsdlWizardCtrl.Controls.Add(this.wizardPageSchemaImports);
  286. this.wsdlWizardCtrl.Controls.Add(this.wizardPageOperationsList);
  287. this.wsdlWizardCtrl.Controls.Add(this.wizardPageMessageMapping);
  288. this.wsdlWizardCtrl.Controls.Add(this.wizardPageAdditionalOptions);
  289. this.wsdlWizardCtrl.Controls.Add(this.wizardPageAlternativeXSDPaths);
  290. this.wsdlWizardCtrl.Location = new System.Drawing.Point(0, 0);
  291. this.wsdlWizardCtrl.Name = "wsdlWizardCtrl";
  292. this.wsdlWizardCtrl.Size = new System.Drawing.Size(497, 360);
  293. this.wsdlWizardCtrl.TabIndex = 0;
  294. this.wsdlWizardCtrl.Title = "Generate WSDL";
  295. this.wsdlWizardCtrl.WelcomeBitmap = ((System.Drawing.Image)(resources.GetObject("wsdlWizardCtrl.WelcomeBitmap")));
  296. this.wsdlWizardCtrl.WelcomeText = resources.GetString("wsdlWizardCtrl.WelcomeText");
  297. this.wsdlWizardCtrl.Load += new System.EventHandler(this.wsdlWizardCtrl_Load);
  298. this.wsdlWizardCtrl.Cancelled += new WizardControl.Wizard.CancelledEventHandler(this.wsdlWizardCtrl_Cancelled);
  299. this.wsdlWizardCtrl.BeforeSummaryPageDisplayed += new WizardControl.Wizard.BeforeSummaryPageDisplayedEventHandler(this.wsdlWizardCtrl_BeforeSummaryPageDisplayed);
  300. this.wsdlWizardCtrl.BeforePageDisplayed += new WizardControl.Wizard.BeforePageDisplayedEventHandler(this.wsdlWizardCtrl_BeforePageDisplayed);
  301. this.wsdlWizardCtrl.Finished += new WizardControl.Wizard.FinishedEventHandler(this.wsdlWizardCtrl_Finished);
  302. this.wsdlWizardCtrl.AfterPageDisplayed += new WizardControl.Wizard.AfterPageDisplayedEventHandler(this.wsdlWizardCtrl_AfterPageDisplayed);
  303. this.wsdlWizardCtrl.ValidatePage += new WizardControl.Wizard.ValidatePageEventHandler(this.wsdlWizardCtrl_ValidatePage);
  304. //
  305. // wizardPageBasicMetadata
  306. //
  307. this.wizardPageBasicMetadata.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  308. | System.Windows.Forms.AnchorStyles.Left)
  309. | System.Windows.Forms.AnchorStyles.Right)));
  310. this.wizardPageBasicMetadata.Controls.Add(this.tbServiceDoc);
  311. this.wizardPageBasicMetadata.Controls.Add(this.lblServiceDoc);
  312. this.wizardPageBasicMetadata.Controls.Add(this.lblNamespace);
  313. this.wizardPageBasicMetadata.Controls.Add(this.tbNamespace);
  314. this.wizardPageBasicMetadata.Controls.Add(this.lblServiceName);
  315. this.wizardPageBasicMetadata.Controls.Add(this.tbServiceName);
  316. this.wizardPageBasicMetadata.Description = "Please enter the name and the XML namespace of the Web Service.";
  317. this.wizardPageBasicMetadata.Heading = "Step 1: Specify your Web Service\'s basic settings";
  318. this.wizardPageBasicMetadata.Location = new System.Drawing.Point(21, 71);
  319. this.wizardPageBasicMetadata.Name = "wizardPageBasicMetadata";
  320. this.wizardPageBasicMetadata.Size = new System.Drawing.Size(456, 230);
  321. this.wizardPageBasicMetadata.TabIndex = 0;
  322. //
  323. // tbServiceDoc
  324. //
  325. this.tbServiceDoc.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  326. | System.Windows.Forms.AnchorStyles.Left)
  327. | System.Windows.Forms.AnchorStyles.Right)));
  328. this.tbServiceDoc.Location = new System.Drawing.Point(120, 72);
  329. this.tbServiceDoc.Multiline = true;
  330. this.tbServiceDoc.Name = "tbServiceDoc";
  331. this.tbServiceDoc.Size = new System.Drawing.Size(312, 88);
  332. this.tbServiceDoc.TabIndex = 5;
  333. //
  334. // lblServiceDoc
  335. //
  336. this.lblServiceDoc.Location = new System.Drawing.Point(24, 72);
  337. this.lblServiceDoc.Name = "lblServiceDoc";
  338. this.lblServiceDoc.Size = new System.Drawing.Size(100, 23);
  339. this.lblServiceDoc.TabIndex = 4;
  340. this.lblServiceDoc.Text = "Documentation:";
  341. //
  342. // lblNamespace
  343. //
  344. this.lblNamespace.Location = new System.Drawing.Point(24, 40);
  345. this.lblNamespace.Name = "lblNamespace";
  346. this.lblNamespace.Size = new System.Drawing.Size(96, 23);
  347. this.lblNamespace.TabIndex = 3;
  348. this.lblNamespace.Text = "XML namespace:";
  349. //
  350. // tbNamespace
  351. //
  352. this.tbNamespace.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  353. | System.Windows.Forms.AnchorStyles.Right)));
  354. this.tbNamespace.Location = new System.Drawing.Point(120, 40);
  355. this.tbNamespace.Name = "tbNamespace";
  356. this.tbNamespace.Size = new System.Drawing.Size(312, 20);
  357. this.tbNamespace.TabIndex = 2;
  358. //
  359. // lblServiceName
  360. //
  361. this.lblServiceName.Location = new System.Drawing.Point(24, 8);
  362. this.lblServiceName.Name = "lblServiceName";
  363. this.lblServiceName.Size = new System.Drawing.Size(88, 23);
  364. this.lblServiceName.TabIndex = 1;
  365. this.lblServiceName.Text = "Service name:";
  366. this.toolTip1.SetToolTip(this.lblServiceName, "\'Service name\' specifies the name of the Web Service binding to be generated. Thi" +
  367. "s will be the e.g. the class name for your Web Service proxy when generated from" +
  368. " the service description.");
  369. //
  370. // tbServiceName
  371. //
  372. this.tbServiceName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  373. | System.Windows.Forms.AnchorStyles.Right)));
  374. this.tbServiceName.Location = new System.Drawing.Point(120, 6);
  375. this.tbServiceName.Name = "tbServiceName";
  376. this.tbServiceName.Size = new System.Drawing.Size(312, 20);
  377. this.tbServiceName.TabIndex = 0;
  378. this.toolTip1.SetToolTip(this.tbServiceName, "\'Service name\' specifies the name of the Web Service binding to be generated. Thi" +
  379. "s will be the e.g. the class name for your Web Service proxy when generated from" +
  380. " the service description.");
  381. //
  382. // wizardPageSchemaImports
  383. //
  384. this.wizardPageSchemaImports.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  385. | System.Windows.Forms.AnchorStyles.Left)
  386. | System.Windows.Forms.AnchorStyles.Right)));
  387. this.wizardPageSchemaImports.Controls.Add(this.groupBox2);
  388. this.wizardPageSchemaImports.Cursor = System.Windows.Forms.Cursors.Default;
  389. this.wizardPageSchemaImports.Description = "Please add additional message schemas from XSD files as appropriate.";
  390. this.wizardPageSchemaImports.Heading = "Step 2: Specify additional message schemas";
  391. this.wizardPageSchemaImports.Location = new System.Drawing.Point(21, 71);
  392. this.wizardPageSchemaImports.Name = "wizardPageSchemaImports";
  393. this.wizardPageSchemaImports.Size = new System.Drawing.Size(456, 230);
  394. this.wizardPageSchemaImports.TabIndex = 2;
  395. //
  396. // groupBox2
  397. //
  398. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  399. | System.Windows.Forms.AnchorStyles.Left)
  400. | System.Windows.Forms.AnchorStyles.Right)));
  401. this.groupBox2.Controls.Add(this.llRemoveImport);
  402. this.groupBox2.Controls.Add(this.llAddImport);
  403. this.groupBox2.Controls.Add(this.importsListView);
  404. this.groupBox2.Location = new System.Drawing.Point(8, 3);
  405. this.groupBox2.Name = "groupBox2";
  406. this.groupBox2.Size = new System.Drawing.Size(440, 224);
  407. this.groupBox2.TabIndex = 2;
  408. this.groupBox2.TabStop = false;
  409. this.groupBox2.Text = "XSD Imports:";
  410. //
  411. // llRemoveImport
  412. //
  413. this.llRemoveImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  414. this.llRemoveImport.Location = new System.Drawing.Point(95, 205);
  415. this.llRemoveImport.Name = "llRemoveImport";
  416. this.llRemoveImport.Size = new System.Drawing.Size(100, 16);
  417. this.llRemoveImport.TabIndex = 4;
  418. this.llRemoveImport.TabStop = true;
  419. this.llRemoveImport.Text = "Remove import";
  420. this.llRemoveImport.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llRemoveImport_LinkClicked);
  421. //
  422. // llAddImport
  423. //
  424. this.llAddImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  425. this.llAddImport.Location = new System.Drawing.Point(8, 205);
  426. this.llAddImport.Name = "llAddImport";
  427. this.llAddImport.Size = new System.Drawing.Size(81, 15);
  428. this.llAddImport.TabIndex = 3;
  429. this.llAddImport.TabStop = true;
  430. this.llAddImport.Text = "Add import";
  431. this.llAddImport.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llAddImport_LinkClicked);
  432. //
  433. // importsListView
  434. //
  435. this.importsListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  436. | System.Windows.Forms.AnchorStyles.Left)
  437. | System.Windows.Forms.AnchorStyles.Right)));
  438. this.importsListView.DisabledColumns = ((System.Collections.ArrayList)(resources.GetObject("importsListView.DisabledColumns")));
  439. this.importsListView.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  440. this.importsListView.FullRowSelect = true;
  441. this.importsListView.GridLines = true;
  442. this.importsListView.Location = new System.Drawing.Point(8, 16);
  443. this.importsListView.Name = "importsListView";
  444. this.importsListView.Size = new System.Drawing.Size(424, 184);
  445. this.importsListView.TabIndex = 2;
  446. this.importsListView.UseCompatibleStateImageBehavior = false;
  447. this.importsListView.View = System.Windows.Forms.View.Details;
  448. this.importsListView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.importsListView_MouseMove);
  449. //
  450. // wizardPageOperationsList
  451. //
  452. this.wizardPageOperationsList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  453. | System.Windows.Forms.AnchorStyles.Left)
  454. | System.Windows.Forms.AnchorStyles.Right)));
  455. this.wizardPageOperationsList.Controls.Add(this.groupBox1);
  456. this.wizardPageOperationsList.Controls.Add(this.panel1);
  457. this.wizardPageOperationsList.Description = "Please add operations to the Web Service as needed.";
  458. this.wizardPageOperationsList.Heading = "Step 3: Specify settings for your Web Service\'s operations.";
  459. this.wizardPageOperationsList.Location = new System.Drawing.Point(21, 71);
  460. this.wizardPageOperationsList.Name = "wizardPageOperationsList";
  461. this.wizardPageOperationsList.Size = new System.Drawing.Size(456, 230);
  462. this.wizardPageOperationsList.TabIndex = 1;
  463. //
  464. // groupBox1
  465. //
  466. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  467. | System.Windows.Forms.AnchorStyles.Left)
  468. | System.Windows.Forms.AnchorStyles.Right)));
  469. this.groupBox1.Controls.Add(this.operationsListView);
  470. this.groupBox1.Controls.Add(this.llAddOperation);
  471. this.groupBox1.Controls.Add(this.llRemoveOperation);
  472. this.groupBox1.Controls.Add(this.cbInfer);
  473. this.groupBox1.Location = new System.Drawing.Point(8, 3);
  474. this.groupBox1.Name = "groupBox1";
  475. this.groupBox1.Size = new System.Drawing.Size(440, 224);
  476. this.groupBox1.TabIndex = 4;
  477. this.groupBox1.TabStop = false;
  478. this.groupBox1.Text = "Operations:";
  479. //
  480. // operationsListView
  481. //
  482. this.operationsListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  483. | System.Windows.Forms.AnchorStyles.Left)
  484. | System.Windows.Forms.AnchorStyles.Right)));
  485. this.operationsListView.DisabledColumns = ((System.Collections.ArrayList)(resources.GetObject("operationsListView.DisabledColumns")));
  486. this.operationsListView.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  487. this.operationsListView.FullRowSelect = true;
  488. this.operationsListView.GridLines = true;
  489. this.operationsListView.Location = new System.Drawing.Point(8, 16);
  490. this.operationsListView.Name = "operationsListView";
  491. this.operationsListView.Size = new System.Drawing.Size(424, 184);
  492. this.operationsListView.TabIndex = 0;
  493. this.operationsListView.UseCompatibleStateImageBehavior = false;
  494. this.operationsListView.View = System.Windows.Forms.View.Details;
  495. //
  496. // llAddOperation
  497. //
  498. this.llAddOperation.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  499. this.llAddOperation.Location = new System.Drawing.Point(7, 205);
  500. this.llAddOperation.Name = "llAddOperation";
  501. this.llAddOperation.Size = new System.Drawing.Size(81, 15);
  502. this.llAddOperation.TabIndex = 1;
  503. this.llAddOperation.TabStop = true;
  504. this.llAddOperation.Text = "Add operation";
  505. this.llAddOperation.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llAddItem_LinkClicked);
  506. //
  507. // llRemoveOperation
  508. //
  509. this.llRemoveOperation.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  510. this.llRemoveOperation.Location = new System.Drawing.Point(95, 205);
  511. this.llRemoveOperation.Name = "llRemoveOperation";
  512. this.llRemoveOperation.Size = new System.Drawing.Size(100, 16);
  513. this.llRemoveOperation.TabIndex = 2;
  514. this.llRemoveOperation.TabStop = true;
  515. this.llRemoveOperation.Text = "Remove operation";
  516. this.llRemoveOperation.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llRemoveItem_LinkClicked);
  517. //
  518. // cbInfer
  519. //
  520. this.cbInfer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  521. this.cbInfer.Location = new System.Drawing.Point(336, 204);
  522. this.cbInfer.Name = "cbInfer";
  523. this.cbInfer.Size = new System.Drawing.Size(104, 16);
  524. this.cbInfer.TabIndex = 4;
  525. this.cbInfer.Text = "Infer Operations";
  526. this.cbInfer.CheckedChanged += new System.EventHandler(this.cbInfer_CheckedChanged);
  527. //
  528. // panel1
  529. //
  530. this.panel1.Controls.Add(this.tbEdit);
  531. this.panel1.Controls.Add(this.cbMEPs);
  532. this.panel1.Location = new System.Drawing.Point(24, 32);
  533. this.panel1.Name = "panel1";
  534. this.panel1.Size = new System.Drawing.Size(408, 192);
  535. this.panel1.TabIndex = 2;
  536. //
  537. // tbEdit
  538. //
  539. this.tbEdit.Location = new System.Drawing.Point(16, 16);
  540. this.tbEdit.Name = "tbEdit";
  541. this.tbEdit.Size = new System.Drawing.Size(100, 20);
  542. this.tbEdit.TabIndex = 3;
  543. this.tbEdit.Text = "textBox2";
  544. this.tbEdit.Visible = false;
  545. //
  546. // cbMEPs
  547. //
  548. this.cbMEPs.ItemHeight = 13;
  549. this.cbMEPs.Items.AddRange(new object[] {
  550. "Request/Response",
  551. "One-Way"});
  552. this.cbMEPs.Location = new System.Drawing.Point(272, 16);
  553. this.cbMEPs.Name = "cbMEPs";
  554. this.cbMEPs.Size = new System.Drawing.Size(121, 21);
  555. this.cbMEPs.TabIndex = 2;
  556. this.cbMEPs.Text = "comboBox1";
  557. this.cbMEPs.Visible = false;
  558. //
  559. // wizardPageMessageMapping
  560. //
  561. this.wizardPageMessageMapping.Controls.Add(this.ptvServiceOperations);
  562. this.wizardPageMessageMapping.Description = "Please enter all details for the service\'s operations and messages.";
  563. this.wizardPageMessageMapping.Heading = "Step 4: Specify the operation\'s message parameters";
  564. this.wizardPageMessageMapping.Location = new System.Drawing.Point(21, 71);
  565. this.wizardPageMessageMapping.Name = "wizardPageMessageMapping";
  566. this.wizardPageMessageMapping.Size = new System.Drawing.Size(456, 230);
  567. this.wizardPageMessageMapping.TabIndex = 3;
  568. //
  569. // ptvServiceOperations
  570. //
  571. this.ptvServiceOperations.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  572. | System.Windows.Forms.AnchorStyles.Left)
  573. | System.Windows.Forms.AnchorStyles.Right)));
  574. this.ptvServiceOperations.ImageList = null;
  575. this.ptvServiceOperations.Indent = 19;
  576. this.ptvServiceOperations.Location = new System.Drawing.Point(0, -1);
  577. this.ptvServiceOperations.Name = "ptvServiceOperations";
  578. this.ptvServiceOperations.PaneHeaderVisible = false;
  579. this.ptvServiceOperations.SelectedImageIndex = -1;
  580. this.ptvServiceOperations.SelectedPaneNode = null;
  581. this.ptvServiceOperations.ShowLines = true;
  582. this.ptvServiceOperations.ShowPlusMinus = true;
  583. this.ptvServiceOperations.ShowRootLines = true;
  584. this.ptvServiceOperations.Size = new System.Drawing.Size(456, 232);
  585. this.ptvServiceOperations.SplitterColor = System.Drawing.SystemColors.AppWorkspace;
  586. this.ptvServiceOperations.SplitterLeft = 184;
  587. this.ptvServiceOperations.TabIndex = 1;
  588. //
  589. // wizardPageAdditionalOptions
  590. //
  591. this.wizardPageAdditionalOptions.Controls.Add(this.cbSoap12);
  592. this.wizardPageAdditionalOptions.Controls.Add(this.cbSoap11);
  593. this.wizardPageAdditionalOptions.Controls.Add(this.cbNeedsServiceElement);
  594. this.wizardPageAdditionalOptions.Controls.Add(this.cbCodeGenDialog);
  595. this.wizardPageAdditionalOptions.Description = "Please select any additional options to configure.";
  596. this.wizardPageAdditionalOptions.Heading = "Step 5: Additional options";
  597. this.wizardPageAdditionalOptions.Location = new System.Drawing.Point(21, 71);
  598. this.wizardPageAdditionalOptions.Name = "wizardPageAdditionalOptions";
  599. this.wizardPageAdditionalOptions.Size = new System.Drawing.Size(456, 230);
  600. this.wizardPageAdditionalOptions.TabIndex = 4;
  601. //
  602. // cbSoap12
  603. //
  604. this.cbSoap12.AutoSize = true;
  605. this.cbSoap12.Location = new System.Drawing.Point(24, 87);
  606. this.cbSoap12.Name = "cbSoap12";
  607. this.cbSoap12.Size = new System.Drawing.Size(144, 17);
  608. this.cbSoap12.TabIndex = 12;
  609. this.cbSoap12.Text = "Create SOAP 1.2 binding";
  610. this.cbSoap12.UseVisualStyleBackColor = true;
  611. //
  612. // cbSoap11
  613. //
  614. this.cbSoap11.AutoSize = true;
  615. this.cbSoap11.Checked = true;
  616. this.cbSoap11.CheckState = System.Windows.Forms.CheckState.Checked;
  617. this.cbSoap11.Enabled = false;
  618. this.cbSoap11.Location = new System.Drawing.Point(24, 51);
  619. this.cbSoap11.Name = "cbSoap11";
  620. this.cbSoap11.Size = new System.Drawing.Size(144, 17);
  621. this.cbSoap11.TabIndex = 11;
  622. this.cbSoap11.Text = "Create SOAP 1.1 binding";
  623. this.cbSoap11.UseVisualStyleBackColor = true;
  624. //
  625. // cbNeedsServiceElement
  626. //
  627. this.cbNeedsServiceElement.Location = new System.Drawing.Point(24, 8);
  628. this.cbNeedsServiceElement.Name = "cbNeedsServiceElement";
  629. this.cbNeedsServiceElement.Size = new System.Drawing.Size(192, 24);
  630. this.cbNeedsServiceElement.TabIndex = 10;
  631. this.cbNeedsServiceElement.Text = "Generate <service> element.";
  632. this.toolTip1.SetToolTip(this.cbNeedsServiceElement, "Enable this option if you want to have a <service> element generated for the WSDL" +
  633. " service description.");
  634. //
  635. // cbCodeGenDialog
  636. //
  637. this.cbCodeGenDialog.Location = new System.Drawing.Point(24, 169);
  638. this.cbCodeGenDialog.Name = "cbCodeGenDialog";
  639. this.cbCodeGenDialog.Size = new System.Drawing.Size(408, 24);
  640. this.cbCodeGenDialog.TabIndex = 6;
  641. this.cbCodeGenDialog.Text = "Open the code generation dialog after this wizard closes.";
  642. this.cbCodeGenDialog.CheckedChanged += new System.EventHandler(this.cbCodeGenDialog_CheckedChanged);
  643. //
  644. // wizardPageAlternativeXSDPaths
  645. //
  646. this.wizardPageAlternativeXSDPaths.Controls.Add(this.xsdpathsListView);
  647. this.wizardPageAlternativeXSDPaths.Description = "Please select the alternative XSD path for each XSD file imported.";
  648. this.wizardPageAlternativeXSDPaths.Heading = "Step 6: Alternative XSD Paths";
  649. this.wizardPageAlternativeXSDPaths.Location = new System.Drawing.Point(21, 71);
  650. this.wizardPageAlternativeXSDPaths.Name = "wizardPageAlternativeXSDPaths";
  651. this.wizardPageAlternativeXSDPaths.Size = new System.Drawing.Size(456, 230);
  652. this.wizardPageAlternativeXSDPaths.TabIndex = 5;
  653. //
  654. // xsdpathsListView
  655. //
  656. this.xsdpathsListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  657. | System.Windows.Forms.AnchorStyles.Left)
  658. | System.Windows.Forms.AnchorStyles.Right)));
  659. this.xsdpathsListView.DisabledColumns = ((System.Collections.ArrayList)(resources.GetObject("xsdpathsListView.DisabledColumns")));
  660. this.xsdpathsListView.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  661. this.xsdpathsListView.FullRowSelect = true;
  662. this.xsdpathsListView.GridLines = true;
  663. this.xsdpathsListView.Location = new System.Drawing.Point(0, 0);
  664. this.xsdpathsListView.Name = "xsdpathsListView";
  665. this.xsdpathsListView.Size = new System.Drawing.Size(456, 224);
  666. this.xsdpathsListView.TabIndex = 3;
  667. this.xsdpathsListView.UseCompatibleStateImageBehavior = false;
  668. this.xsdpathsListView.View = System.Windows.Forms.View.Details;
  669. //
  670. // openFileDialog1
  671. //
  672. this.openFileDialog1.Filter = "XSD Files(*.xsd)|*.xsd";
  673. //
  674. // toolTipPath
  675. //
  676. this.toolTipPath.AutomaticDelay = 1000;
  677. //
  678. // WsdlWizardForm
  679. //
  680. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  681. this.ClientSize = new System.Drawing.Size(497, 360);
  682. this.Controls.Add(this.wsdlWizardCtrl);
  683. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
  684. this.HelpButton = true;
  685. this.Name = "WsdlWizardForm";
  686. this.ShowInTaskbar = false;
  687. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  688. this.Text = "Create a WSDL Interface Description";
  689. this.Load += new System.EventHandler(this.WSDLWizard_Load);
  690. this.Closing += new System.ComponentModel.CancelEventHandler(this.WsdlWizardForm_Closing);
  691. this.wsdlWizardCtrl.ResumeLayout(false);
  692. this.wizardPageBasicMetadata.ResumeLayout(false);
  693. this.wizardPageBasicMetadata.PerformLayout();
  694. this.wizardPageSchemaImports.ResumeLayout(false);
  695. this.groupBox2.ResumeLayout(false);
  696. this.wizardPageOperationsList.ResumeLayout(false);
  697. this.groupBox1.ResumeLayout(false);
  698. this.panel1.ResumeLayout(false);
  699. this.panel1.PerformLayout();
  700. this.wizardPageMessageMapping.ResumeLayout(false);
  701. ((System.ComponentModel.ISupportInitialize)(this.ptvServiceOperations)).EndInit();
  702. this.wizardPageAdditionalOptions.ResumeLayout(false);
  703. this.wizardPageAdditionalOptions.PerformLayout();
  704. this.wizardPageAlternativeXSDPaths.ResumeLayout(false);
  705. this.ResumeLayout(false);
  706. }
  707. #endregion
  708. #region Event handlers
  709. /// <summary>
  710. /// Adds an operation to the operationsListView.
  711. /// </summary>
  712. /// <param name="sender">The source of the event.</param>
  713. /// <param name="e">An instance of <see cref="LinkLabelLinkClickedEventArgs"/> class with Event data.</param>
  714. private void llAddItem_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  715. {
  716. ListViewItem listViewItem1 =
  717. new ListViewItem(new string[] {
  718. "Operation" + operationCount,
  719. "Request/Response",
  720. "",
  721. ""},
  722. -1);
  723. operationsListView.Items.AddRange(
  724. new ListViewItem[] {listViewItem1});
  725. operationCount++;
  726. }
  727. /// <summary>
  728. /// Removes an operation from the operationsListView.
  729. /// </summary>
  730. /// <param name="sender">The source of the event.</param>
  731. /// <param name="e">An instance of <see cref="LinkLabelLinkClickedEventArgs"/> class with Event data.</param>
  732. /// <remarks>
  733. /// This method will remove the first item of the selected items collection. If no item is selected then
  734. /// it removes the last item available in the list.
  735. /// </remarks>
  736. private void llRemoveItem_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  737. {
  738. if(operationsListView.Items.Count > 0)
  739. {
  740. // Remove the first item of the selected items.
  741. if(operationsListView.SelectedItems.Count > 0)
  742. {
  743. while (operationsListView.SelectedItems.Count != 0)
  744. {
  745. ListViewItem lvi = operationsListView.SelectedItems[0];
  746. operationsListView.Items.Remove(lvi);
  747. }
  748. }
  749. else
  750. {
  751. // If anything is not selected, remove the last item on the list.
  752. operationsListView.Items.RemoveAt(operationsListView.Items.Count - 1);
  753. operationCount--;
  754. }
  755. }
  756. }
  757. /// <summary>
  758. /// Performs the necessary initialization when the wizard control loads.
  759. /// </summary>
  760. /// <param name="sender">The source of the event.</param>
  761. /// <param name="e">An instance of <see cref="EventArgs"/> class with event data.</param>
  762. private void wsdlWizardCtrl_Load(object sender, EventArgs e)
  763. {
  764. // Add the columns to the operationsListView.
  765. operationsListView.Columns.Add("Operation Name", 210, HorizontalAlignment.Left);
  766. operationsListView.Columns.Add("Message Exchange Pattern", -2, HorizontalAlignment.Left);
  767. // Add the columns to the importsListView.
  768. importsListView.Columns.Add("File Name", 210, HorizontalAlignment.Left);
  769. importsListView.Columns.Add("Location", -1, HorizontalAlignment.Left);
  770. // Set the non editable columns.
  771. importsListView.DisabledColumns.Add("File Name");
  772. importsListView.DisabledColumns.Add("Location");
  773. // Add the columns to the xsdpathsListView.
  774. xsdpathsListView.Columns.Add("File Name", 210, HorizontalAlignment.Left);
  775. xsdpathsListView.Columns.Add("Alternative Path", -2, HorizontalAlignment.Left);
  776. // Set the non editable columns.
  777. xsdpathsListView.DisabledColumns.Add("File Name");
  778. // Load the default XSD to the schema imports list.
  779. string fname = schemaLocation.Substring(schemaLocation.LastIndexOf("\\") + 1);
  780. ListViewItem defaultLocation = new ListViewItem();
  781. defaultLocation.Text = fname;
  782. defaultLocation.SubItems.Add(schemaLocation);
  783. importsListView.Items.Add(defaultLocation);
  784. // Skip the wizard welcome page if the round tripping is on.
  785. if(RoundtripMode == true)
  786. {
  787. wsdlWizardCtrl.AdvancePage();
  788. tbNamespace.Enabled = false;
  789. }
  790. // Focus the first tbServiceName text box.
  791. tbServiceName.Focus();
  792. // Assign the cancel button.
  793. this.CancelButton = wsdlWizardCtrl.CancelButton;
  794. }
  795. /// <summary>
  796. /// Asks the confirmation question and quits the wizard upon the click of the "Cancel" button.
  797. /// </summary>
  798. /// <param name="sender">The source of the event.</param>
  799. /// <param name="e">An instance of <see cref="EventArgs"/> class with the event data.</param>
  800. private void wsdlWizardCtrl_Cancelled(object sender, EventArgs e)
  801. {
  802. /*
  803. if(MessageBox.Show("Do you really want to quit?",
  804. "WSDL Wizard", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  805. {
  806. alreadyCancelled = true;
  807. this.Close();
  808. }
  809. */
  810. }
  811. /// <summary>
  812. /// Performs the actions, when the wizard's "Finish" button is clicked.
  813. /// </summary>
  814. /// <param name="sender">The source of the event.</param>
  815. /// <param name="e">An instance of <see cref="EventArgs"/> class with the event data.</param>
  816. /// <remarks>
  817. /// This method finally wraps up the necessary details and calls the
  818. /// <see cref="ServiceDescriptionEngine"/> class to generate the WSDL file.
  819. /// </remarks>
  820. private void wsdlWizardCtrl_Finished(object sender, EventArgs e)
  821. {
  822. try
  823. {
  824. // Set additional options for WSDL generation.
  825. serviceInterfaceContract.NeedsServiceElement =
  826. cbNeedsServiceElement.Checked;
  827. if (cbSoap11.Checked)
  828. {
  829. serviceInterfaceContract.Bindings |= InterfaceContract.SoapBindings.Soap11;
  830. }
  831. if (cbSoap12.Checked)
  832. {
  833. serviceInterfaceContract.Bindings |= InterfaceContract.SoapBindings.Soap12;
  834. }
  835. // Use alternative location for imports by default.
  836. serviceInterfaceContract.UseAlternateLocationForImports = true;
  837. // Call the GenerateWSDL method according to the round tripping mode.
  838. if(this.roundtripMode)
  839. {
  840. wsdlLocation = ServiceDescriptionEngine.GenerateWsdl(serviceInterfaceContract,
  841. wsdlLocation, GetXmlCommentForWSDL(), this.wsdlFile);
  842. }
  843. else
  844. {
  845. wsdlLocation = ServiceDescriptionEngine.GenerateWsdl(serviceInterfaceContract,
  846. wsdlLocation, GetXmlCommentForWSDL());
  847. }
  848. this.DialogResult = DialogResult.OK;
  849. alreadyCancelled = true;
  850. this.Close();
  851. }
  852. catch(WsdlGenerationException ex)
  853. {
  854. MessageBox.Show("An error occured while generating WSDL: " + ex.Message, "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error);
  855. }
  856. catch(Exception generalException)
  857. {
  858. MessageBox.Show("An error occured while generating WSDL: " + generalException.Message, "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error);
  859. }
  860. }
  861. /// <summary>
  862. /// Performs the actions prior to displaying each page on the wizard control.
  863. /// </summary>
  864. /// <param name="sender">The source of the event.</param>
  865. /// <param name="e">An instance of <see cref="WizardPageDisplayedEventArgs"/> class with event data.</param>
  866. private void wsdlWizardCtrl_BeforePageDisplayed(object sender, WizardPageDisplayedEventArgs e)
  867. {
  868. // Assign the basic meta data values to the instance of InterfaceContract class.
  869. if (e.Page == wizardPageSchemaImports)
  870. {
  871. // 07-23-2005
  872. // BDS: Added this gate to validate the namespace uri.
  873. Uri uri;
  874. try
  875. {
  876. if (tbNamespace.Text.IndexOf(":") > -1 || Path.IsPathRooted(tbNamespace.Text))
  877. {
  878. uri = new Uri(tbNamespace.Text);
  879. }
  880. else
  881. {
  882. uri = new Uri("anyuri:" + tbNamespace.Text);
  883. }
  884. }
  885. catch
  886. {
  887. MessageBox.Show(this,
  888. "Invalid uri for the namespace. Enter a valid uri and try again.",
  889. "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error);
  890. e.Cancel = true;
  891. return;
  892. }
  893. serviceInterfaceContract.ServiceName = tbServiceName.Text;
  894. serviceInterfaceContract.ServiceNamespace = tbNamespace.Text;
  895. serviceInterfaceContract.SchemaNamespace = schemaNamespace;
  896. serviceInterfaceContract.ServiceDocumentation = tbServiceDoc.Text;
  897. return;
  898. }
  899. if (e.Page == wizardPageOperationsList)
  900. {
  901. // Clear the existing items.
  902. this.messageSchemas.Clear();
  903. this.headerSchemas.Clear();
  904. faultSchemas.Clear();
  905. this.importedSchemaNamespaces.Clear();
  906. this.serviceInterfaceContract.Imports.Clear();
  907. // Add the selected schemas to the ServiceInterfaceContract.Imports collection.
  908. foreach (ListViewItem importItem in importsListView.Items)
  909. {
  910. string schemaNamespace = string.Empty;
  911. string importLocation = importItem.SubItems[1].Text;
  912. ArrayList result;
  913. try
  914. {
  915. // Read the content of the imported files and add them to the local arrays for UI.
  916. result = ServiceDescriptionEngine.GetSchemasFromXsd(importLocation, out schemaNamespace);
  917. }
  918. catch(Exception ex)
  919. {
  920. MessageBox.Show(this, ex.Message,
  921. "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error);
  922. e.Cancel = true;
  923. return;
  924. }
  925. // Check whether the schema has a valid namespace.
  926. //if (schemaNamespace == null)
  927. //{
  928. // MessageBox.Show(this, "Could not import the file: " +
  929. // importLocation + ". The schema definition does not belong to a valid namespace.",
  930. // "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error);
  931. // wsdlWizardCtrl.JumpToPage(2);
  932. // return;
  933. //}
  934. //// Check whether the Namespace already exists in the list.
  935. //if (this.importedSchemaNamespaces.IndexOf(schemaNamespace.ToLower()) > -1)
  936. //{
  937. // MessageBox.Show(this, "Could not import the file: " +
  938. // importLocation + ". The Target Namespace already imported.",
  939. // "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error);
  940. // wsdlWizardCtrl.JumpToPage(2);
  941. // return;
  942. //}
  943. //else
  944. //{
  945. if(schemaNamespace != null)
  946. this.importedSchemaNamespaces.Add(schemaNamespace.ToLower());
  947. //}
  948. messageSchemas.AddRange((SchemaElements)result[1]);
  949. headerSchemas.AddRange((SchemaElements)result[1]);
  950. faultSchemas.AddRange((SchemaElements)result[1]);
  951. SchemaImport si = new SchemaImport(importItem.SubItems[1].Text, schemaNamespace, importItem.SubItems[0].Text);
  952. // Check whether the schema is in the current directory.
  953. if (Directory.GetFiles(this.wsdlLocation, si.SchemaName).Length > 0)
  954. {
  955. si.AlternateLocation = si.SchemaName;
  956. }
  957. else if (si.SchemaLocation.ToLower().StartsWith(this.projectRootDirectory.ToLower()))
  958. {
  959. string schemaDirectory = si.SchemaLocation.Substring(
  960. 0, si.SchemaLocation.LastIndexOf('\\'));
  961. string currentDirectory = wsdlLocation;
  962. // Remove the project root before passing them to the relative path finder.
  963. schemaDirectory = schemaDirectory.Substring(this.projectRootDirectory.Length);
  964. currentDirectory = currentDirectory.Substring(this.projectRootDirectory.Length);
  965. si.AlternateLocation = IOPathHelper.GetRelativePath(schemaDirectory, currentDirectory);
  966. if (si.AlternateLocation.EndsWith("/"))
  967. {
  968. si.AlternateLocation = si.AlternateLocation + si.SchemaName;
  969. }
  970. else
  971. {
  972. si.AlternateLocation = si.AlternateLocation + "/" + si.SchemaName;
  973. }
  974. }
  975. else
  976. {
  977. si.AlternateLocation = si.SchemaLocation;
  978. }
  979. serviceInterfaceContract.Imports.Add(si);
  980. }
  981. // Import the embedded types.
  982. ImportEmbeddedTypes();
  983. // Check for the messages count found in the imported files and alert the user if no messages
  984. // are found.
  985. if (messageSchemas.Count < 1)
  986. {
  987. MessageBox.Show("There are no elements in this XSD to use as operation messages.",
  988. "WSDL Wizard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  989. e.Cancel = true;
  990. return;
  991. }
  992. return;
  993. }
  994. if (e.Page == wizardPageMessageMapping)
  995. {
  996. try
  997. {
  998. // Setup the dynamic UI controls for the operation - message mapping UI.
  999. SetupOperationsMessagesPanes();
  1000. if (ptvServiceOperations.PaneNodes.Count > 0)
  1001. {
  1002. ptvServiceOperations.SelectedPaneNode = ptvServiceOperations.PaneNodes[0];
  1003. ptvServiceOperations.PaneNodes[0].Expanded = true;
  1004. }
  1005. }
  1006. catch (Exception ex)
  1007. {
  1008. MessageBox.Show(ex.Message);
  1009. }
  1010. return;
  1011. }
  1012. if (e.Page == wizardPageAdditionalOptions)
  1013. {
  1014. cbCodeGenDialog.Checked = this.roundtripMode;
  1015. return;
  1016. }
  1017. if (e.Page == wizardPageAlternativeXSDPaths)
  1018. {
  1019. xsdpathsListView.Items.Clear();
  1020. if (serviceInterfaceContract.Imports.Count > 0)
  1021. {
  1022. foreach (SchemaImport import in serviceInterfaceContract.Imports)
  1023. {
  1024. ListViewItem li = new ListViewItem(import.SchemaName);
  1025. li.SubItems.Add(import.AlternateLocation);
  1026. xsdpathsListView.Items.Add(li);
  1027. }
  1028. }
  1029. else
  1030. {
  1031. wsdlWizardCtrl.AdvancePage();
  1032. }
  1033. return;
  1034. }
  1035. }
  1036. /// <summary>
  1037. /// Handles the SelectedIndexChanged event of the dynami…

Large files files are truncated, but you can click here to view the full file