DefaultWsdlHelpGenerator.aspx 56 KB

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