source: 2016/27/PaavoH/Animal.io/Animal.io B2/Animal.io B2_Data/Mono/etc/mono/2.0/DefaultWsdlHelpGenerator.aspx @ 8679

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