2 // ServiceDescriptionReflectorTest.cs
5 // Gert Driesen <drieseng@users.sourceforge.net>
7 // Copyright (C) 2006 Novell, Inc.
10 using NUnit.Framework;
13 using System.Globalization;
15 using System.Web.Services;
16 using System.Web.Services.Description;
17 using System.Xml.Serialization;
19 namespace MonoTests.System.Web.Services.Description
22 public class ServiceDescriptionReflectorTest
25 [Category ("NotWorking")]
26 public void IncludeTest ()
28 ServiceDescriptionReflector reflector = new ServiceDescriptionReflector ();
29 reflector.Reflect (typeof (IncludeTestServices), "http://localhost/IncludeTestServices.asmx");
31 Assert.AreEqual (0, reflector.Schemas.Count, "#1");
32 Assert.AreEqual (1, reflector.ServiceDescriptions.Count, "#2");
34 ServiceDescription sd = reflector.ServiceDescriptions[0];
36 Assert.IsNull (sd.Name, "#3");
37 Assert.AreEqual (1, sd.Types.Schemas.Count, "#4");
39 StringWriter sw = new StringWriter ();
42 Assert.AreEqual (string.Format(CultureInfo.InvariantCulture,
43 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
45 "<wsdl:definitions xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\" xmlns:tm=\"http://microsoft.com/wsdl/mime/textMatching/\"" +
46 " xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:mime=\"http://schemas.xmlsoap.org/wsdl/mime/\"" +
47 " xmlns:tns=\"http://tempuri.org/\" xmlns:s=\"http://www.w3.org/2001/XMLSchema\"" +
48 " xmlns:soap12=\"http://schemas.xmlsoap.org/wsdl/soap12/\"" +
49 " xmlns:http=\"http://schemas.xmlsoap.org/wsdl/http/\" targetNamespace=\"http://tempuri.org/\"" +
50 " xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">{0}" +
52 "<wsdl:definitions xmlns:http=\"http://schemas.xmlsoap.org/wsdl/http/\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\"" +
53 " xmlns:s=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"" +
54 " xmlns:tns=\"http://tempuri.org/\" xmlns:tm=\"http://microsoft.com/wsdl/mime/textMatching/\"" +
55 " xmlns:mime=\"http://schemas.xmlsoap.org/wsdl/mime/\" targetNamespace=\"http://tempuri.org/\"" +
56 " xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">{0}" +
59 " <s:schema elementFormDefault=\"qualified\" targetNamespace=\"http://tempuri.org/\">{0}" +
60 " <s:element name=\"EchoString\">{0}" +
61 " <s:complexType>{0}" +
63 " <s:element minOccurs=\"0\" maxOccurs=\"1\" name=\"strval\" type=\"s:string\" />{0}" +
65 " </s:complexType>{0}" +
67 " <s:element name=\"EchoStringResponse\">{0}" +
68 " <s:complexType>{0}" +
70 " <s:element minOccurs=\"1\" maxOccurs=\"1\" name=\"MyTime\" type=\"s:time\" />{0}" +
72 " </s:complexType>{0}" +
74 " <s:element name=\"Vehicle\">{0}" +
75 " <s:complexType>{0}" +
77 " <s:element minOccurs=\"0\" maxOccurs=\"1\" name=\"licenseNumber\" type=\"s:string\" />{0}" +
79 " </s:complexType>{0}" +
81 " <s:element name=\"VehicleResponse\">{0}" +
82 " <s:complexType>{0}" +
84 " <s:element minOccurs=\"1\" maxOccurs=\"1\" name=\"NewVehicle\" nillable=\"true\" type=\"tns:Vehicle\" />{0}" +
86 " </s:complexType>{0}" +
88 " <s:complexType name=\"Vehicle\" abstract=\"true\">{0}" +
90 " <s:element minOccurs=\"0\" maxOccurs=\"1\" name=\"licenseNumber\" type=\"s:string\" />{0}" +
91 " <s:element minOccurs=\"1\" maxOccurs=\"1\" name=\"make\" type=\"s:dateTime\" />{0}" +
92 " <s:element minOccurs=\"1\" maxOccurs=\"1\" name=\"age\" type=\"tns:TimeSpan\" />{0}" +
94 " </s:complexType>{0}" +
95 " <s:complexType name=\"TimeSpan\" />{0}" +
96 " <s:complexType name=\"Car\">{0}" +
97 " <s:complexContent mixed=\"false\">{0}" +
98 " <s:extension base=\"tns:Vehicle\" />{0}" +
99 " </s:complexContent>{0}" +
100 " </s:complexType>{0}" +
102 " </wsdl:types>{0}" +
103 " <wsdl:message name=\"EchoStringSoapIn\">{0}" +
104 " <wsdl:part name=\"parameters\" element=\"tns:EchoString\" />{0}" +
105 " </wsdl:message>{0}" +
106 " <wsdl:message name=\"EchoStringSoapOut\">{0}" +
107 " <wsdl:part name=\"parameters\" element=\"tns:EchoStringResponse\" />{0}" +
108 " </wsdl:message>{0}" +
109 " <wsdl:message name=\"VehicleSoapIn\">{0}" +
110 " <wsdl:part name=\"parameters\" element=\"tns:Vehicle\" />{0}" +
111 " </wsdl:message>{0}" +
112 " <wsdl:message name=\"VehicleSoapOut\">{0}" +
113 " <wsdl:part name=\"parameters\" element=\"tns:VehicleResponse\" />{0}" +
114 " </wsdl:message>{0}" +
115 " <wsdl:portType name=\"IncludeTestServicesSoap\">{0}" +
116 " <wsdl:operation name=\"EchoString\">{0}" +
117 " <wsdl:input message=\"tns:EchoStringSoapIn\" />{0}" +
118 " <wsdl:output message=\"tns:EchoStringSoapOut\" />{0}" +
119 " </wsdl:operation>{0}" +
120 " <wsdl:operation name=\"Vehicle\">{0}" +
121 " <wsdl:input message=\"tns:VehicleSoapIn\" />{0}" +
122 " <wsdl:output message=\"tns:VehicleSoapOut\" />{0}" +
123 " </wsdl:operation>{0}" +
124 " </wsdl:portType>{0}" +
125 " <wsdl:binding name=\"IncludeTestServicesSoap\" type=\"tns:IncludeTestServicesSoap\">{0}" +
127 " <soap:binding transport=\"http://schemas.xmlsoap.org/soap/http\" />{0}" +
129 " <soap:binding transport=\"http://schemas.xmlsoap.org/soap/http\" style=\"document\" />{0}" +
131 " <wsdl:operation name=\"EchoString\">{0}" +
132 " <soap:operation soapAction=\"http://tempuri.org/EchoString\" style=\"document\" />{0}" +
134 " <soap:body use=\"literal\" />{0}" +
135 " </wsdl:input>{0}" +
136 " <wsdl:output>{0}" +
137 " <soap:body use=\"literal\" />{0}" +
138 " </wsdl:output>{0}" +
139 " </wsdl:operation>{0}" +
140 " <wsdl:operation name=\"Vehicle\">{0}" +
141 " <soap:operation soapAction=\"http://tempuri.org/Vehicle\" style=\"document\" />{0}" +
143 " <soap:body use=\"literal\" />{0}" +
144 " </wsdl:input>{0}" +
145 " <wsdl:output>{0}" +
146 " <soap:body use=\"literal\" />{0}" +
147 " </wsdl:output>{0}" +
148 " </wsdl:operation>{0}" +
149 " </wsdl:binding>{0}" +
151 " <wsdl:binding name=\"IncludeTestServicesSoap12\" type=\"tns:IncludeTestServicesSoap\">{0}" +
152 " <soap12:binding transport=\"http://schemas.xmlsoap.org/soap/http\" />{0}" +
153 " <wsdl:operation name=\"EchoString\">{0}" +
154 " <soap12:operation soapAction=\"http://tempuri.org/EchoString\" style=\"document\" />{0}" +
156 " <soap12:body use=\"literal\" />{0}" +
157 " </wsdl:input>{0}" +
158 " <wsdl:output>{0}" +
159 " <soap12:body use=\"literal\" />{0}" +
160 " </wsdl:output>{0}" +
161 " </wsdl:operation>{0}" +
162 " <wsdl:operation name=\"Vehicle\">{0}" +
163 " <soap12:operation soapAction=\"http://tempuri.org/Vehicle\" style=\"document\" />{0}" +
165 " <soap12:body use=\"literal\" />{0}" +
166 " </wsdl:input>{0}" +
167 " <wsdl:output>{0}" +
168 " <soap12:body use=\"literal\" />{0}" +
169 " </wsdl:output>{0}" +
170 " </wsdl:operation>{0}" +
171 " </wsdl:binding>{0}" +
173 " <wsdl:service name=\"IncludeTestServices\">{0}" +
175 " <documentation xmlns=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
177 " <wsdl:port name=\"IncludeTestServicesSoap\" binding=\"tns:IncludeTestServicesSoap\">{0}" +
178 " <soap:address location=\"http://localhost/IncludeTestServices.asmx\" />{0}" +
181 " <wsdl:port name=\"IncludeTestServicesSoap12\" binding=\"tns:IncludeTestServicesSoap12\">{0}" +
182 " <soap12:address location=\"http://localhost/IncludeTestServices.asmx\" />{0}" +
185 " </wsdl:service>{0}" +
186 "</wsdl:definitions>", Environment.NewLine), sw.ToString (), "#5");
189 public class IncludeTestServices : WebService
192 [return: XmlElement ("MyTime", DataType = "time")]
193 public DateTime EchoString ([XmlElement (DataType = "string")] string strval)
199 [XmlInclude (typeof (Car))]
200 public Vehicle Vehicle (string licenseNumber)
202 if (licenseNumber == "0") {
203 Vehicle v = new Car ();
204 v.licenseNumber = licenseNumber;
211 [XmlRoot ("NewVehicle")]
212 public abstract class Vehicle
214 public string licenseNumber;
215 public DateTime make;
219 public class Car : Vehicle