DefaultWsdlHelpGenerator.aspx 57 KB

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