You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1896 lines
59 KiB

  1. <%--
  2. //
  3. // DefaultWsdlHelpGenerator.aspx:
  4. //
  5. // Author:
  6. // Lluis Sanchez Gual (lluis@ximian.com)
  7. //
  8. // (C) 2003 Ximian, Inc. http://www.ximian.com
  9. //
  10. --%>
  11. <%@ Import Namespace="System.Collections" %>
  12. <%@ Import Namespace="System.Collections.Generic" %>
  13. <%@ Import Namespace="System.IO" %>
  14. <%@ Import Namespace="System.Xml.Serialization" %>
  15. <%@ Import Namespace="System.Xml" %>
  16. <%@ Import Namespace="System.Xml.Schema" %>
  17. <%@ Import Namespace="System.Web.Services" %>
  18. <%@ Import Namespace="System.Web.Services.Description" %>
  19. <%@ Import Namespace="System.Web.Services.Configuration" %>
  20. <%@ Import Namespace="System.Web.Configuration" %>
  21. <%@ Import Namespace="System" %>
  22. <%@ Import Namespace="System.Net" %>
  23. <%@ Import Namespace="System.Globalization" %>
  24. <%@ Import Namespace="System.Resources" %>
  25. <%@ Import Namespace="System.Diagnostics" %>
  26. <%@ Import Namespace="System.CodeDom" %>
  27. <%@ Import Namespace="System.CodeDom.Compiler" %>
  28. <%@ Import Namespace="Microsoft.CSharp" %>
  29. <%@ Import Namespace="Microsoft.VisualBasic" %>
  30. <%@ Import Namespace="System.Text" %>
  31. <%@ Import Namespace="System.Text.RegularExpressions" %>
  32. <%@ Import Namespace="System.Security.Cryptography.X509Certificates" %>
  33. <%@ Assembly name="System.Web.Services" %>
  34. <%@ Page debug="true" %>
  35. <html>
  36. <script language="C#" runat="server">
  37. ServiceDescriptionCollection descriptions;
  38. XmlSchemas schemas;
  39. string WebServiceName;
  40. string WebServiceDescription;
  41. string PageName;
  42. string DefaultBinding;
  43. ArrayList ServiceProtocols;
  44. string CurrentOperationName;
  45. string CurrentOperationBinding;
  46. string OperationDocumentation;
  47. string CurrentOperationFormat;
  48. bool CurrentOperationSupportsTest;
  49. ArrayList InParams;
  50. ArrayList OutParams;
  51. string CurrentOperationProtocols;
  52. int CodeTextColumns = 95;
  53. BasicProfileViolationCollection ProfileViolations;
  54. void Page_Load(object sender, EventArgs e)
  55. {
  56. descriptions = (ServiceDescriptionCollection) Context.Items["wsdls"];
  57. schemas = (XmlSchemas) Context.Items["schemas"];
  58. ServiceDescription desc = descriptions [0];
  59. if (schemas.Count == 0) schemas = desc.Types.Schemas;
  60. Service service = desc.Services[0];
  61. WebServiceName = service.Name;
  62. if (desc.Bindings.Count == 0)
  63. return;
  64. DefaultBinding = desc.Bindings[0].Name;
  65. WebServiceDescription = service.Documentation;
  66. if (WebServiceDescription == "" || WebServiceDescription == null)
  67. WebServiceDescription = "Description has not been provided";
  68. ServiceProtocols = FindServiceProtocols (null);
  69. CurrentOperationName = Request.QueryString["op"];
  70. CurrentOperationBinding = Request.QueryString["bnd"];
  71. if (CurrentOperationName != null) BuildOperationInfo ();
  72. PageName = HttpUtility.UrlEncode (Path.GetFileName(Request.Path), Encoding.UTF8);
  73. ArrayList list = new ArrayList ();
  74. foreach (ServiceDescription sd in descriptions) {
  75. foreach (Binding bin in sd.Bindings)
  76. if (bin.Extensions.Find (typeof(SoapBinding)) != null) list.Add (bin);
  77. }
  78. BindingsRepeater.DataSource = list;
  79. Page.DataBind();
  80. ProfileViolations = new BasicProfileViolationCollection ();
  81. foreach (WsiProfilesElement claims in ((WebServicesSection) WebConfigurationManager.GetSection("system.web/webServices")).ConformanceWarnings)
  82. if (claims.Name != WsiProfiles.None)
  83. WebServicesInteroperability.CheckConformance (claims.Name, descriptions, ProfileViolations);
  84. }
  85. void BuildOperationInfo ()
  86. {
  87. InParams = new ArrayList ();
  88. OutParams = new ArrayList ();
  89. Port port = FindPort (CurrentOperationBinding, null);
  90. Binding binding = descriptions.GetBinding (port.Binding);
  91. PortType portType = descriptions.GetPortType (binding.Type);
  92. Operation oper = FindOperation (portType, CurrentOperationName);
  93. OperationDocumentation = oper.Documentation;
  94. if (OperationDocumentation == null || OperationDocumentation == "")
  95. OperationDocumentation = "No additional remarks";
  96. foreach (OperationMessage opm in oper.Messages)
  97. {
  98. if (opm is OperationInput)
  99. BuildParameters (InParams, opm);
  100. else if (opm is OperationOutput)
  101. BuildParameters (OutParams, opm);
  102. }
  103. // Protocols supported by the operation
  104. CurrentOperationProtocols = "";
  105. WebServiceProtocols testProtocols = 0;
  106. ArrayList prots = FindServiceProtocols (CurrentOperationName);
  107. for (int n=0; n<prots.Count; n++) {
  108. string prot = (string) prots [n];
  109. if (n != 0) CurrentOperationProtocols += ", ";
  110. CurrentOperationProtocols += prot;
  111. if (prot == "HttpGet")
  112. testProtocols |= WebServiceProtocols.HttpGet;
  113. else if (prot == "HttpPost") {
  114. testProtocols |= WebServiceProtocols.HttpPost;
  115. if (Context.Request.IsLocal)
  116. testProtocols |= WebServiceProtocols.HttpPostLocalhost;
  117. }
  118. }
  119. CurrentOperationSupportsTest = (WebServicesSection.Current.EnabledProtocols & testProtocols) != 0;
  120. // Operation format
  121. OperationBinding obin = FindOperation (binding, CurrentOperationName);
  122. if (obin != null)
  123. CurrentOperationFormat = GetOperationFormat (obin);
  124. InputParamsRepeater.DataSource = InParams;
  125. InputFormParamsRepeater.DataSource = InParams;
  126. OutputParamsRepeater.DataSource = OutParams;
  127. }
  128. void BuildParameters (ArrayList list, OperationMessage opm)
  129. {
  130. Message msg = descriptions.GetMessage (opm.Message);
  131. if (msg.Parts.Count > 0 && msg.Parts[0].Name == "parameters")
  132. {
  133. MessagePart part = msg.Parts[0];
  134. XmlSchemaComplexType ctype;
  135. if (part.Element == XmlQualifiedName.Empty)
  136. {
  137. ctype = (XmlSchemaComplexType) schemas.Find (part.Type, typeof(XmlSchemaComplexType));
  138. }
  139. else
  140. {
  141. XmlSchemaElement elem = (XmlSchemaElement) schemas.Find (part.Element, typeof(XmlSchemaElement));
  142. ctype = (XmlSchemaComplexType) elem.SchemaType;
  143. }
  144. XmlSchemaSequence seq = ctype.Particle as XmlSchemaSequence;
  145. if (seq == null) return;
  146. foreach (XmlSchemaObject ob in seq.Items)
  147. {
  148. Parameter p = new Parameter();
  149. p.Description = "No additional remarks";
  150. if (ob is XmlSchemaElement)
  151. {
  152. XmlSchemaElement selem = GetRefElement ((XmlSchemaElement)ob);
  153. p.Name = selem.Name;
  154. p.Type = selem.SchemaTypeName.Name;
  155. }
  156. else
  157. {
  158. p.Name = "Unknown";
  159. p.Type = "Unknown";
  160. }
  161. list.Add (p);
  162. }
  163. }
  164. else
  165. {
  166. foreach (MessagePart part in msg.Parts)
  167. {
  168. Parameter p = new Parameter ();
  169. p.Description = "No additional remarks";
  170. p.Name = part.Name;
  171. if (part.Element == XmlQualifiedName.Empty)
  172. p.Type = part.Type.Name;
  173. else
  174. {
  175. XmlSchemaElement elem = (XmlSchemaElement) schemas.Find (part.Element, typeof(XmlSchemaElement));
  176. p.Type = elem.SchemaTypeName.Name;
  177. }
  178. list.Add (p);
  179. }
  180. }
  181. }
  182. string GetOperationFormat (OperationBinding obin)
  183. {
  184. string format = "";
  185. SoapOperationBinding sob = obin.Extensions.Find (typeof(SoapOperationBinding)) as SoapOperationBinding;
  186. if (sob != null) {
  187. format = sob.Style.ToString ();
  188. SoapBodyBinding sbb = obin.Input.Extensions.Find (typeof(SoapBodyBinding)) as SoapBodyBinding;
  189. if (sbb != null)
  190. format += " / " + sbb.Use;
  191. }
  192. return format;
  193. }
  194. XmlSchemaElement GetRefElement (XmlSchemaElement elem)
  195. {
  196. if (!elem.RefName.IsEmpty)
  197. return (XmlSchemaElement) schemas.Find (elem.RefName, typeof(XmlSchemaElement));
  198. else
  199. return elem;
  200. }
  201. ArrayList FindServiceProtocols(string operName)
  202. {
  203. ArrayList table = new ArrayList ();
  204. Service service = descriptions[0].Services[0];
  205. foreach (Port port in service.Ports)
  206. {
  207. string prot = null;
  208. Binding bin = descriptions.GetBinding (port.Binding);
  209. if (bin.Extensions.Find (typeof(SoapBinding)) != null)
  210. prot = "Soap";
  211. else
  212. {
  213. HttpBinding hb = (HttpBinding) bin.Extensions.Find (typeof(HttpBinding));
  214. if (hb != null && hb.Verb == "POST") prot = "HttpPost";
  215. else if (hb != null && hb.Verb == "GET") prot = "HttpGet";
  216. }
  217. if (prot != null && operName != null)
  218. {
  219. if (FindOperation (bin, operName) == null)
  220. prot = null;
  221. }
  222. if (prot != null && !table.Contains (prot))
  223. table.Add (prot);
  224. }
  225. return table;
  226. }
  227. Port FindPort (string portName, string protocol)
  228. {
  229. Service service = descriptions[0].Services[0];
  230. foreach (Port port in service.Ports)
  231. {
  232. if (portName == null)
  233. {
  234. Binding binding = descriptions.GetBinding (port.Binding);
  235. if (GetProtocol (binding) == protocol) return port;
  236. }
  237. else if (port.Name == portName)
  238. return port;
  239. }
  240. return null;
  241. }
  242. string GetProtocol (Binding binding)
  243. {
  244. if (binding.Extensions.Find (typeof(SoapBinding)) != null) return "Soap";
  245. HttpBinding hb = (HttpBinding) binding.Extensions.Find (typeof(HttpBinding));
  246. if (hb == null) return "";
  247. if (hb.Verb == "POST") return "HttpPost";
  248. if (hb.Verb == "GET") return "HttpGet";
  249. return "";
  250. }
  251. Operation FindOperation (PortType portType, string name)
  252. {
  253. foreach (Operation oper in portType.Operations) {
  254. if (oper.Messages.Input.Name != null) {
  255. if (oper.Messages.Input.Name == name) return oper;
  256. }
  257. else
  258. if (oper.Name == name) return oper;
  259. }
  260. return null;
  261. }
  262. OperationBinding FindOperation (Binding binding, string name)
  263. {
  264. foreach (OperationBinding oper in binding.Operations) {
  265. if (oper.Input.Name != null) {
  266. if (oper.Input.Name == name) return oper;
  267. }
  268. else
  269. if (oper.Name == name) return oper;
  270. }
  271. return null;
  272. }
  273. string FormatBindingName (string name)
  274. {
  275. if (name == DefaultBinding) return "Methods";
  276. else return "Methods for binding<br>" + name;
  277. }
  278. string GetOpName (object op)
  279. {
  280. OperationBinding ob = op as OperationBinding;
  281. if (ob == null) return "";
  282. if (ob.Input.Name != null) return ob.Input.Name;
  283. else return ob.Name;
  284. }
  285. bool HasFormResult
  286. {
  287. get { return Request.QueryString ["ext"] == "testform"; }
  288. }
  289. class NoCheckCertificatePolicy : ICertificatePolicy {
  290. public bool CheckValidationResult (ServicePoint a, X509Certificate b, WebRequest c, int d)
  291. {
  292. return true;
  293. }
  294. }
  295. string GetOrPost ()
  296. {
  297. return (CurrentOperationProtocols.IndexOf ("HttpGet") >= 0) ? "GET" : "POST";
  298. }
  299. string GetQS ()
  300. {
  301. bool fill = false;
  302. string qs = "";
  303. NameValueCollection query_string = Request.QueryString;
  304. for (int n = 0; n < query_string.Count; n++) {
  305. if (fill) {
  306. if (qs != "") qs += "&";
  307. qs += query_string.GetKey(n) + "=" + Server.UrlEncode (query_string [n]);
  308. }
  309. if (query_string.GetKey(n) == "ext") fill = true;
  310. }
  311. return qs;
  312. }
  313. string GetTestResultUrl ()
  314. {
  315. if (!HasFormResult) return "";
  316. string location = null;
  317. ServiceDescription desc = descriptions [0];
  318. Service service = desc.Services[0];
  319. foreach (Port port in service.Ports)
  320. if (port.Name == CurrentOperationBinding)
  321. {
  322. SoapAddressBinding sbi = (SoapAddressBinding) port.Extensions.Find (typeof(SoapAddressBinding));
  323. if (sbi != null)
  324. location = sbi.Location;
  325. }
  326. if (location == null)
  327. return "Could not locate web service";
  328. return location + "/" + CurrentOperationName;
  329. }
  330. string GenerateOperationMessages (string protocol, bool generateInput)
  331. {
  332. if (!IsOperationSupported (protocol)) return "";
  333. Port port;
  334. if (protocol != "Soap") port = FindPort (null, protocol);
  335. else port = FindPort (CurrentOperationBinding, null);
  336. Binding binding = descriptions.GetBinding (port.Binding);
  337. OperationBinding obin = FindOperation (binding, CurrentOperationName);
  338. PortType portType = descriptions.GetPortType (binding.Type);
  339. Operation oper = FindOperation (portType, CurrentOperationName);
  340. HtmlSampleGenerator sg = new HtmlSampleGenerator (descriptions, schemas);
  341. string txt = sg.GenerateMessage (port, obin, oper, protocol, generateInput);
  342. if (protocol == "Soap") txt = WrapText (txt,CodeTextColumns);
  343. txt = ColorizeXml (txt);
  344. txt = txt.Replace ("@placeholder!","<span class='literal-placeholder'>");
  345. txt = txt.Replace ("!placeholder@","</span>");
  346. return txt;
  347. }
  348. bool IsOperationSupported (string protocol)
  349. {
  350. if (CurrentPage != "op" || CurrentTab != "msg") return false;
  351. if (protocol == "Soap") return true;
  352. Port port = FindPort (null, protocol);
  353. if (port == null) return false;
  354. Binding binding = descriptions.GetBinding (port.Binding);
  355. if (binding == null) return false;
  356. return FindOperation (binding, CurrentOperationName) != null;
  357. }
  358. //
  359. // Proxy code generation
  360. //
  361. string GetProxyCode ()
  362. {
  363. CodeNamespace codeNamespace = new CodeNamespace();
  364. CodeCompileUnit codeUnit = new CodeCompileUnit();
  365. codeUnit.Namespaces.Add (codeNamespace);
  366. ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
  367. foreach (ServiceDescription sd in descriptions)
  368. importer.AddServiceDescription(sd, null, null);
  369. foreach (XmlSchema sc in schemas)
  370. importer.Schemas.Add (sc);
  371. importer.Import(codeNamespace, codeUnit);
  372. string langId = Request.QueryString ["lang"];
  373. if (langId == null || langId == "") langId = "cs";
  374. CodeDomProvider provider = GetProvider (langId);
  375. ICodeGenerator generator = provider.CreateGenerator();
  376. CodeGeneratorOptions options = new CodeGeneratorOptions();
  377. StringWriter sw = new StringWriter ();
  378. generator.GenerateCodeFromCompileUnit(codeUnit, sw, options);
  379. return Colorize (WrapText (sw.ToString (), CodeTextColumns), langId);
  380. }
  381. public string CurrentLanguage
  382. {
  383. get {
  384. string langId = Request.QueryString ["lang"];
  385. if (langId == null || langId == "") langId = "cs";
  386. return langId;
  387. }
  388. }
  389. public string CurrentProxytName
  390. {
  391. get {
  392. string lan = CurrentLanguage == "cs" ? "C#" : "Visual Basic";
  393. return lan + " Client Proxy";
  394. }
  395. }
  396. private CodeDomProvider GetProvider(string langId)
  397. {
  398. switch (langId.ToUpper())
  399. {
  400. case "CS": return new CSharpCodeProvider();
  401. case "VB": return new VBCodeProvider();
  402. default: return null;
  403. }
  404. }
  405. //
  406. // Document generation
  407. //
  408. string GenerateDocument ()
  409. {
  410. StringWriter sw = new StringWriter ();
  411. if (CurrentDocType == "wsdl")
  412. descriptions [CurrentDocInd].Write (sw);
  413. else if (CurrentDocType == "schema")
  414. schemas [CurrentDocInd].Write (sw);
  415. return Colorize (WrapText (sw.ToString (), CodeTextColumns), "xml");
  416. }
  417. public string CurrentDocType
  418. {
  419. get { return Request.QueryString ["doctype"] != null ? Request.QueryString ["doctype"] : "wsdl"; }
  420. }
  421. public int CurrentDocInd
  422. {
  423. get { return Request.QueryString ["docind"] != null ? int.Parse (Request.QueryString ["docind"]) : 0; }
  424. }
  425. public string CurrentDocumentName
  426. {
  427. get {
  428. if (CurrentDocType == "wsdl")
  429. return "WSDL document for namespace \"" + descriptions [CurrentDocInd].TargetNamespace + "\"";
  430. else
  431. return "Xml Schema for namespace \"" + schemas [CurrentDocInd].TargetNamespace + "\"";
  432. }
  433. }
  434. //
  435. // Pages and tabs
  436. //
  437. bool firstTab = true;
  438. ArrayList disabledTabs = new ArrayList ();
  439. string CurrentTab
  440. {
  441. get { return Request.QueryString["tab"] != null ? Request.QueryString["tab"] : "main" ; }
  442. }
  443. string CurrentPage
  444. {
  445. get { return Request.QueryString["page"] != null ? Request.QueryString["page"] : "main" ; }
  446. }
  447. void WriteTabs ()
  448. {
  449. if (CurrentOperationName != null)
  450. {
  451. WriteTab ("main","Overview");
  452. WriteTab ("test","Test Form");
  453. WriteTab ("msg","Message Layout");
  454. }
  455. }
  456. void WriteTab (string id, string label)
  457. {
  458. if (!firstTab) Response.Write("&nbsp;|&nbsp;");
  459. firstTab = false;
  460. string cname = CurrentTab == id ? "tabLabelOn" : "tabLabelOff";
  461. Response.Write ("<a href='" + PageName + "?" + GetPageContext(null) + GetDataContext() + "tab=" + id + "' style='text-decoration:none'>");
  462. Response.Write ("<span class='" + cname + "'>" + label + "</span>");
  463. Response.Write ("</a>");
  464. }
  465. string GetTabContext (string pag, string tab)
  466. {
  467. if (tab == null) tab = CurrentTab;
  468. if (pag == null) pag = CurrentPage;
  469. if (pag != CurrentPage) tab = "main";
  470. return "page=" + pag + "&tab=" + tab + "&";
  471. }
  472. string GetPageContext (string pag)
  473. {
  474. if (pag == null) pag = CurrentPage;
  475. return "page=" + pag + "&";
  476. }
  477. class Tab
  478. {
  479. public string Id;
  480. public string Label;
  481. }
  482. //
  483. // Syntax coloring
  484. //
  485. static string keywords_cs =
  486. "(\\babstract\\b|\\bevent\\b|\\bnew\\b|\\bstruct\\b|\\bas\\b|\\bexplicit\\b|\\bnull\\b|\\bswitch\\b|\\bbase\\b|\\bextern\\b|" +
  487. "\\bobject\\b|\\bthis\\b|\\bbool\\b|\\bfalse\\b|\\boperator\\b|\\bthrow\\b|\\bbreak\\b|\\bfinally\\b|\\bout\\b|\\btrue\\b|" +
  488. "\\bbyte\\b|\\bfixed\\b|\\boverride\\b|\\btry\\b|\\bcase\\b|\\bfloat\\b|\\bparams\\b|\\btypeof\\b|\\bcatch\\b|\\bfor\\b|" +
  489. "\\bprivate\\b|\\buint\\b|\\bchar\\b|\\bforeach\\b|\\bprotected\\b|\\bulong\\b|\\bchecked\\b|\\bgoto\\b|\\bpublic\\b|" +
  490. "\\bunchecked\\b|\\bclass\\b|\\bif\\b|\\breadonly\\b|\\bunsafe\\b|\\bconst\\b|\\bimplicit\\b|\\bref\\b|\\bushort\\b|" +
  491. "\\bcontinue\\b|\\bin\\b|\\breturn\\b|\\busing\\b|\\bdecimal\\b|\\bint\\b|\\bsbyte\\b|\\bvirtual\\b|\\bdefault\\b|" +
  492. "\\binterface\\b|\\bsealed\\b|\\bvolatile\\b|\\bdelegate\\b|\\binternal\\b|\\bshort\\b|\\bvoid\\b|\\bdo\\b|\\bis\\b|" +
  493. "\\bsizeof\\b|\\bwhile\\b|\\bdouble\\b|\\block\\b|\\bstackalloc\\b|\\belse\\b|\\blong\\b|\\bstatic\\b|\\benum\\b|" +
  494. "\\bnamespace\\b|\\bstring\\b)";
  495. static string keywords_vb =
  496. "(\\bAddHandler\\b|\\bAddressOf\\b|\\bAlias\\b|\\bAnd\\b|\\bAndAlso\\b|\\bAnsi\\b|\\bAs\\b|\\bAssembly\\b|" +
  497. "\\bAuto\\b|\\bBoolean\\b|\\bByRef\\b|\\bByte\\b|\\bByVal\\b|\\bCall\\b|\\bCase\\b|\\bCatch\\b|" +
  498. "\\bCBool\\b|\\bCByte\\b|\\bCChar\\b|\\bCDate\\b|\\bCDec\\b|\\bCDbl\\b|\\bChar\\b|\\bCInt\\b|" +
  499. "\\bClass\\b|\\bCLng\\b|\\bCObj\\b|\\bConst\\b|\\bCShort\\b|\\bCSng\\b|\\bCStr\\b|\\bCType\\b|" +
  500. "\\bDate\\b|\\bDecimal\\b|\\bDeclare\\b|\\bDefault\\b|\\bDelegate\\b|\\bDim\\b|\\bDirectCast\\b|\\bDo\\b|" +
  501. "\\bDouble\\b|\\bEach\\b|\\bElse\\b|\\bElseIf\\b|\\bEnd\\b|\\bEnum\\b|\\bErase\\b|\\bError\\b|" +
  502. "\\bEvent\\b|\\bExit\\b|\\bFalse\\b|\\bFinally\\b|\\bFor\\b|\\bFriend\\b|\\bFunction\\b|\\bGet\\b|" +
  503. "\\bGetType\\b|\\bGoSub\\b|\\bGoTo\\b|\\bHandles\\b|\\bIf\\b|\\bImplements\\b|\\bImports\\b|\\bIn\\b|" +
  504. "\\bInherits\\b|\\bInteger\\b|\\bInterface\\b|\\bIs\\b|\\bLet\\b|\\bLib\\b|\\bLike\\b|\\bLong\\b|" +
  505. "\\bLoop\\b|\\bMe\\b|\\bMod\\b|\\bModule\\b|\\bMustInherit\\b|\\bMustOverride\\b|\\bMyBase\\b|\\bMyClass\\b|" +
  506. "\\bNamespace\\b|\\bNew\\b|\\bNext\\b|\\bNot\\b|\\bNothing\\b|\\bNotInheritable\\b|\\bNotOverridable\\b|\\bObject\\b|" +
  507. "\\bOn\\b|\\bOption\\b|\\bOptional\\b|\\bOr\\b|\\bOrElse\\b|\\bOverloads\\b|\\bOverridable\\b|\\bOverrides\\b|" +
  508. "\\bParamArray\\b|\\bPreserve\\b|\\bPrivate\\b|\\bProperty\\b|\\bProtected\\b|\\bPublic\\b|\\bRaiseEvent\\b|\\bReadOnly\\b|" +
  509. "\\bReDim\\b|\\bREM\\b|\\bRemoveHandler\\b|\\bResume\\b|\\bReturn\\b|\\bSelect\\b|\\bSet\\b|\\bShadows\\b|" +
  510. "\\bShared\\b|\\bShort\\b|\\bSingle\\b|\\bStatic\\b|\\bStep\\b|\\bStop\\b|\\bString\\b|\\bStructure\\b|" +
  511. "\\bSub\\b|\\bSyncLock\\b|\\bThen\\b|\\bThrow\\b|\\bTo\\b|\\bTrue\\b|\\bTry\\b|\\bTypeOf\\b|" +
  512. "\\bUnicode\\b|\\bUntil\\b|\\bVariant\\b|\\bWhen\\b|\\bWhile\\b|\\bWith\\b|\\bWithEvents\\b|\\bWriteOnly\\b|\\bXor\\b)";
  513. string Colorize (string text, string lang)
  514. {
  515. if (lang == "xml") return ColorizeXml (text);
  516. else if (lang == "cs") return ColorizeCs (text);
  517. else if (lang == "vb") return ColorizeVb (text);
  518. else return text;
  519. }
  520. string ColorizeXml (string text)
  521. {
  522. text = text.Replace (" ", "&nbsp;");
  523. Regex re = new Regex ("\r\n|\r|\n");
  524. text = re.Replace (text, "_br_");
  525. re = new Regex ("<\\s*(\\/?)\\s*([\\s\\S]*?)\\s*(\\/?)\\s*>");
  526. text = re.Replace (text,"{blue:&lt;$1}{maroon:$2}{blue:$3&gt;}");
  527. re = new Regex ("\\{(\\w*):([\\s\\S]*?)\\}");
  528. text = re.Replace (text,"<span style='color:$1'>$2</span>");
  529. re = new Regex ("\"(.*?)\"");
  530. text = re.Replace (text,"\"<span style='color:purple'>$1</span>\"");
  531. text = text.Replace ("\t", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
  532. text = text.Replace ("_br_", "<br>");
  533. return text;
  534. }
  535. string ColorizeCs (string text)
  536. {
  537. text = text.Replace (" ", "&nbsp;");
  538. text = text.Replace ("<", "&lt;");
  539. text = text.Replace (">", "&gt;");
  540. Regex re = new Regex ("\"((((?!\").)|\\\")*?)\"");
  541. text = re.Replace (text,"<span style='color:purple'>\"$1\"</span>");
  542. re = new Regex ("//(((.(?!\"</span>))|\"(((?!\").)*)\"</span>)*)(\r|\n|\r\n)");
  543. text = re.Replace (text,"<span style='color:green'>//$1</span><br/>");
  544. re = new Regex (keywords_cs);
  545. text = re.Replace (text,"<span style='color:blue'>$1</span>");
  546. text = text.Replace ("\t","&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
  547. text = text.Replace ("\n","<br/>");
  548. return text;
  549. }
  550. string ColorizeVb (string text)
  551. {
  552. text = text.Replace (" ", "&nbsp;");
  553. /* Regex re = new Regex ("\"((((?!\").)|\\\")*?)\"");
  554. text = re.Replace (text,"<span style='color:purple'>\"$1\"</span>");
  555. re = new Regex ("'(((.(?!\"\\<\\/span\\>))|\"(((?!\").)*)\"\\<\\/span\\>)*)(\r|\n|\r\n)");
  556. text = re.Replace (text,"<span style='color:green'>//$1</span><br/>");
  557. re = new Regex (keywords_vb);
  558. text = re.Replace (text,"<span style='color:blue'>$1</span>");
  559. */
  560. text = text.Replace ("\t","&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
  561. text = text.Replace ("\n","<br/>");
  562. return text;
  563. }
  564. //
  565. // Helper methods and classes
  566. //
  567. string GetDataContext ()
  568. {
  569. return "op=" + CurrentOperationName + "&bnd=" + CurrentOperationBinding + "&";
  570. }
  571. string GetOptionSel (string v1, string v2)
  572. {
  573. string op = "<option ";
  574. if (v1 == v2) op += "selected ";
  575. return op + "value='" + v1 + "'>";
  576. }
  577. string WrapText (string text, int maxChars)
  578. {
  579. text = text.Replace(" />","/>");
  580. string linspace = null;
  581. int lincount = 0;
  582. int breakpos = 0;
  583. int linstart = 0;
  584. bool inquotes = false;
  585. char lastc = ' ';
  586. string sublineIndent = "";
  587. System.Text.StringBuilder sb = new System.Text.StringBuilder ();
  588. for (int n=0; n<text.Length; n++)
  589. {
  590. char c = text [n];
  591. if (c=='\r' || c=='\n' || n==text.Length-1)
  592. {
  593. sb.Append (linspace + sublineIndent + text.Substring (linstart, n-linstart+1));
  594. linspace = null;
  595. lincount = 0;
  596. linstart = n+1;
  597. breakpos = linstart;
  598. sublineIndent = "";
  599. lastc = c;
  600. continue;
  601. }
  602. if (lastc==',' || lastc=='(')
  603. {
  604. if (!inquotes) breakpos = n;
  605. }
  606. if (lincount > maxChars && breakpos >= linstart)
  607. {
  608. if (linspace != null)
  609. sb.Append (linspace + sublineIndent);
  610. sb.Append (text.Substring (linstart, breakpos-linstart));
  611. sb.Append ("\n");
  612. sublineIndent = " ";
  613. lincount = linspace.Length + sublineIndent.Length + (n-breakpos);
  614. linstart = breakpos;
  615. }
  616. if (c==' ' || c=='\t')
  617. {
  618. if (!inquotes)
  619. breakpos = n;
  620. }
  621. else if (c=='"')
  622. {
  623. inquotes = !inquotes;
  624. }
  625. else
  626. if (linspace == null) {
  627. linspace = text.Substring (linstart, n-linstart);
  628. linstart = n;
  629. }
  630. lincount++;
  631. lastc = c;
  632. }
  633. return sb.ToString ();
  634. }
  635. class Parameter
  636. {
  637. string name;
  638. string type;
  639. string description;
  640. public string Name { get { return name; } set { name = value; } }
  641. public string Type { get { return type; } set { type = value; } }
  642. public string Description { get { return description; } set { description = value; } }
  643. }
  644. public class HtmlSampleGenerator: SampleGenerator
  645. {
  646. public HtmlSampleGenerator (ServiceDescriptionCollection services, XmlSchemas schemas)
  647. : base (services, schemas)
  648. {
  649. }
  650. protected override string GetLiteral (string s)
  651. {
  652. return "@placeholder!" + s + "!placeholder@";
  653. }
  654. }
  655. public class SampleGenerator
  656. {
  657. protected ServiceDescriptionCollection descriptions;
  658. protected XmlSchemas schemas;
  659. XmlSchemaElement anyElement;
  660. ArrayList queue;
  661. SoapBindingUse currentUse;
  662. XmlDocument document = new XmlDocument ();
  663. static readonly XmlQualifiedName anyType = new XmlQualifiedName ("anyType",XmlSchema.Namespace);
  664. static readonly XmlQualifiedName arrayType = new XmlQualifiedName ("Array","http://schemas.xmlsoap.org/soap/encoding/");
  665. static readonly XmlQualifiedName arrayTypeRefName = new XmlQualifiedName ("arrayType","http://schemas.xmlsoap.org/soap/encoding/");
  666. const string SoapEnvelopeNamespace = "http://schemas.xmlsoap.org/soap/envelope/";
  667. const string WsdlNamespace = "http://schemas.xmlsoap.org/wsdl/";
  668. const string SoapEncodingNamespace = "http://schemas.xmlsoap.org/soap/encoding/";
  669. class EncodedType
  670. {
  671. public EncodedType (string ns, XmlSchemaElement elem) { Namespace = ns; Element = elem; }
  672. public string Namespace;
  673. public XmlSchemaElement Element;
  674. }
  675. public SampleGenerator (ServiceDescriptionCollection services, XmlSchemas schemas)
  676. {
  677. descriptions = services;
  678. this.schemas = schemas;
  679. queue = new ArrayList ();
  680. }
  681. public string GenerateMessage (Port port, OperationBinding obin, Operation oper, string protocol, bool generateInput)
  682. {
  683. OperationMessage msg = null;
  684. foreach (OperationMessage opm in oper.Messages)
  685. {
  686. if (opm is OperationInput && generateInput) msg = opm;
  687. else if (opm is OperationOutput && !generateInput) msg = opm;
  688. }
  689. if (msg == null) return null;
  690. switch (protocol) {
  691. case "Soap": return GenerateHttpSoapMessage (port, obin, oper, msg);
  692. case "HttpGet": return GenerateHttpGetMessage (port, obin, oper, msg);
  693. case "HttpPost": return GenerateHttpPostMessage (port, obin, oper, msg);
  694. }
  695. return "Unknown protocol";
  696. }
  697. public string GenerateHttpSoapMessage (Port port, OperationBinding obin, Operation oper, OperationMessage msg)
  698. {
  699. string req = "";
  700. if (msg is OperationInput)
  701. {
  702. SoapAddressBinding sab = port.Extensions.Find (typeof(SoapAddressBinding)) as SoapAddressBinding;
  703. SoapOperationBinding sob = obin.Extensions.Find (typeof(SoapOperationBinding)) as SoapOperationBinding;
  704. req += "POST " + new Uri (sab.Location).AbsolutePath + "\n";
  705. req += "SOAPAction: " + sob.SoapAction + "\n";
  706. req += "Content-Type: text/xml; charset=utf-8\n";
  707. req += "Content-Length: " + GetLiteral ("string") + "\n";
  708. req += "Host: " + GetLiteral ("string") + "\n\n";
  709. }
  710. else
  711. {
  712. req += "HTTP/1.0 200 OK\n";
  713. req += "Content-Type: text/xml; charset=utf-8\n";
  714. req += "Content-Length: " + GetLiteral ("string") + "\n\n";
  715. }
  716. req += GenerateSoapMessage (obin, oper, msg);
  717. return req;
  718. }
  719. public string GenerateHttpGetMessage (Port port, OperationBinding obin, Operation oper, OperationMessage msg)
  720. {
  721. string req = "";
  722. if (msg is OperationInput)
  723. {
  724. HttpAddressBinding sab = port.Extensions.Find (typeof(HttpAddressBinding)) as HttpAddressBinding;
  725. HttpOperationBinding sob = obin.Extensions.Find (typeof(HttpOperationBinding)) as HttpOperationBinding;
  726. string location = new Uri (sab.Location).AbsolutePath + sob.Location + "?" + BuildQueryString (msg);
  727. req += "GET " + location + "\n";
  728. req += "Host: " + GetLiteral ("string");
  729. }
  730. else
  731. {
  732. req += "HTTP/1.0 200 OK\n";
  733. req += "Content-Type: text/xml; charset=utf-8\n";
  734. req += "Content-Length: " + GetLiteral ("string") + "\n\n";
  735. MimeXmlBinding mxb = (MimeXmlBinding) obin.Output.Extensions.Find (typeof(MimeXmlBinding)) as MimeXmlBinding;
  736. if (mxb == null) return req;
  737. Message message = descriptions.GetMessage (msg.Message);
  738. XmlQualifiedName ename = null;
  739. foreach (MessagePart part in message.Parts)
  740. if (part.Name == mxb.Part) ename = part.Element;
  741. if (ename == null) return req + GetLiteral("string");
  742. StringWriter sw = new StringWriter ();
  743. XmlTextWriter xtw = new XmlTextWriter (sw);
  744. xtw.Formatting = Formatting.Indented;
  745. currentUse = SoapBindingUse.Literal;
  746. WriteRootElementSample (xtw, ename);
  747. xtw.Close ();
  748. req += sw.ToString ();
  749. }
  750. return req;
  751. }
  752. public string GenerateHttpPostMessage (Port port, OperationBinding obin, Operation oper, OperationMessage msg)
  753. {
  754. string req = "";
  755. if (msg is OperationInput)
  756. {
  757. HttpAddressBinding sab = port.Extensions.Find (typeof(HttpAddressBinding)) as HttpAddressBinding;
  758. HttpOperationBinding sob = obin.Extensions.Find (typeof(HttpOperationBinding)) as HttpOperationBinding;
  759. string location = new Uri (sab.Location).AbsolutePath + sob.Location;
  760. req += "POST " + location + "\n";
  761. req += "Content-Type: application/x-www-form-urlencoded\n";
  762. req += "Content-Length: " + GetLiteral ("string") + "\n";
  763. req += "Host: " + GetLiteral ("string") + "\n\n";
  764. req += BuildQueryString (msg);
  765. }
  766. else return GenerateHttpGetMessage (port, obin, oper, msg);
  767. return req;
  768. }
  769. string BuildQueryString (OperationMessage opm)
  770. {
  771. string s = "";
  772. Message msg = descriptions.GetMessage (opm.Message);
  773. foreach (MessagePart part in msg.Parts)
  774. {
  775. if (s.Length != 0) s += "&";
  776. s += part.Name + "=" + GetLiteral (part.Type.Name);
  777. }
  778. return s;
  779. }
  780. public string GenerateSoapMessage (OperationBinding obin, Operation oper, OperationMessage msg)
  781. {
  782. SoapOperationBinding sob = obin.Extensions.Find (typeof(SoapOperationBinding)) as SoapOperationBinding;
  783. SoapBindingStyle style = (sob != null) ? sob.Style : SoapBindingStyle.Document;
  784. MessageBinding msgbin = (msg is OperationInput) ? (MessageBinding) obin.Input : (MessageBinding)obin.Output;
  785. SoapBodyBinding sbb = msgbin.Extensions.Find (typeof(SoapBodyBinding)) as SoapBodyBinding;
  786. SoapBindingUse bodyUse = (sbb != null) ? sbb.Use : SoapBindingUse.Literal;
  787. StringWriter sw = new StringWriter ();
  788. XmlTextWriter xtw = new XmlTextWriter (sw);
  789. xtw.Formatting = Formatting.Indented;
  790. xtw.WriteStartDocument ();
  791. xtw.WriteStartElement ("soap", "Envelope", SoapEnvelopeNamespace);
  792. xtw.WriteAttributeString ("xmlns", "xsi", null, XmlSchema.InstanceNamespace);
  793. xtw.WriteAttributeString ("xmlns", "xsd", null, XmlSchema.Namespace);
  794. if (bodyUse == SoapBindingUse.Encoded)
  795. {
  796. xtw.WriteAttributeString ("xmlns", "soapenc", null, SoapEncodingNamespace);
  797. xtw.WriteAttributeString ("xmlns", "tns", null, msg.Message.Namespace);
  798. }
  799. // Serialize headers
  800. bool writtenHeader = false;
  801. foreach (object ob in msgbin.Extensions)
  802. {
  803. SoapHeaderBinding hb = ob as SoapHeaderBinding;
  804. if (hb == null) continue;
  805. if (!writtenHeader) {
  806. xtw.WriteStartElement ("soap", "Header", SoapEnvelopeNamespace);
  807. writtenHeader = true;
  808. }
  809. WriteHeader (xtw, hb);
  810. }
  811. if (writtenHeader)
  812. xtw.WriteEndElement ();
  813. // Serialize body
  814. xtw.WriteStartElement ("soap", "Body", SoapEnvelopeNamespace);
  815. currentUse = bodyUse;
  816. WriteBody (xtw, oper, msg, sbb, style);
  817. xtw.WriteEndElement ();
  818. xtw.WriteEndElement ();
  819. xtw.Close ();
  820. return sw.ToString ();
  821. }
  822. void WriteHeader (XmlTextWriter xtw, SoapHeaderBinding header)
  823. {
  824. Message msg = descriptions.GetMessage (header.Message);
  825. if (msg == null) throw new InvalidOperationException ("Message " + header.Message + " not found");
  826. MessagePart part = msg.Parts [header.Part];
  827. if (part == null) throw new InvalidOperationException ("Message part " + header.Part + " not found in message " + header.Message);
  828. currentUse = header.Use;
  829. if (currentUse == SoapBindingUse.Literal)
  830. WriteRootElementSample (xtw, part.Element);
  831. else
  832. WriteTypeSample (xtw, part.Type);
  833. }
  834. void WriteBody (XmlTextWriter xtw, Operation oper, OperationMessage opm, SoapBodyBinding sbb, SoapBindingStyle style)
  835. {
  836. Message msg = descriptions.GetMessage (opm.Message);
  837. if (msg.Parts.Count > 0 && msg.Parts[0].Name == "parameters")
  838. {
  839. MessagePart part = msg.Parts[0];
  840. if (part.Element == XmlQualifiedName.Empty)
  841. WriteTypeSample (xtw, part.Type);
  842. else
  843. WriteRootElementSample (xtw, part.Element);
  844. }
  845. else
  846. {
  847. string elemName = oper.Name;
  848. string ns = "";
  849. if (opm is OperationOutput) elemName += "Response";
  850. if (style == SoapBindingStyle.Rpc) {
  851. xtw.WriteStartElement (elemName, sbb.Namespace);
  852. ns = sbb.Namespace;
  853. }
  854. foreach (MessagePart part in msg.Parts)
  855. {
  856. if (part.Element == XmlQualifiedName.Empty)
  857. {
  858. XmlSchemaElement elem = new XmlSchemaElement ();
  859. elem.SchemaTypeName = part.Type;
  860. elem.Name = part.Name;
  861. WriteElementSample (xtw, ns, elem);
  862. }
  863. else
  864. WriteRootElementSample (xtw, part.Element);
  865. }
  866. if (style == SoapBindingStyle.Rpc)
  867. xtw.WriteEndElement ();
  868. }
  869. WriteQueuedTypeSamples (xtw);
  870. }
  871. void WriteRootElementSample (XmlTextWriter xtw, XmlQualifiedName qname)
  872. {
  873. XmlSchemaElement elem = (XmlSchemaElement) schemas.Find (qname, typeof(XmlSchemaElement));
  874. if (elem == null) throw new InvalidOperationException ("Element not found: " + qname);
  875. WriteElementSample (xtw, qname.Namespace, elem);
  876. }
  877. void WriteElementSample (XmlTextWriter xtw, string ns, XmlSchemaElement elem)
  878. {
  879. bool sharedAnnType = false;
  880. XmlQualifiedName root;
  881. if (!elem.RefName.IsEmpty) {
  882. XmlSchemaElement refElem = FindRefElement (elem);
  883. if (refElem == null) throw new InvalidOperationException ("Global element not found: " + elem.RefName);
  884. root = elem.RefName;
  885. elem = refElem;
  886. sharedAnnType = true;
  887. }
  888. else
  889. root = new XmlQualifiedName (elem.Name, ns);
  890. if (!elem.SchemaTypeName.IsEmpty)
  891. {
  892. XmlSchemaComplexType st = FindComplexTyype (elem.SchemaTypeName);
  893. if (st != null)
  894. WriteComplexTypeSample (xtw, st, root);
  895. else
  896. {
  897. xtw.WriteStartElement (root.Name, root.Namespace);
  898. if (currentUse == SoapBindingUse.Encoded)
  899. xtw.WriteAttributeString ("type", XmlSchema.InstanceNamespace, GetQualifiedNameString (xtw, elem.SchemaTypeName));
  900. xtw.WriteString (GetLiteral (FindBuiltInType (elem.SchemaTypeName)));
  901. xtw.WriteEndElement ();
  902. }
  903. }
  904. else if (elem.SchemaType == null)
  905. {
  906. xtw.WriteStartElement ("any");
  907. xtw.WriteEndElement ();
  908. }
  909. else
  910. WriteComplexTypeSample (xtw, (XmlSchemaComplexType) elem.SchemaType, root);
  911. }
  912. void WriteTypeSample (XmlTextWriter xtw, XmlQualifiedName qname)
  913. {
  914. XmlSchemaComplexType ctype = FindComplexTyype (qname);
  915. if (ctype != null) {
  916. WriteComplexTypeSample (xtw, ctype, qname);
  917. return;
  918. }
  919. XmlSchemaSimpleType stype = (XmlSchemaSimpleType) schemas.Find (qname, typeof(XmlSchemaSimpleType));
  920. if (stype != null) {
  921. WriteSimpleTypeSample (xtw, stype);
  922. return;
  923. }
  924. xtw.WriteString (GetLiteral (FindBuiltInType (qname)));
  925. throw new InvalidOperationException ("Type not found: " + qname);
  926. }
  927. void WriteComplexTypeSample (XmlTextWriter xtw, XmlSchemaComplexType stype, XmlQualifiedName rootName)
  928. {
  929. WriteComplexTypeSample (xtw, stype, rootName, -1);
  930. }
  931. void WriteComplexTypeSample (XmlTextWriter xtw, XmlSchemaComplexType stype, XmlQualifiedName rootName, int id)
  932. {
  933. string ns = rootName.Namespace;
  934. if (rootName.Name.IndexOf ("[]") != -1) rootName = arrayType;
  935. if (currentUse == SoapBindingUse.Encoded) {
  936. string pref = xtw.LookupPrefix (rootName.Namespace);
  937. if (pref == null) pref = "q1";
  938. xtw.WriteStartElement (pref, rootName.Name, rootName.Namespace);
  939. ns = "";
  940. }
  941. else
  942. xtw.WriteStartElement (rootName.Name, rootName.Namespace);
  943. if (id != -1)
  944. {
  945. xtw.WriteAttributeString ("id", "id" + id);
  946. if (rootName != arrayType)
  947. xtw.WriteAttributeString ("type", XmlSchema.InstanceNamespace, GetQualifiedNameString (xtw, rootName));
  948. }
  949. WriteComplexTypeAttributes (xtw, stype);
  950. WriteComplexTypeElements (xtw, ns, stype);
  951. xtw.WriteEndElement ();
  952. }
  953. void WriteComplexTypeAttributes (XmlTextWriter xtw, XmlSchemaComplexType stype)
  954. {
  955. WriteAttributes (xtw, stype.Attributes, stype.AnyAttribute);
  956. }
  957. Dictionary<XmlSchemaComplexType,int> recursed_types = new Dictionary<XmlSchemaComplexType,int> ();
  958. void WriteComplexTypeElements (XmlTextWriter xtw, string ns, XmlSchemaComplexType stype)
  959. {
  960. int prev = 0;
  961. if (recursed_types.ContainsKey (stype))
  962. prev = recursed_types [stype];
  963. if (prev > 1)
  964. return;
  965. recursed_types [stype] = ++prev;
  966. if (stype.Particle != null)
  967. WriteParticleComplexContent (xtw, ns, stype.Particle);
  968. else
  969. {
  970. if (stype.ContentModel is XmlSchemaSimpleContent)
  971. WriteSimpleContent (xtw, (XmlSchemaSimpleContent)stype.ContentModel);
  972. else if (stype.ContentModel is XmlSchemaComplexContent)
  973. WriteComplexContent (xtw, ns, (XmlSchemaComplexContent)stype.ContentModel);
  974. }
  975. prev = recursed_types [stype];
  976. recursed_types [stype] = --prev;
  977. }
  978. void WriteAttributes (XmlTextWriter xtw, XmlSchemaObjectCollection atts, XmlSchemaAnyAttribute anyat)
  979. {
  980. foreach (XmlSchemaObject at in atts)
  981. {
  982. if (at is XmlSchemaAttribute)
  983. {
  984. string ns;
  985. XmlSchemaAttribute attr = (XmlSchemaAttribute)at;
  986. XmlSchemaAttribute refAttr = attr;
  987. // refAttr.Form; TODO
  988. if (!attr.RefName.IsEmpty) {
  989. refAttr = FindRefAttribute (attr.RefName);
  990. if (refAttr == null) throw new InvalidOperationException ("Global attribute not found: " + attr.RefName);
  991. }
  992. string val;
  993. if (!refAttr.SchemaTypeName.IsEmpty) val = FindBuiltInType (refAttr.SchemaTypeName);
  994. else val = FindBuiltInType ((XmlSchemaSimpleType) refAttr.SchemaType);
  995. xtw.WriteAttributeString (refAttr.Name, val);
  996. }
  997. else if (at is XmlSchemaAttributeGroupRef)
  998. {
  999. XmlSchemaAttributeGroupRef gref = (XmlSchemaAttributeGroupRef)at;
  1000. XmlSchemaAttributeGroup grp = (XmlSchemaAttributeGroup) schemas.Find (gref.RefName, typeof(XmlSchemaAttributeGroup));
  1001. WriteAttributes (xtw, grp.Attributes, grp.AnyAttribute);
  1002. }
  1003. }
  1004. if (anyat != null)
  1005. xtw.WriteAttributeString ("custom-attribute","value");
  1006. }
  1007. void WriteParticleComplexContent (XmlTextWriter xtw, string ns, XmlSchemaParticle particle)
  1008. {
  1009. WriteParticleContent (xtw, ns, particle, false);
  1010. }
  1011. void WriteParticleContent (XmlTextWriter xtw, string ns, XmlSchemaParticle particle, bool multiValue)
  1012. {
  1013. if (particle is XmlSchemaGroupRef)
  1014. particle = GetRefGroupParticle ((XmlSchemaGroupRef)particle);
  1015. if (particle.MaxOccurs > 1) multiValue = true;
  1016. if (particle is XmlSchemaSequence) {
  1017. WriteSequenceContent (xtw, ns, ((XmlSchemaSequence)particle).Items, multiValue);
  1018. }
  1019. else if (particle is XmlSchemaChoice) {
  1020. if (((XmlSchemaChoice)particle).Items.Count == 1)
  1021. WriteSequenceContent (xtw, ns, ((XmlSchemaChoice)particle).Items, multiValue);
  1022. else
  1023. WriteChoiceContent (xtw, ns, (XmlSchemaChoice)particle, multiValue);
  1024. }
  1025. else if (particle is XmlSchemaAll) {
  1026. WriteSequenceContent (xtw, ns, ((XmlSchemaAll)particle).Items, multiValue);
  1027. }
  1028. }
  1029. void WriteSequenceContent (XmlTextWriter xtw, string ns, XmlSchemaObjectCollection items, bool multiValue)
  1030. {
  1031. foreach (XmlSchemaObject item in items)
  1032. WriteContentItem (xtw, ns, item, multiValue);
  1033. }
  1034. void WriteContentItem (XmlTextWriter xtw, string ns, XmlSchemaObject item, bool multiValue)
  1035. {
  1036. if (item is XmlSchemaGroupRef)
  1037. item = GetRefGroupParticle ((XmlSchemaGroupRef)item);
  1038. if (item is XmlSchemaElement)
  1039. {
  1040. XmlSchemaElement elem = (XmlSchemaElement) item;
  1041. XmlSchemaElement refElem;
  1042. if (!elem.RefName.IsEmpty) refElem = FindRefElement (elem);
  1043. else refElem = elem;
  1044. int num = (elem.MaxOccurs == 1 && !multiValue) ? 1 : 2;
  1045. for (int n=0; n<num; n++)
  1046. {
  1047. if (currentUse == SoapBindingUse.Literal)
  1048. WriteElementSample (xtw, ns, refElem);
  1049. else
  1050. WriteRefTypeSample (xtw, ns, refElem);
  1051. }
  1052. }
  1053. else if (item is XmlSchemaAny)
  1054. {
  1055. xtw.WriteString (GetLiteral ("xml"));
  1056. }
  1057. else if (item is XmlSchemaParticle) {
  1058. WriteParticleContent (xtw, ns, (XmlSchemaParticle)item, multiValue);
  1059. }
  1060. }
  1061. void WriteChoiceContent (XmlTextWriter xtw, string ns, XmlSchemaChoice choice, bool multiValue)
  1062. {
  1063. foreach (XmlSchemaObject item in choice.Items)
  1064. WriteContentItem (xtw, ns, item, multiValue);
  1065. }
  1066. void WriteSimpleContent (XmlTextWriter xtw, XmlSchemaSimpleContent content)
  1067. {
  1068. XmlSchemaSimpleContentExtension ext = content.Content as XmlSchemaSimpleContentExtension;
  1069. if (ext != null)
  1070. WriteAttributes (xtw, ext.Attributes, ext.AnyAttribute);
  1071. XmlQualifiedName qname = GetContentBaseType (content.Content);
  1072. xtw.WriteString (GetLiteral (FindBuiltInType (qname)));
  1073. }
  1074. string FindBuiltInType (XmlQualifiedName qname)
  1075. {
  1076. if (qname.Namespace == XmlSchema.Namespace)
  1077. return qname.Name;
  1078. XmlSchemaComplexType ct = FindComplexTyype (qname);
  1079. if (ct != null)
  1080. {
  1081. XmlSchemaSimpleContent sc = ct.ContentModel as XmlSchemaSimpleContent;
  1082. if (sc == null) throw new InvalidOperationException ("Invalid schema");
  1083. return FindBuiltInType (GetContentBaseType (sc.Content));
  1084. }
  1085. XmlSchemaSimpleType st = (XmlSchemaSimpleType) schemas.Find (qname, typeof(XmlSchemaSimpleType));
  1086. if (st != null)
  1087. return FindBuiltInType (st);
  1088. throw new InvalidOperationException ("Definition of type " + qname + " not found");
  1089. }
  1090. string FindBuiltInType (XmlSchemaSimpleType st)
  1091. {
  1092. if (st.Content is XmlSchemaSimpleTypeRestriction) {
  1093. return FindBuiltInType (GetContentBaseType (st.Content));
  1094. }
  1095. else if (st.Content is XmlSchemaSimpleTypeList) {
  1096. string s = FindBuiltInType (GetContentBaseType (st.Content));
  1097. return s + " " + s + " ...";
  1098. }
  1099. else if (st.Content is XmlSchemaSimpleTypeUnion)
  1100. {
  1101. //Check if all types of the union are equal. If not, then will use anyType.
  1102. XmlSchemaSimpleTypeUnion uni = (XmlSchemaSimpleTypeUnion) st.Content;
  1103. string utype = null;
  1104. // Anonymous types are unique
  1105. if (uni.BaseTypes.Count != 0 && uni.MemberTypes.Length != 0)
  1106. return "string";
  1107. foreach (XmlQualifiedName mt in uni.MemberTypes)
  1108. {
  1109. string qn = FindBuiltInType (mt);
  1110. if (utype != null && qn != utype) return "string";
  1111. else utype = qn;
  1112. }
  1113. return utype;
  1114. }
  1115. else
  1116. return "string";
  1117. }
  1118. XmlQualifiedName GetContentBaseType (XmlSchemaObject ob)
  1119. {
  1120. if (ob is XmlSchemaSimpleContentExtension)
  1121. return ((XmlSchemaSimpleContentExtension)ob).BaseTypeName;
  1122. else if (ob is XmlSchemaSimpleContentRestriction)
  1123. return ((XmlSchemaSimpleContentRestriction)ob).BaseTypeName;
  1124. else if (ob is XmlSchemaSimpleTypeRestriction)
  1125. return ((XmlSchemaSimpleTypeRestriction)ob).BaseTypeName;
  1126. else if (ob is XmlSchemaSimpleTypeList)
  1127. return ((XmlSchemaSimpleTypeList)ob).ItemTypeName;
  1128. else
  1129. return null;
  1130. }
  1131. void WriteComplexContent (XmlTextWriter xtw, string ns, XmlSchemaComplexContent content)
  1132. {
  1133. XmlQualifiedName qname;
  1134. XmlSchemaComplexContentExtension ext = content.Content as XmlSchemaComplexContentExtension;
  1135. if (ext != null) qname = ext.BaseTypeName;
  1136. else {
  1137. XmlSchemaComplexContentRestriction rest = (XmlSchemaComplexContentRestriction)content.Content;
  1138. qname = rest.BaseTypeName;
  1139. if (qname == arrayType) {
  1140. ParseArrayType (rest, out qname);
  1141. XmlSchemaElement elem = new XmlSchemaElement ();
  1142. elem.Name = "Item";
  1143. elem.SchemaTypeName = qname;
  1144. xtw.WriteAttributeString ("arrayType", SoapEncodingNamespace, qname.Name + "[2]");
  1145. WriteContentItem (xtw, ns, elem, true);
  1146. return;
  1147. }
  1148. }
  1149. // Add base map members to this map
  1150. XmlSchemaComplexType ctype = FindComplexTyype (qname);
  1151. WriteComplexTypeAttributes (xtw, ctype);
  1152. if (ext != null) {
  1153. // Add the members of this map
  1154. WriteAttributes (xtw, ext.Attributes, ext.AnyAttribute);
  1155. if (ext.Particle != null)
  1156. WriteParticleComplexContent (xtw, ns, ext.Particle);
  1157. }
  1158. WriteComplexTypeElements (xtw, ns, ctype);
  1159. }
  1160. void ParseArrayType (XmlSchemaComplexContentRestriction rest, out XmlQualifiedName qtype)
  1161. {
  1162. XmlSchemaAttribute arrayTypeAt = FindArrayAttribute (rest.Attributes);
  1163. XmlAttribute[] uatts = arrayTypeAt.UnhandledAttributes;
  1164. if (uatts == null || uatts.Length == 0) throw new InvalidOperationException ("arrayType attribute not specified in array declaration");
  1165. XmlAttribute xat = null;
  1166. foreach (XmlAttribute at in uatts)
  1167. if (at.LocalName == "arrayType" && at.NamespaceURI == WsdlNamespace)
  1168. { xat = at; break; }
  1169. if (xat == null)
  1170. throw new InvalidOperationException ("arrayType attribute not specified in array declaration");
  1171. string arrayType = xat.Value;
  1172. string type, ns;
  1173. int i = arrayType.LastIndexOf (":");
  1174. if (i == -1) ns = "";
  1175. else ns = arrayType.Substring (0,i);
  1176. int j = arrayType.IndexOf ("[", i+1);
  1177. if (j == -1) throw new InvalidOperationException ("Cannot parse WSDL array type: " + arrayType);
  1178. type = arrayType.Substring (i+1);
  1179. type = type.Substring (0, type.Length-2);
  1180. qtype = new XmlQualifiedName (type, ns);
  1181. }
  1182. XmlSchemaAttribute FindArrayAttribute (XmlSchemaObjectCollection atts)
  1183. {
  1184. foreach (object ob in atts)
  1185. {
  1186. XmlSchemaAttribute att = ob as XmlSchemaAttribute;
  1187. if (att != null && att.RefName == arrayTypeRefName) return att;
  1188. XmlSchemaAttributeGroupRef gref = ob as XmlSchemaAttributeGroupRef;
  1189. if (gref != null)
  1190. {
  1191. XmlSchemaAttributeGroup grp = (XmlSchemaAttributeGroup) schemas.Find (gref.RefName, typeof(XmlSchemaAttributeGroup));
  1192. att = FindArrayAttribute (grp.Attributes);
  1193. if (att != null) return att;
  1194. }
  1195. }
  1196. return null;
  1197. }
  1198. void WriteSimpleTypeSample (XmlTextWriter xtw, XmlSchemaSimpleType stype)
  1199. {
  1200. xtw.WriteString (GetLiteral (FindBuiltInType (stype)));
  1201. }
  1202. XmlSchemaParticle GetRefGroupParticle (XmlSchemaGroupRef refGroup)
  1203. {
  1204. XmlSchemaGroup grp = (XmlSchemaGroup) schemas.Find (refGroup.RefName, typeof (XmlSchemaGroup));
  1205. return grp.Particle;
  1206. }
  1207. XmlSchemaElement FindRefElement (XmlSchemaElement elem)
  1208. {
  1209. if (elem.RefName.Namespace == XmlSchema.Namespace)
  1210. {
  1211. if (anyElement != null) return anyElement;
  1212. anyElement = new XmlSchemaElement ();
  1213. anyElement.Name = "any";
  1214. anyElement.SchemaTypeName = anyType;
  1215. return anyElement;
  1216. }
  1217. return (XmlSchemaElement) schemas.Find (elem.RefName, typeof(XmlSchemaElement));
  1218. }
  1219. XmlSchemaAttribute FindRefAttribute (XmlQualifiedName refName)
  1220. {
  1221. if (refName.Namespace == XmlSchema.Namespace)
  1222. {
  1223. XmlSchemaAttribute at = new XmlSchemaAttribute ();
  1224. at.Name = refName.Name;
  1225. at.SchemaTypeName = new XmlQualifiedName ("string",XmlSchema.Namespace);
  1226. return at;
  1227. }
  1228. return (XmlSchemaAttribute) schemas.Find (refName, typeof(XmlSchemaAttribute));
  1229. }
  1230. void WriteRefTypeSample (XmlTextWriter xtw, string ns, XmlSchemaElement elem)
  1231. {
  1232. if (elem.SchemaTypeName.Namespace == XmlSchema.Namespace || schemas.Find (elem.SchemaTypeName, typeof(XmlSchemaSimpleType)) != null)
  1233. WriteElementSample (xtw, ns, elem);
  1234. else
  1235. {
  1236. xtw.WriteStartElement (elem.Name, ns);
  1237. xtw.WriteAttributeString ("href", "#id" + (queue.Count+1));
  1238. xtw.WriteEndElement ();
  1239. queue.Add (new EncodedType (ns, elem));
  1240. }
  1241. }
  1242. void WriteQueuedTypeSamples (XmlTextWriter xtw)
  1243. {
  1244. for (int n=0; n<queue.Count; n++)
  1245. {
  1246. EncodedType ec = (EncodedType) queue[n];
  1247. XmlSchemaComplexType st = FindComplexTyype (ec.Element.SchemaTypeName);
  1248. WriteComplexTypeSample (xtw, st, ec.Element.SchemaTypeName, n+1);
  1249. }
  1250. }
  1251. XmlSchemaComplexType FindComplexTyype (XmlQualifiedName qname)
  1252. {
  1253. if (qname.Name.IndexOf ("[]") != -1)
  1254. {
  1255. XmlSchemaComplexType stype = new XmlSchemaComplexType ();
  1256. stype.ContentModel = new XmlSchemaComplexContent ();
  1257. XmlSchemaComplexContentRestriction res = new XmlSchemaComplexContentRestriction ();
  1258. stype.ContentModel.Content = res;
  1259. res.BaseTypeName = arrayType;
  1260. XmlSchemaAttribute att = new XmlSchemaAttribute ();
  1261. att.RefName = arrayTypeRefName;
  1262. res.Attributes.Add (att);
  1263. XmlAttribute xat = document.CreateAttribute ("arrayType", WsdlNamespace);
  1264. xat.Value = qname.Namespace + ":" + qname.Name;
  1265. att.UnhandledAttributes = new XmlAttribute[] {xat};
  1266. return stype;
  1267. }
  1268. return (XmlSchemaComplexType) schemas.Find (qname, typeof(XmlSchemaComplexType));
  1269. }
  1270. string GetQualifiedNameString (XmlTextWriter xtw, XmlQualifiedName qname)
  1271. {
  1272. string pref = xtw.LookupPrefix (qname.Namespace);
  1273. if (pref != null) return pref + ":" + qname.Name;
  1274. xtw.WriteAttributeString ("xmlns", "q1", null, qname.Namespace);
  1275. return "q1:" + qname.Name;
  1276. }
  1277. protected virtual string GetLiteral (string s)
  1278. {
  1279. return s;
  1280. }
  1281. void GetOperationFormat (OperationBinding obin, out SoapBindingStyle style, out SoapBindingUse use)
  1282. {
  1283. style = SoapBindingStyle.Document;
  1284. use = SoapBindingUse.Literal;
  1285. SoapOperationBinding sob = obin.Extensions.Find (typeof(SoapOperationBinding)) as SoapOperationBinding;
  1286. if (sob != null) {
  1287. style = sob.Style;
  1288. SoapBodyBinding sbb = obin.Input.Extensions.Find (typeof(SoapBodyBinding)) as SoapBodyBinding;
  1289. if (sbb != null)
  1290. use = sbb.Use;
  1291. }
  1292. }
  1293. }
  1294. </script>
  1295. <head runat="server">
  1296. <%
  1297. Response.Write ("<link rel=\"alternate\" type=\"text/xml\" href=\"" + Request.FilePath + "?disco\"/>");
  1298. %>
  1299. <title><%=WebServiceName%> Web Service</title>
  1300. <style type="text/css">
  1301. BODY { font-family: Arial; margin-left: 20px; margin-top: 20px; font-size: x-small}
  1302. TABLE { font-size: x-small }
  1303. .title { color:dimgray; font-family: Arial; font-size:20pt; font-weight:900}
  1304. .operationTitle { color:dimgray; font-family: Arial; font-size:15pt; font-weight:900}
  1305. .method { font-size: x-small }
  1306. .bindingLabel { font-size: x-small; font-weight:bold; color:darkgray; line-height:8pt; display:block; margin-bottom:3px }
  1307. .label { font-size: small; font-weight:bold; color:darkgray }
  1308. .paramTable { font-size: x-small }
  1309. .paramTable TR { background-color: gainsboro }
  1310. .paramFormTable { font-size: x-small; padding: 10px; background-color: gainsboro }
  1311. .paramFormTable TR { background-color: gainsboro }
  1312. .paramInput { border: solid 1px gray }
  1313. .button {border: solid 1px gray }
  1314. .smallSeparator { height:3px; overflow:hidden }
  1315. .panel { background-color:whitesmoke; border: solid 1px silver; border-top: solid 1px silver }
  1316. .codePanel { background-color: white; font-size:x-small; padding:7px; border:solid 1px silver}
  1317. .code-xml { font-size:10pt; font-family:courier }
  1318. .code-cs { font-size:10pt; font-family:courier }
  1319. .code-vb { font-size:10pt; font-family:courier }
  1320. .tabLabelOn { font-weight:bold }
  1321. .tabLabelOff {color: darkgray }
  1322. .literal-placeholder {color: darkblue; font-weight:bold}
  1323. A:link { color: black; }
  1324. A:visited { color: black; }
  1325. A:active { color: black; }
  1326. A:hover { color: blue }
  1327. </style>
  1328. <script language="javascript" type="text/javascript">
  1329. var req;
  1330. function getXML (command, url, qs) {
  1331. if (url == "" || url.substring (0, 4) != "http")
  1332. return;
  1333. var post_data = null;
  1334. req = getReq ();
  1335. req.onreadystatechange = stateChange;
  1336. if (command == "GET") {
  1337. url = url + "?" + qs;
  1338. } else {
  1339. post_data = qs;
  1340. }
  1341. req.open (command, url, true);
  1342. if (command == "POST")
  1343. req.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
  1344. req.send (post_data);
  1345. }
  1346. function stateChange () {
  1347. if (req.readyState == 4) {
  1348. var node = document.getElementById("testresult_div");
  1349. var text = "";
  1350. if (req.status == 200) {
  1351. node.innerHTML = "<div class='code-xml'>" + formatXml (req.responseText) + "</div>";
  1352. } else {
  1353. var ht = "<b style='color: red'>" + formatXml (req.status + " - " + req.statusText) + "</b>";
  1354. if (req.responseText != "")
  1355. ht = ht + "\n<div class='code-xml'>" + formatXml (req.responseText) + "</div>";
  1356. node.innerHTML = ht;
  1357. }
  1358. }
  1359. }
  1360. function formatXml (text)
  1361. {
  1362. var re = / /g;
  1363. text = text.replace (re, "&nbsp;");
  1364. re = /\t/g;
  1365. text = text.replace (re, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
  1366. re = /\<\s*(\/?)\s*(.*?)\s*(\/?)\s*\>/g;
  1367. text = text.replace (re,"{blue:&lt;$1}{maroon:$2}{blue:$3&gt;}");
  1368. re = /{(\w*):(.*?)}/g;
  1369. text = text.replace (re,"<span style='color:$1'>$2</span>");
  1370. re = /"(.*?)"/g;
  1371. text = text.replace (re,"\"<span style='color:purple'>$1</span>\"");
  1372. re = /\r\n|\r|\n/g;
  1373. text = text.replace (re, "<br/>");
  1374. return text;
  1375. }
  1376. function getReq () {
  1377. if (window.XMLHttpRequest) {
  1378. return new XMLHttpRequest(); // Firefox, Safari, ...
  1379. } else if (window.ActiveXObject) {
  1380. return new ActiveXObject("Microsoft.XMLHTTP");
  1381. }
  1382. }
  1383. function clearForm ()
  1384. {
  1385. document.getElementById("testFormResult").style.display="none";
  1386. }
  1387. </script>
  1388. </head>
  1389. <body>
  1390. <div class="title" style="margin-left:20px">
  1391. <span class="label">Web Service</span><br>
  1392. <%=WebServiceName%>
  1393. </div>
  1394. <!--
  1395. **********************************************************
  1396. Left panel
  1397. -->
  1398. <table border="0" width="100%" cellpadding="15px" cellspacing="15px">
  1399. <tr valign="top"><td width="150px" class="panel">
  1400. <div style="width:150px"></div>
  1401. <a class="method" href='<%=PageName%>'>Overview</a><br>
  1402. <div class="smallSeparator"></div>
  1403. <a class="method" href='<%=PageName + "?" + GetPageContext("wsdl")%>'>Service Description</a>
  1404. <div class="smallSeparator"></div>
  1405. <a class="method" href='<%=PageName + "?" + GetPageContext("proxy")%>'>Client proxy</a>
  1406. <br><br>
  1407. <asp:repeater id="BindingsRepeater" runat=server>
  1408. <itemtemplate name="itemtemplate">
  1409. <span class="bindingLabel"><%#FormatBindingName(DataBinder.Eval(Container.DataItem, "Name").ToString())%></span>
  1410. <asp:repeater id="OperationsRepeater" runat=server datasource='<%# ((Binding)Container.DataItem).Operations %>'>
  1411. <itemtemplate>
  1412. <a class="method" href="<%=PageName%>?<%=GetTabContext("op",null)%>op=<%#GetOpName(Container.DataItem)%>&bnd=<%#DataBinder.Eval(Container.DataItem, "Binding.Name")%>"><%#GetOpName(Container.DataItem)%></a>
  1413. <div class="smallSeparator"></div>
  1414. </itemtemplate>
  1415. </asp:repeater>
  1416. <br>
  1417. </itemtemplate>
  1418. </asp:repeater>
  1419. </td><td class="panel">
  1420. <% if (CurrentPage == "main") {%>
  1421. <!--
  1422. **********************************************************
  1423. Web service overview
  1424. -->
  1425. <p class="label">Web Service Overview</p>
  1426. <%=WebServiceDescription%>
  1427. <br/><br/>
  1428. <% if (ProfileViolations != null && ProfileViolations.Count > 0) { %>
  1429. <p class="label">Basic Profile Conformance</p>
  1430. This web service does not conform to WS-I Basic Profile v1.1
  1431. <%
  1432. Response.Write ("<ul>");
  1433. foreach (BasicProfileViolation vio in ProfileViolations) {
  1434. Response.Write ("<li><b>" + vio.NormativeStatement + "</b>: " + vio.Details);
  1435. Response.Write ("<ul>");
  1436. foreach (string ele in vio.Elements)
  1437. Response.Write ("<li>" + ele + "</li>");
  1438. Response.Write ("</ul>");
  1439. Response.Write ("</li>");
  1440. }
  1441. Response.Write ("</ul>");
  1442. }%>
  1443. <%} if (DefaultBinding == null) {%>
  1444. This service does not contain any public web method.
  1445. <%} else if (CurrentPage == "op") {%>
  1446. <!--
  1447. **********************************************************
  1448. Operation description
  1449. -->
  1450. <span class="operationTitle"><%=CurrentOperationName%></span>
  1451. <br><br>
  1452. <% WriteTabs (); %>
  1453. <br><br><br>
  1454. <% if (CurrentTab == "main") { %>
  1455. <span class="label">Input Parameters</span>
  1456. <div class="smallSeparator"></div>
  1457. <% if (InParams.Count == 0) { %>
  1458. No input parameters<br>
  1459. <% } else { %>
  1460. <table class="paramTable" cellspacing="1" cellpadding="5">
  1461. <asp:repeater id="InputParamsRepeater" runat=server>
  1462. <itemtemplate>
  1463. <tr>
  1464. <td width="150"><%#DataBinder.Eval(Container.DataItem, "Name")%></td>
  1465. <td width="150"><%#DataBinder.Eval(Container.DataItem, "Type")%></td>
  1466. </tr>
  1467. </itemtemplate>
  1468. </asp:repeater>
  1469. </table>
  1470. <% } %>
  1471. <br>
  1472. <% if (OutParams.Count > 0) { %>
  1473. <span class="label">Output Parameters</span>
  1474. <div class="smallSeparator"></div>
  1475. <table class="paramTable" cellspacing="1" cellpadding="5">
  1476. <asp:repeater id="OutputParamsRepeater" runat=server>
  1477. <itemtemplate>
  1478. <tr>
  1479. <td width="150"><%#DataBinder.Eval(Container.DataItem, "Name")%></td>
  1480. <td width="150"><%#DataBinder.Eval(Container.DataItem, "Type")%></td>
  1481. </tr>
  1482. </itemtemplate>
  1483. </asp:repeater>
  1484. </table>
  1485. <br>
  1486. <% } %>
  1487. <span class="label">Remarks</span>
  1488. <div class="smallSeparator"></div>
  1489. <%=OperationDocumentation%>
  1490. <br><br>
  1491. <span class="label">Technical information</span>
  1492. <div class="smallSeparator"></div>
  1493. Format: <%=CurrentOperationFormat%>
  1494. <br>Supported protocols: <%=CurrentOperationProtocols%>
  1495. <% } %>
  1496. <!--
  1497. **********************************************************
  1498. Operation description - Test form
  1499. -->
  1500. <% if (CurrentTab == "test") {
  1501. if (CurrentOperationSupportsTest) {%>
  1502. Enter values for the parameters and click the 'Invoke' button to test this method:<br><br>
  1503. <form action="<%=PageName%>" method="GET">
  1504. <input type="hidden" name="page" value="<%=CurrentPage%>">
  1505. <input type="hidden" name="tab" value="<%=CurrentTab%>">
  1506. <input type="hidden" name="op" value="<%=CurrentOperationName%>">
  1507. <input type="hidden" name="bnd" value="<%=CurrentOperationBinding%>">
  1508. <input type="hidden" name="ext" value="testform">
  1509. <table class="paramFormTable" cellspacing="0" cellpadding="3">
  1510. <asp:repeater id="InputFormParamsRepeater" runat=server>
  1511. <itemtemplate>
  1512. <tr>
  1513. <td><%#DataBinder.Eval(Container.DataItem, "Name")%>:&nbsp;</td>
  1514. <td width="150"><input class="paramInput" type="text" size="20" name="<%#DataBinder.Eval(Container.DataItem, "Name")%>"></td>
  1515. </tr>
  1516. </itemtemplate>
  1517. </asp:repeater>
  1518. <tr><td></td><td><input class="button" type="submit" value="Invoke">&nbsp;<input class="button" type="button" onclick="clearForm()" value="Clear"></td></tr>
  1519. </table>
  1520. </form>
  1521. <div id="testFormResult" style="display:<%= (HasFormResult?"block":"none") %>">
  1522. The web service returned the following result:<br/><br/>
  1523. <div class="codePanel" id="testresult_div">
  1524. </div>
  1525. <script language="javascript">
  1526. getXML ("<%= GetOrPost () %>", "<%= GetTestResultUrl () %>", "<%= GetQS () %>");
  1527. </script>
  1528. </div>
  1529. <% } else {%>
  1530. The test form is not available for this operation because it has parameters with a complex structure.
  1531. <% } %>
  1532. <% } %>
  1533. <!--
  1534. **********************************************************
  1535. Operation description - Message Layout
  1536. -->
  1537. <% if (CurrentTab == "msg") { %>
  1538. The following are sample SOAP requests and responses for each protocol supported by this method:
  1539. <br/><br/>
  1540. <% if (IsOperationSupported ("Soap")) { %>
  1541. <span class="label">Soap</span>
  1542. <br/><br/>
  1543. <div class="codePanel"><div class="code-xml"><%=GenerateOperationMessages ("Soap", true)%></div></div>
  1544. <br/>
  1545. <div class="codePanel"><div class="code-xml"><%=GenerateOperationMessages ("Soap", false)%></div></div>
  1546. <br/>
  1547. <% } %>
  1548. <% if (IsOperationSupported ("HttpGet")) { %>
  1549. <span class="label">HTTP Get</span>
  1550. <br/><br/>
  1551. <div class="codePanel"><div class="code-xml"><%=GenerateOperationMessages ("HttpGet", true)%></div></div>
  1552. <br/>
  1553. <div class="codePanel"><div class="code-xml"><%=GenerateOperationMessages ("HttpGet", false)%></div></div>
  1554. <br/>
  1555. <% } %>
  1556. <% if (IsOperationSupported ("HttpPost")) { %>
  1557. <span class="label">HTTP Post</span>
  1558. <br/><br/>
  1559. <div class="codePanel"><div class="code-xml"><%=GenerateOperationMessages ("HttpPost", true)%></div></div>
  1560. <br/>
  1561. <div class="codePanel"><div class="code-xml"><%=GenerateOperationMessages ("HttpPost", false)%></div></div>
  1562. <br/>
  1563. <% } %>
  1564. <% } %>
  1565. <%} else if (CurrentPage == "proxy") {%>
  1566. <!--
  1567. **********************************************************
  1568. Client Proxy
  1569. -->
  1570. <form action="<%=PageName%>" name="langForm" method="GET">
  1571. Select the language for which you want to generate a proxy
  1572. <input type="hidden" name="page" value="<%=CurrentPage%>">&nbsp;
  1573. <SELECT name="lang" onchange="langForm.submit()">
  1574. <%=GetOptionSel("cs",CurrentLanguage)%>C#</option>
  1575. <%=GetOptionSel("vb",CurrentLanguage)%>Visual Basic</option>
  1576. </SELECT>
  1577. &nbsp;&nbsp;
  1578. </form>
  1579. <br>
  1580. <span class="label"><%=CurrentProxytName%></span>&nbsp;&nbsp;&nbsp;
  1581. <a href="<%=PageName + "?code=" + CurrentLanguage%>">Download</a>
  1582. <br><br>
  1583. <div class="codePanel">
  1584. <div class="code-<%=CurrentLanguage%>"><%=GetProxyCode ()%></div>
  1585. </div>
  1586. <%} else if (CurrentPage == "wsdl") {%>
  1587. <!--
  1588. **********************************************************
  1589. Service description
  1590. -->
  1591. <% if (descriptions.Count > 1 || schemas.Count > 1) {%>
  1592. The description of this web service is composed by several documents. Click on the document you want to see:
  1593. <ul>
  1594. <%
  1595. for (int n=0; n<descriptions.Count; n++)
  1596. Response.Write ("<li><a href='" + PageName + "?" + GetPageContext(null) + "doctype=wsdl&docind=" + n + "'>WSDL document " + descriptions[n].TargetNamespace + "</a></li>");
  1597. for (int n=0; n<schemas.Count; n++)
  1598. Response.Write ("<li><a href='" + PageName + "?" + GetPageContext(null) + "doctype=schema&docind=" + n + "'>Xml Schema " + schemas[n].TargetNamespace + "</a></li>");
  1599. %>
  1600. </ul>
  1601. <%} else {%>
  1602. <%}%>
  1603. <br>
  1604. <span class="label"><%=CurrentDocumentName%></span>&nbsp;&nbsp;&nbsp;
  1605. <a href="<%=PageName + "?" + CurrentDocType + "=" + CurrentDocInd %>">Download</a>
  1606. <br><br>
  1607. <div class="codePanel">
  1608. <div class="code-xml"><%=GenerateDocument ()%></div>
  1609. </div>
  1610. <%}%>
  1611. <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
  1612. </td>
  1613. <td width="20px"></td>
  1614. </tr>
  1615. </table>
  1616. </body>
  1617. </html>