5 // Ankit Jain <JAnkit@novell.com>
7 // Copyright (C) 2006 Novell, Inc. http://www.novell.com
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Collections.Generic;
32 using System.ServiceModel.Channels;
33 using System.ServiceModel.Description;
34 using NUnit.Framework;
35 using System.Runtime.Serialization;
36 using System.ServiceModel;
37 using System.Web.Services;
39 using WSServiceDescription = System.Web.Services.Description.ServiceDescription;
40 using WSMessage = System.Web.Services.Description.Message;
41 using WSBinding = System.Web.Services.Description.Binding;
42 using QName = System.Xml.XmlQualifiedName;
44 using SMMessage = System.ServiceModel.Channels.Message;
47 using System.Web.Services.Description;
48 using System.Xml.Schema;
49 using System.Xml.Serialization;
50 using System.Reflection;
52 namespace MonoTests.System.ServiceModel.Description
55 public class WsdlExporterTest
58 [Category ("NotWorking")]
61 WsdlExporter we = new WsdlExporter ();
63 Assert.IsNotNull (we.GetGeneratedMetadata ());
64 Assert.IsNotNull (we.GeneratedWsdlDocuments, "#c1");
65 Assert.AreEqual (0, we.GeneratedWsdlDocuments.Count, "#c2");
67 Assert.IsNotNull (we.GeneratedXmlSchemas, "#c3");
68 Assert.AreEqual (0, we.GeneratedXmlSchemas.Count, "#c4");
72 public void ExportEndpointTest ()
74 WsdlExporter we = new WsdlExporter ();
76 ServiceEndpoint se = new ServiceEndpoint (ContractDescription.GetContract (typeof (IEchoService)));
77 se.Binding = new BasicHttpBinding ();
78 se.Address = new EndpointAddress ("http://localhost:8080");
79 //TEST Invalid name: 5se.Name = "Service#1";
80 //se.Name = "Service0";
81 //se.ListenUri = new Uri ("http://localhost:8080/svc");
83 we.ExportEndpoint (se);
85 MetadataSet ms = we.GetGeneratedMetadata ();
86 Assert.AreEqual (6, ms.MetadataSections.Count);
87 CheckContract_IEchoService (ms, "#eet01");
89 WSServiceDescription sd = GetServiceDescription (ms, "http://tempuri.org/", "ExportEndpointTest");
90 CheckServicePort (GetService (sd, "service", "ExportEndpointTest"),
91 "BasicHttpBinding_IEchoService", new XmlQualifiedName ("BasicHttpBinding_IEchoService", "http://tempuri.org/"),
92 "http://localhost:8080/", "#eet02");
94 CheckBasicHttpBinding (sd, "BasicHttpBinding_IEchoService", new XmlQualifiedName ("IEchoService", "http://myns/echo"),
95 "Echo", "http://myns/echo/IEchoService/Echo", true, true, "#eet03");
99 public void ExportEndpointTest2 ()
101 WsdlExporter we = new WsdlExporter ();
103 ServiceEndpoint se = new ServiceEndpoint (ContractDescription.GetContract (typeof (IEchoService2)));
104 se.Binding = new BasicHttpBinding ();
105 se.Address = new EndpointAddress ("http://localhost:8080");
106 we.ExportEndpoint (se);
108 MetadataSet ms = we.GetGeneratedMetadata ();
109 Assert.AreEqual (5, ms.MetadataSections.Count);
111 WSServiceDescription sd = ms.MetadataSections [0].Metadata as WSServiceDescription;
112 CheckContract_IEchoService2 (ms, "#eet20");
113 CheckServicePort (GetService (GetServiceDescription (ms, "http://tempuri.org/", "#eet21"), "service", "ExportEndpointTest"),
114 "BasicHttpBinding_ThisIsEchoService", new XmlQualifiedName ("BasicHttpBinding_ThisIsEchoService", "http://tempuri.org/"),
115 "http://localhost:8080/", "#eet22");
117 CheckBasicHttpBinding (sd, "BasicHttpBinding_ThisIsEchoService",
118 new XmlQualifiedName ("ThisIsEchoService", "http://tempuri.org/"),
119 "Echo", "http://tempuri.org/ThisIsEchoService/Echo", true, true, "#eet03");
121 //FIXME: CheckXmlSchema
125 public void ExportEndpointTest3 ()
127 WsdlExporter we = new WsdlExporter ();
128 /*ContractDescription contract =*/ ContractDescription.GetContract (typeof (IEchoService2));
130 ServiceEndpoint se = new ServiceEndpoint (ContractDescription.GetContract (typeof (IEchoService2)));
131 se.Binding = new BasicHttpBinding ();
132 se.Address = new EndpointAddress ("http://localhost:8080");
133 we.ExportEndpoint (se);
135 se = new ServiceEndpoint (ContractDescription.GetContract (typeof (IEchoService)));
136 se.Binding = new BasicHttpBinding ();
137 se.Address = new EndpointAddress ("http://somehost");
138 we.ExportEndpoint (se);
140 MetadataSet ms = we.GetGeneratedMetadata ();
141 Assert.AreEqual (7, ms.MetadataSections.Count);
143 Service svc = GetService (
144 GetServiceDescription (ms, "http://tempuri.org/", "ExportEndpointTest"),
145 "service", "ExportEndpointTest");
147 CheckContract_IEchoService (ms, "#eet31");
148 CheckServicePort (svc, "BasicHttpBinding_IEchoService",
149 new XmlQualifiedName ("BasicHttpBinding_IEchoService", "http://tempuri.org/"),
150 "http://somehost/", "#eet32");
152 CheckContract_IEchoService2 (ms, "#eet33");
153 CheckServicePort (svc, "BasicHttpBinding_ThisIsEchoService",
154 new XmlQualifiedName ("BasicHttpBinding_ThisIsEchoService", "http://tempuri.org/"),
155 "http://localhost:8080/", "#eet34");
158 WSServiceDescription sd = ms.MetadataSections [0].Metadata as WSServiceDescription;
159 CheckBasicHttpBinding (sd, "BasicHttpBinding_IEchoService", new XmlQualifiedName ("IEchoService", "http://myns/echo"),
160 "Echo", "http://myns/echo/IEchoService/Echo", true, true, "#eet35");
162 CheckBasicHttpBinding (sd, "BasicHttpBinding_ThisIsEchoService", new XmlQualifiedName ("ThisIsEchoService", "http://tempuri.org/"),
163 "Echo", "http://tempuri.org/ThisIsEchoService/Echo", true, true, "#eet36");
166 //FIXME: CheckXmlSchema
170 public void ExportContractInvalid1 ()
172 WsdlExporter we = new WsdlExporter ();
174 we.ExportContract (ContractDescription.GetContract (typeof (IEchoService2)));
175 //Duplicate contract QNames not allowed
176 ExportContractExpectException (we, ContractDescription.GetContract (typeof (IEchoService2)),
177 typeof (ArgumentException), "ExportContractInvalid1");
181 public void ExportContractInvalid2 ()
183 WsdlExporter we = new WsdlExporter ();
185 we.ExportContract (ContractDescription.GetContract (typeof (IEchoService2)));
186 //Invalid as IEchoService3.Echo is http://tempuri.org/Echo message which has already been exported
187 //Even though, the service name is different
188 ExportContractExpectException (we, ContractDescription.GetContract (typeof (IEchoService3)),
189 typeof (InvalidOperationException), "ExportContractInvalid2");
193 public void ExportContract1 ()
195 WsdlExporter we = new WsdlExporter ();
196 we.ExportContract (ContractDescription.GetContract (typeof (IEchoService)));
198 MetadataSet ms = we.GetGeneratedMetadata ();
199 Assert.AreEqual (5, ms.MetadataSections.Count);
201 CheckContract_IEchoService (ms, "ExportContract1");
205 public void ExportContract2 ()
207 WsdlExporter we = new WsdlExporter ();
208 we.ExportContract (ContractDescription.GetContract (typeof (IFoo1)));
210 MetadataSet ms = we.GetGeneratedMetadata ();
211 Assert.AreEqual (5, ms.MetadataSections.Count);
215 public void ExportContract2a ()
217 WsdlExporter we = new WsdlExporter ();
218 we.ExportContract (ContractDescription.GetContract (typeof (IFoo1)));
219 //IFoo1a.Op1 is the same operations as IFoo1.Op1, so cant be exported
220 //the message element for both is the same
221 //(Compared by names not signature)
222 ExportContractExpectException (we, ContractDescription.GetContract (typeof (IFoo1a)),
223 typeof (InvalidOperationException), "ExportContract2a");
227 public void ExportMessageContract ()
229 WsdlExporter we = new WsdlExporter ();
230 ContractDescription cd = ContractDescription.GetContract (typeof (IFoo2));
231 we.ExportContract (cd);
235 [Category ("NotWorking")]
236 //FIXME: One check not working, BeginGetResult
237 public void ExportMexContract ()
239 WsdlExporter we = new WsdlExporter ();
240 ContractDescription cd = ContractDescription.GetContract (typeof (IMetadataExchange));
241 we.ExportContract (cd);
243 MetadataSet ms = we.GetGeneratedMetadata ();
245 WSServiceDescription sd = GetServiceDescription (ms, "http://schemas.microsoft.com/2006/04/mex", "ExportMexContract");
247 CheckMessage (sd, "IMetadataExchange_Get_InputMessage", "request", "http://schemas.microsoft.com/Message:MessageBody", true, "#exc0");
248 CheckMessage (sd, "IMetadataExchange_Get_OutputMessage", "GetResult", "http://schemas.microsoft.com/Message:MessageBody", true, "#exc1");
251 PortType port_type = sd.PortTypes ["IMetadataExchange"];
252 Assert.IsNotNull (port_type, "#exc2, PortType named IMetadataExchange not found.");
254 Assert.AreEqual (1, port_type.Operations.Count, "#exc3");
255 Operation op = port_type.Operations [0];
256 Assert.AreEqual ("Get", op.Name, "#exc4");
258 Assert.AreEqual (2, op.Messages.Count, "#exc5");
259 CheckOperationMessage (op.Messages [0], "http://schemas.microsoft.com/2006/04/mex:IMetadataExchange_Get_InputMessage",
260 typeof (OperationInput), "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get");
262 CheckOperationMessage (op.Messages [1], "http://schemas.microsoft.com/2006/04/mex:IMetadataExchange_Get_OutputMessage",
263 typeof (OperationOutput), "http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse");
265 CheckSpecialMessage (ms, "#exc6");
267 Assert.AreEqual (1, we.GeneratedWsdlDocuments.Count, "GeneratedWsdlDocuments.Count");
268 Assert.AreEqual (1, we.GeneratedXmlSchemas.Count, "GeneratedXmlSchemas.Count");
272 public void ExportBar1Contract ()
274 WsdlExporter we = new WsdlExporter ();
275 ContractDescription cd = ContractDescription.GetContract (typeof (Bar1));
276 we.ExportContract (cd);
281 //Checks the ComplexType emitted for CLR type Message
282 void CheckSpecialMessage (MetadataSet ms, string label)
284 //Check ComplexType MessageBody
285 XmlSchema xs = GetXmlSchema (ms, "http://schemas.microsoft.com/Message", label + " #csm0");
286 foreach (XmlSchemaObject o in xs.SchemaTypes.Values) {
287 XmlSchemaComplexType complex_type = o as XmlSchemaComplexType;
288 if (complex_type == null)
290 if (complex_type.Name != "MessageBody")
294 Assert.IsNotNull (complex_type.Particle, label + " #cms1");
295 Assert.AreEqual (typeof (XmlSchemaSequence), complex_type.Particle.GetType (), label + " #cms2");
296 XmlSchemaSequence seq = (XmlSchemaSequence) complex_type.Particle;
298 Assert.AreEqual (1, seq.Items.Count, label + " #cms3");
299 Assert.AreEqual (typeof (XmlSchemaAny), seq.Items [0].GetType (), label + " #cms4");
300 XmlSchemaAny any = (XmlSchemaAny) seq.Items [0];
302 Assert.AreEqual ("##any", any.Namespace, label + " #cms5");
303 Assert.AreEqual (0, any.MinOccurs, label + " #cms6");
304 Assert.AreEqual ("unbounded", any.MaxOccursString, label + " #cms6");
308 //somebody fix this name!
309 void ExportContractExpectException (WsdlExporter we, ContractDescription cd, Type exception_type, string msg)
312 we.ExportContract (cd);
313 } catch (Exception e) {
314 if (e.GetType () == exception_type)
316 Assert.Fail (String.Format ("[{0}] Expected {1}, but got : {2}", msg, exception_type, e));
319 Assert.Fail (String.Format ("[{0}] Expected {1}", msg, exception_type));
322 WSServiceDescription GetServiceDescription (MetadataSet ms, string ns, string msg)
324 foreach (MetadataSection section in ms.MetadataSections) {
325 WSServiceDescription sd = section.Metadata as WSServiceDescription;
328 if (sd.TargetNamespace == ns) {
329 /*Assert.AreEqual ("http://schemas.xmlsoap.org/wsdl/", section.Dialect, msg + " Dialect");
330 Assert.AreEqual (id, section.Identifier, msg + "Identifier");
331 Assert.AreEqual (0, section.Attributes.Count, "#cw4");*/
337 Assert.Fail (String.Format ("[{0}] ServiceDescription for ns : {1} not found.", msg, ns));
341 XmlSchema GetXmlSchema (MetadataSet ms, string ns, string msg)
343 foreach (MetadataSection section in ms.MetadataSections) {
344 XmlSchema xs = section.Metadata as XmlSchema;
347 if (xs.TargetNamespace == ns) {
348 /*Assert.AreEqual ("http://schemas.xmlsoap.org/wxsl/", section.Dialect, msg + " Dialect");
349 Assert.AreEqual (id, section.Identifier, msg + "Identifier");
350 Assert.AreEqual (0, section.Attributes.Count, "#cw4");*/
356 Assert.Fail (String.Format ("[{0}] XmlSchema for tns : {1} not found.", msg, ns));
359 Service GetService (WSServiceDescription sd, string name, string label)
361 Service ret = sd.Services [name];
363 Assert.Fail (String.Format ("[{0}] Service named '{1}' not found.", label, name));
367 WSBinding GetBinding (WSServiceDescription sd, string name, string label)
369 WSBinding ret = sd.Bindings [name];
371 Assert.Fail (String.Format ("[{0}] Binding named '{1}' not found.", label, name));
375 OperationBinding GetOperationBinding (WSBinding b, string name, string label)
377 foreach (OperationBinding op in b.Operations)
381 Assert.Fail (String.Format ("[{0}] OperationBinding named '{1}' not found.", label, name));
385 void CheckBasicHttpBinding (WSServiceDescription wsd, string binding_name, XmlQualifiedName binding_type,
386 string operation_name, string action, bool has_input, bool has_output, string label)
388 WSBinding b = GetBinding (wsd, binding_name, label);
389 OperationBinding op = GetOperationBinding (b, operation_name, label + " CheckBasicHttpBinding");
391 Assert.AreEqual (binding_type, b.Type, label + " #cbh0");
394 InputBinding inb = op.Input;
395 Assert.IsNotNull (inb, label + " #cbh1");
396 Assert.AreEqual (1, inb.Extensions.Count, label + " #cbh2");
398 Assert.AreEqual (typeof (SoapBodyBinding), inb.Extensions [0].GetType (), label + " #cbh3");
399 SoapBodyBinding soap_binding = (SoapBodyBinding) inb.Extensions [0];
400 Assert.AreEqual (SoapBindingUse.Literal, soap_binding.Use, label + " #cbh4");
402 if (action != null) {
403 Assert.AreEqual (1, op.Extensions.Count, label + " #chb5");
404 Assert.AreEqual (typeof (SoapOperationBinding), op.Extensions [0].GetType (), label + " #cbh6");
405 SoapOperationBinding sopb = (SoapOperationBinding) op.Extensions [0];
406 Assert.AreEqual (action, sopb.SoapAction, label + " #cbh7");
411 OutputBinding outb = op.Output;
412 Assert.IsNotNull (outb, label + " #cbh10");
413 Assert.AreEqual (1, outb.Extensions.Count, label + " #cbh11");
415 Assert.AreEqual (typeof (SoapBodyBinding), outb.Extensions [0].GetType (), label + " #cbh12");
416 SoapBodyBinding soap_binding = (SoapBodyBinding) outb.Extensions [0];
417 Assert.AreEqual (SoapBindingUse.Literal, soap_binding.Use, label + " #cbh13");
420 Assert.AreEqual (1, b.Extensions.Count, label + " #cbh20");
421 Assert.AreEqual (typeof (SoapBinding), b.Extensions [0].GetType (), label + " #cbh21");
422 SoapBinding sb = (SoapBinding) b.Extensions [0];
423 Assert.AreEqual (SoapBinding.HttpTransport, sb.Transport, label + " #cbh22");
426 void CheckServicePort (Service svc, string port_name, XmlQualifiedName binding_name, string address, string label)
428 Port port = svc.Ports [port_name];
429 Assert.IsNotNull (port, label + " #csp0");
430 Assert.AreEqual (port.Binding, binding_name, label + " #csp1");
432 Assert.AreEqual (1, port.Extensions.Count, label + " #csp2");
433 Assert.AreEqual (typeof (SoapAddressBinding), port.Extensions [0].GetType (), label + " #csp3");
434 SoapAddressBinding sab = (SoapAddressBinding) port.Extensions [0];
435 Assert.AreEqual (address, sab.Location, label + " #csp3");
438 void CheckContract_IEchoService2 (MetadataSet ms, string label)
440 WSServiceDescription wsd = GetServiceDescription (ms, "http://tempuri.org/", label + "#a1");
441 Assert.AreEqual (3, wsd.Messages.Count, "#cw5");
443 Assert.IsNotNull (wsd.Messages [0]);
444 // WSMessage m = wsd.Messages [0];
445 CheckMessage (wsd, "ThisIsEchoService_Echo_InputMessage", "http://tempuri.org/:Echo");
446 CheckMessage (wsd, "ThisIsEchoService_Echo_OutputMessage", "http://tempuri.org/:EchoResponse");
448 CheckMessage (wsd, "ThisIsEchoService_DoubleIt_InputMessage", "http://tempuri.org/:DoubleIt");
451 Assert.AreEqual (1, wsd.PortTypes.Count, "#cw6");
452 PortType port = wsd.PortTypes [0];
453 Assert.AreEqual ("ThisIsEchoService", port.Name, "#cw7");
456 Assert.AreEqual (2, port.Operations.Count, "#cw8");
458 Operation op = port.Operations [0];
459 Assert.AreEqual ("Echo", op.Name, "#co1");
460 Assert.AreEqual (0, op.Extensions.Count, "#co2");
461 Assert.IsNull (op.ParameterOrder, "#co3");
462 Assert.AreEqual ("", op.ParameterOrderString, "#co4");
463 Assert.AreEqual (0, op.Faults.Count, "#co5");
466 Assert.AreEqual (2, op.Messages.Count, "#co6");
467 Assert.AreEqual (OperationFlow.RequestResponse, op.Messages.Flow, "#co7");
469 CheckOperationMessage (op.Messages [0], "http://tempuri.org/:ThisIsEchoService_Echo_InputMessage",
470 typeof (OperationInput), "http://tempuri.org/ThisIsEchoService/Echo");
471 CheckOperationMessage (op.Messages [1], "http://tempuri.org/:ThisIsEchoService_Echo_OutputMessage",
472 typeof (OperationOutput), "http://tempuri.org/ThisIsEchoService/EchoResponse");
474 op = port.Operations [1];
475 Assert.AreEqual ("DoubleIt", op.Name, "#co8");
476 Assert.AreEqual (0, op.Extensions.Count, "#co9");
477 Assert.IsNull (op.ParameterOrder, "#co10");
478 Assert.AreEqual ("", op.ParameterOrderString, "#co11");
479 Assert.AreEqual (0, op.Faults.Count, "#co12");
482 Assert.AreEqual (1, op.Messages.Count, "#co13");
483 Assert.AreEqual (OperationFlow.OneWay, op.Messages.Flow, "#co14");
485 CheckOperationMessage (op.Messages [0], "http://tempuri.org/:ThisIsEchoService_DoubleIt_InputMessage",
486 typeof (OperationInput), "http://tempuri.org/ThisIsEchoService/DoubleIt");
488 /* FIXME: Assert.AreEqual (1, wsd.Types.Schemas.Count, "#co20");
489 XmlSchema xs = wsd.Types.Schemas [0];
491 Assert.AreEqual (4, xs.Includes.Count);
492 //FIXME: Check the imports.. */
495 void CheckContract_IEchoService (MetadataSet ms, string label)
497 WSServiceDescription wsd = GetServiceDescription (ms, "http://myns/echo", label + "#a0");
498 Assert.AreEqual (4, wsd.Messages.Count, "#cw5");
500 Assert.IsNotNull (wsd.Messages [0]);
501 //WSMessage m = wsd.Messages [0];
503 CheckMessage (wsd, "IEchoService_Echo_InputMessage", "http://myns/echo:Echo");
504 CheckMessage (wsd, "IEchoService_Echo_OutputMessage", "http://myns/echo:EchoResponse");
506 CheckMessage (wsd, "IEchoService_DoubleIt_InputMessage", "http://myns/echo:DoubleIt");
507 CheckMessage (wsd, "IEchoService_DoubleIt_OutputMessage", "http://myns/echo:DoubleItResponse");
510 Assert.AreEqual (1, wsd.PortTypes.Count, "#cw6");
511 PortType port = wsd.PortTypes [0];
512 Assert.AreEqual ("IEchoService", port.Name, "#cw7");
515 Assert.AreEqual (2, port.Operations.Count, "#cw8");
517 Operation op = port.Operations [0];
518 Assert.AreEqual ("Echo", op.Name, "#co1");
519 Assert.AreEqual (0, op.Extensions.Count, "#co2");
520 Assert.IsNull (op.ParameterOrder, "#co3");
521 Assert.AreEqual ("", op.ParameterOrderString, "#co4");
522 Assert.AreEqual (0, op.Faults.Count, "#co5");
525 Assert.AreEqual (2, op.Messages.Count, "#co6");
526 Assert.AreEqual (OperationFlow.RequestResponse, op.Messages.Flow, "#co7");
528 CheckOperationMessage (op.Messages [0], "http://myns/echo:IEchoService_Echo_InputMessage", typeof (OperationInput), "http://myns/echo/IEchoService/Echo");
529 CheckOperationMessage (op.Messages [1], "http://myns/echo:IEchoService_Echo_OutputMessage", typeof (OperationOutput), "http://myns/echo/IEchoService/EchoResponse");
531 op = port.Operations [1];
532 Assert.AreEqual ("DoubleIt", op.Name, "#co8");
533 Assert.AreEqual (0, op.Extensions.Count, "#co9");
534 Assert.IsNull (op.ParameterOrder, "#co10");
535 Assert.AreEqual ("", op.ParameterOrderString, "#co11");
536 Assert.AreEqual (0, op.Faults.Count, "#co12");
539 Assert.AreEqual (2, op.Messages.Count, "#co13");
540 Assert.AreEqual (OperationFlow.RequestResponse, op.Messages.Flow, "#co14");
542 CheckOperationMessage (op.Messages [0], "http://myns/echo:IEchoService_DoubleIt_InputMessage", typeof (OperationInput), "http://myns/echo/IEchoService/DoubleIt");
543 CheckOperationMessage (op.Messages [1], "http://myns/echo:IEchoService_DoubleIt_OutputMessage", typeof (OperationOutput), "http://myns/echo/IEchoService/DoubleItResponse");
545 /* FIXME: Assert.AreEqual (1, wsd.Types.Schemas.Count, "#co20");
546 XmlSchema xs = wsd.Types.Schemas [0];
548 Assert.AreEqual (4, xs.Includes.Count);
549 //FIXME: Check the imports.. */
552 void CheckOperationMessage (OperationMessage opmsg, string msg, Type type, string action)
554 Assert.AreEqual (type, opmsg.GetType (), "#com1");
555 Assert.AreEqual (msg, opmsg.Message.ToString (), "#com2");
556 Assert.AreEqual (0, opmsg.Extensions.Count, "#com3");
557 Assert.AreEqual (1, opmsg.ExtensibleAttributes.Length, "#com4");
558 Assert.IsNull (opmsg.Name, "#com5");
560 XmlAttribute attr = opmsg.ExtensibleAttributes [0];
561 Assert.AreEqual ("Action", attr.LocalName, "#ca1");
562 Assert.AreEqual ("http://www.w3.org/2006/05/addressing/wsdl", attr.NamespaceURI, "#ca2");
563 Assert.AreEqual (action, attr.Value, "#ca3");
566 void CheckMessage (WSServiceDescription sd, string msg_name, string part_type)
568 CheckMessage (sd, msg_name, "parameters", part_type, false, "");
571 void CheckMessage (WSServiceDescription sd, string msg_name, string part_name, string part_type, bool is_type, string label)
573 WSMessage m = sd.Messages [msg_name];
574 Assert.IsNotNull (m, label + " : Message named " + msg_name + " not found.");
576 Assert.AreEqual (msg_name, m.Name, label + " #cm1");
577 Assert.AreEqual (0, m.Extensions.Count, label + " #cm2");
579 Assert.IsNull (m.ExtensibleAttributes, label + " #cm3a");
580 Assert.AreEqual (1, m.Parts.Count, label + " #cm3");
582 Assert.AreEqual (part_name, m.Parts [0].Name, label + " #cm9");
585 Assert.AreEqual ("", m.Parts [0].Element.ToString (), label + " #cm4");
586 Assert.AreEqual (part_type, m.Parts [0].Type.ToString (), label + " #cm4a");
588 Assert.AreEqual ("", m.Parts [0].Type.ToString (), label + " #cm5");
589 Assert.AreEqual (part_type, m.Parts [0].Element.ToString (), label + " #cm5a");
592 Assert.IsNull (m.Parts [0].ExtensibleAttributes, label + " #cm6");
593 Assert.AreEqual (0, m.Parts [0].Extensions.Count, label + " #cm7");
596 void WriteTo (WsdlExporter we, string name)
598 using (XmlTextWriter xw = new XmlTextWriter (name, Encoding.UTF8)) {
599 xw.Formatting = Formatting.Indented;
600 we.GetGeneratedMetadata ().WriteTo (xw);
605 public void ExportEndpointTest5 () {
606 WsdlExporter we = new WsdlExporter ();
608 ServiceEndpoint se = new ServiceEndpoint (ContractDescription.GetContract (typeof (IEchoService)));
609 se.Binding = new BasicHttpBinding ();
610 se.Address = new EndpointAddress ("http://localhost:8080");
612 we.ExportEndpoint (se);
614 MetadataSet ms = we.GetGeneratedMetadata ();
615 Assert.AreEqual (6, ms.MetadataSections.Count);
616 WSServiceDescription wsd = GetServiceDescription (ms, "http://tempuri.org/", "ExportEndpointTest5#1");
618 SoapBinding soapBinding = (SoapBinding) wsd.Bindings [0].Extensions [0];
619 Assert.AreEqual (SoapBindingStyle.Document, soapBinding.Style, "soapBinding.Style");
620 Assert.AreEqual (SoapBinding.HttpTransport, soapBinding.Transport, "soapBinding.Transport");
644 [ServiceContract (Namespace = "http://myns/echo")]
645 public interface IEchoService
649 string Echo (string msg, int num, dc d);
652 void DoubleIt (int it, string prefix);
654 /*[OperationContract]
659 [ServiceContract (Name = "ThisIsEchoService")]
660 public interface IEchoService2
664 string Echo (string msg, int num, dc d);
666 [OperationContract (IsOneWay = true)]
667 void DoubleIt (int it, string prefix);
669 /*[OperationContract]
673 [ServiceContract (Name = "AnotherService")]
674 public interface IEchoService3
677 string Echo (string msg, int num, dc d);
679 [OperationContract (IsOneWay = true)]
680 void DoubleIt (int it, string prefix);
682 /*[OperationContract]
690 public void Foo (SMMessage msg, string s)
696 public interface IFoo1
698 //Same DataContract used in different operations
707 //Used to check whether both IFoo1 & IFoo1a
709 //Operations are not Service scoped
711 public interface IFoo1a
718 public interface IFoo2
720 // FIXME: it does not pass yet
722 OregoMessage Nanoda (OregoMessage msg);
724 // FIXME: it does not pass yet
726 Mona NewMona (Mona source);
730 public class OregoMessage
733 public string Neutral;
738 [MessageBodyMember] // it should be ignored ...
739 public string Setter { set { } }
741 public string NonMember;
748 public string OmaeMona;
751 public string OreMona;