DefaultWsdlHelpGenerator.aspx 57 KB

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