public void DuplicateContract () { var label = new TestLabel ("DuplicateContract"); var cd = new ContractDescription ("MyContract"); var endpoint = new ServiceEndpoint ( cd, new BasicHttpBinding (), new EndpointAddress (HttpUri)); var exporter = new WsdlExporter (); exporter.ExportContract (cd); exporter.ExportContract (cd); exporter.ExportEndpoint (endpoint); CheckExport ( exporter, new QName ("MyContract", "http://tempuri.org/"), "BasicHttpBinding", 1, label); }
public static Wsdl Generate(Type contract) { var exporter = new WsdlExporter(); exporter.ExportContract(ContractDescription.GetContract(contract)); var metadataSet = exporter.GetGeneratedMetadata(); var schemaStream = new MemoryStream(); metadataSet.WriteTo(new XmlTextWriter(new StreamWriter(schemaStream))); schemaStream.Position = 0; var source = XDocument.Load( new XmlTextReader(schemaStream)); return new Wsdl(source); }
//somebody fix this name! void ExportContractExpectException (WsdlExporter we, ContractDescription cd, Type exception_type, string msg) { try { we.ExportContract (cd); } catch (Exception e) { if (e.GetType () == exception_type) return; Assert.Fail (String.Format ("[{0}] Expected {1}, but got : {2}", msg, exception_type, e)); } Assert.Fail (String.Format ("[{0}] Expected {1}", msg, exception_type)); }
public void ExportBar1Contract () { WsdlExporter we = new WsdlExporter (); ContractDescription cd = ContractDescription.GetContract (typeof (Bar1)); we.ExportContract (cd); }
//FIXME: One check not working, BeginGetResult public void ExportMexContract () { WsdlExporter we = new WsdlExporter (); ContractDescription cd = ContractDescription.GetContract (typeof (IMetadataExchange)); we.ExportContract (cd); MetadataSet ms = we.GetGeneratedMetadata (); WSServiceDescription sd = GetServiceDescription (ms, "http://schemas.microsoft.com/2006/04/mex", "ExportMexContract"); CheckMessage (sd, "IMetadataExchange_Get_InputMessage", "request", "http://schemas.microsoft.com/Message:MessageBody", true, "#exc0"); CheckMessage (sd, "IMetadataExchange_Get_OutputMessage", "GetResult", "http://schemas.microsoft.com/Message:MessageBody", true, "#exc1"); //PortType PortType port_type = sd.PortTypes ["IMetadataExchange"]; Assert.IsNotNull (port_type, "#exc2, PortType named IMetadataExchange not found."); Assert.AreEqual (1, port_type.Operations.Count, "#exc3"); Operation op = port_type.Operations [0]; Assert.AreEqual ("Get", op.Name, "#exc4"); Assert.AreEqual (2, op.Messages.Count, "#exc5"); CheckOperationMessage (op.Messages [0], "http://schemas.microsoft.com/2006/04/mex:IMetadataExchange_Get_InputMessage", typeof (OperationInput), "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get"); CheckOperationMessage (op.Messages [1], "http://schemas.microsoft.com/2006/04/mex:IMetadataExchange_Get_OutputMessage", typeof (OperationOutput), "http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse"); CheckSpecialMessage (ms, "#exc6"); Assert.AreEqual (1, we.GeneratedWsdlDocuments.Count, "GeneratedWsdlDocuments.Count"); Assert.AreEqual (1, we.GeneratedXmlSchemas.Count, "GeneratedXmlSchemas.Count"); }
// System.Xml.Schema.XmlSchemaException : XmlSchema error: Named item // http://schemas.datacontract.org/2004/07/System.Reflection:ArrayOfTypeInfo was already contained // in the schema object table. Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic // MS implementation. Related schema item SourceUri: , Line 0, Position 0. public void ExportMessageContract () { WsdlExporter we = new WsdlExporter (); ContractDescription cd = ContractDescription.GetContract (typeof (IFoo2)); we.ExportContract (cd); }
public void ExportContract2a () { WsdlExporter we = new WsdlExporter (); we.ExportContract (ContractDescription.GetContract (typeof (IFoo1))); //IFoo1a.Op1 is the same operations as IFoo1.Op1, so cant be exported //the message element for both is the same //(Compared by names not signature) ExportContractExpectException (we, ContractDescription.GetContract (typeof (IFoo1a)), typeof (InvalidOperationException), "ExportContract2a"); }
public void ExportContract2 () { WsdlExporter we = new WsdlExporter (); we.ExportContract (ContractDescription.GetContract (typeof (IFoo1))); MetadataSet ms = we.GetGeneratedMetadata (); Assert.AreEqual (5, ms.MetadataSections.Count); }
public void ExportContract1 () { WsdlExporter we = new WsdlExporter (); we.ExportContract (ContractDescription.GetContract (typeof (IEchoService))); MetadataSet ms = we.GetGeneratedMetadata (); Assert.AreEqual (5, ms.MetadataSections.Count); CheckContract_IEchoService (ms, "ExportContract1"); }
public void ExportContractInvalid2 () { WsdlExporter we = new WsdlExporter (); we.ExportContract (ContractDescription.GetContract (typeof (IEchoService2))); //Invalid as IEchoService3.Echo is http://tempuri.org/Echo message which has already been exported //Even though, the service name is different ExportContractExpectException (we, ContractDescription.GetContract (typeof (IEchoService3)), typeof (InvalidOperationException), "ExportContractInvalid2"); }
public void ExportContractInvalid1 () { WsdlExporter we = new WsdlExporter (); we.ExportContract (ContractDescription.GetContract (typeof (IEchoService2))); //Duplicate contract QNames not allowed ExportContractExpectException (we, ContractDescription.GetContract (typeof (IEchoService2)), typeof (ArgumentException), "ExportContractInvalid1"); }