1 <%@ Import Namespace="System.Collections" %>
2 <%@ Import Namespace="System.IO" %>
3 <%@ Import Namespace="System.Xml.Serialization" %>
4 <%@ Import Namespace="System.Xml" %>
5 <%@ Import Namespace="System.Xml.Schema" %>
6 <%@ Import Namespace="System.Web.Services.Description" %>
7 <%@ Import Namespace="System" %>
8 <%@ Import Namespace="System.Globalization" %>
9 <%@ Import Namespace="System.Resources" %>
10 <%@ Import Namespace="System.Diagnostics" %>
11 <%@ Assembly name="System.Web.Services" %>
12 <%@ Page debug="true" %>
15 <script language="C#" runat="server">
17 ServiceDescriptionCollection descriptions;
20 string WebServiceName;
21 string WebServiceDescription;
24 string DefaultBinding;
26 string CurrentOperationName;
27 string CurrentOperationBinding;
28 string OperationDocumentation;
32 void Page_Load(object sender, EventArgs e)
34 descriptions = (ServiceDescriptionCollection) Context.Items["wsdls"];
35 schemas = (XmlSchemas) Context.Items["schemas"];
37 ServiceDescription desc = descriptions [0];
38 Service service = desc.Services[0];
39 WebServiceName = service.Name;
40 DefaultBinding = desc.Bindings[0].Name;
41 WebServiceDescription = service.Documentation;
43 CurrentOperationName = Request.QueryString["op"];
44 CurrentOperationBinding = Request.QueryString["bnd"];
45 if (CurrentOperationName != null) BuildOperationInfo ();
47 PageName = HttpUtility.UrlEncode (Path.GetFileName(Request.Path), Encoding.UTF8);
49 ArrayList list = new ArrayList ();
50 foreach (ServiceDescription sd in descriptions)
51 list.AddRange (sd.Bindings);
53 BindingsRepeater.DataSource = list;
57 void BuildOperationInfo ()
59 InParams = new ArrayList ();
60 OutParams = new ArrayList ();
62 Binding binding = FindBinding (CurrentOperationBinding);
63 PortType portType = descriptions.GetPortType (binding.Type);
64 Operation oper = FindOperation (portType, CurrentOperationName);
66 OperationDocumentation = oper.Documentation;
67 if (OperationDocumentation == null || OperationDocumentation == "")
68 OperationDocumentation = "No additional remarks";
70 foreach (OperationMessage opm in oper.Messages)
72 if (opm is OperationInput)
73 BuildParameters (InParams, opm);
74 else if (opm is OperationOutput)
75 BuildParameters (OutParams, opm);
78 InputParamsRepeater.DataSource = InParams;
79 OutputParamsRepeater.DataSource = OutParams;
82 void BuildParameters (ArrayList list, OperationMessage opm)
84 Message msg = descriptions.GetMessage (opm.Message);
85 if (msg.Parts.Count > 0 && msg.Parts[0].Name == "parameters")
87 MessagePart part = msg.Parts[0];
88 XmlSchemaComplexType ctype;
89 if (part.Element == XmlQualifiedName.Empty)
91 ctype = (XmlSchemaComplexType) schemas.Find (part.Type, typeof(XmlSchemaComplexType));
95 XmlSchemaElement elem = (XmlSchemaElement) schemas.Find (part.Element, typeof(XmlSchemaElement));
96 ctype = (XmlSchemaComplexType) elem.SchemaType;
98 XmlSchemaSequence seq = ctype.Particle as XmlSchemaSequence;
99 if (seq == null) return;
101 foreach (XmlSchemaObject ob in seq.Items)
103 Parameter p = new Parameter();
104 p.Description = "No additional remarks";
106 if (ob is XmlSchemaElement)
108 XmlSchemaElement selem = GetRefElement ((XmlSchemaElement)ob);
110 p.Type = selem.SchemaTypeName.Name;
122 foreach (MessagePart part in msg.Parts)
124 Parameter p = new Parameter ();
125 p.Description = "No additional remarks";
127 if (part.Element == XmlQualifiedName.Empty)
128 p.Type = part.Type.Name;
131 XmlSchemaElement elem = (XmlSchemaElement) schemas.Find (part.Element, typeof(XmlSchemaElement));
132 p.Type = elem.SchemaTypeName.Name;
139 XmlSchemaElement GetRefElement (XmlSchemaElement elem)
141 if (!elem.RefName.IsEmpty)
142 return (XmlSchemaElement) schemas.Find (elem.RefName, typeof(XmlSchemaElement));
147 Binding FindBinding (string portName)
149 Service service = descriptions[0].Services[0];
150 foreach (Port port in service.Ports)
151 if (port.Name == portName)
152 return descriptions.GetBinding (port.Binding);
156 Operation FindOperation (PortType portType, string name)
158 foreach (Operation oper in portType.Operations)
159 if (oper.Name == name) return oper;
163 string FormatBindingName (string name)
165 if (name == DefaultBinding) return "Methods";
166 else return "Methods for binding<br>" + name;
175 public string Name { get { return name; } set { name = value; } }
176 public string Type { get { return type; } set { type = value; } }
177 public string Description { get { return description; } set { description = value; } }
183 <style type="text/css">
184 BODY { font-family: Arial; margin-left: 20px; margin-top: 20px; font-size: x-small}
185 TABLE { font-size: x-small }
186 .title { color:dimgray; font-family: Arial; font-size:20pt; font-weight:900}
187 .operationTitle { color:dimgray; font-family: Arial; font-size:15pt; font-weight:900}
188 .method { font-size: x-small }
189 .bindingLabel { font-size: x-small; font-weight:bold; color:darkgray; line-height:8pt; display:block; margin-bottom:3px }
190 .label { font-size: x-small; font-weight:bold; color:darkgray }
191 .paramTable { font-size: x-small }
192 .paramTable TR { background-color: gainsboro }
193 .smallSeparator { height:3px; overflow:hidden }
194 .panel { background-color:whitesmoke; border: solid 1px silver; border-top: solid 1px silver }
195 A:link { color: black; }
196 A:visited { color: black; }
197 A:active { color: black; }
198 A:hover { color: blue }
203 <div class="title" style="margin-left:20px">
204 <span class="label">Web Service</span><br>
207 <table border="0" width="100%" cellpadding="15px" cellspacing="15px">
208 <tr valign="top"><td width="150px" class="panel">
209 <a class="method" href='<%=PageName%>'>Overview</a><br>
210 <div class="smallSeparator"></div>
211 <a class="method" href='<%=PageName + "?wsdl"%>'>Service Description</a>
212 <div class="smallSeparator"></div>
213 <a class="method" href='<%=PageName + "?code=cs"%>'>C# proxy</a>
215 <asp:repeater id="BindingsRepeater" runat=server>
216 <itemtemplate name="itemtemplate">
217 <span class="bindingLabel"><%#FormatBindingName(DataBinder.Eval(Container.DataItem, "Name").ToString())%></span>
218 <asp:repeater id="OperationsRepeater" runat=server datasource='<%# ((Binding)Container.DataItem).Operations %>'>
220 <a class="method" href="<%#PageName%>?op=<%#DataBinder.Eval(Container.DataItem, "Name")%>&bnd=<%#DataBinder.Eval(Container.DataItem, "Binding.Name")%>"><%#DataBinder.Eval(Container.DataItem, "Name")%></a>
221 <div class="smallSeparator"></div>
228 </td><td class="panel">
230 <% if (CurrentOperationName == null) {%>
231 <p class="label">Web Service Overview</p>
232 <%#WebServiceDescription%>
234 <span class="operationTitle"><%#CurrentOperationName%></span>
236 <span class="label">Input Parameters</span>
237 <% if (InParams.Count == 0) { %>
238 <br>No input parameters<br>
240 <table class="paramTable" cellspacing="1" cellpadding="5">
241 <asp:repeater id="InputParamsRepeater" runat=server>
244 <td width="150"><%#DataBinder.Eval(Container.DataItem, "Name")%></td>
245 <td width="150"><%#DataBinder.Eval(Container.DataItem, "Type")%></td>
246 <!-- <td><%#DataBinder.Eval(Container.DataItem, "Description")%></td>-->
254 <% if (OutParams.Count > 0) { %>
255 <span class="label">Output Parameters</span>
256 <table class="paramTable" cellspacing="1" cellpadding="5">
257 <asp:repeater id="OutputParamsRepeater" runat=server>
260 <td width="150"><%#DataBinder.Eval(Container.DataItem, "Name")%></td>
261 <td width="150"><%#DataBinder.Eval(Container.DataItem, "Type")%></td>
262 <!-- <td><%#DataBinder.Eval(Container.DataItem, "Description")%></td> -->
269 <span class="label">Remarks</span>
270 <br><%#OperationDocumentation%>
272 <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
274 <td withd="20px"></td>