DefaultWsdlHelpGenerator.aspx 55 KB

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