DefaultWsdlHelpGenerator.aspx 59 KB

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