ServiceDescription.Write Method

Definition

Writes out the ServiceDescription as a Web Services Description Language (WSDL) file.

Overloads

Write(String)

Writes out the ServiceDescription as a Web Services Description Language (WSDL) file to the specified path.

Write(Stream)

Writes out the ServiceDescription to the specified Stream.

Write(TextWriter)

Writes out the ServiceDescription as a Web Services Description Language (WSDL) file to the TextWriter.

Write(XmlWriter)

Writes out the ServiceDescription to the XmlWriter as a Web Services Description Language (WSDL) file.

Write(String)

Writes out the ServiceDescription as a Web Services Description Language (WSDL) file to the specified path.

C#
public void Write(string fileName);

Parameters

fileName
String

The path to which the WSDL file is written.

Examples

C#
// Read a ServiceDescription from existing WSDL.
ServiceDescription myServiceDescription =
   ServiceDescription.Read("Input_CS.wsdl");
myServiceDescription.TargetNamespace = "http://tempuri.org/";

// Get the ServiceCollection of the ServiceDescription.
ServiceCollection myServiceCollection = myServiceDescription.Services;

// Remove the Service at index 0 of the collection.
myServiceCollection.Remove(myServiceDescription.Services[0]);

// Build a new Service.
Service myService = new Service();
myService.Name = "MathService";
XmlQualifiedName myXmlQualifiedName =
   new XmlQualifiedName("s0:MathServiceSoap");

// Build a new Port for SOAP.
Port mySoapPort= new Port();

mySoapPort.Name = "MathServiceSoap";

mySoapPort.Binding = myXmlQualifiedName;

SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding();
mySoapAddressBinding.Location =
   "http://localhost/ServiceCollection_Item/AddSub_CS.asmx";
mySoapPort.Extensions.Add(mySoapAddressBinding);

// Build a new Port for HTTP-GET.
XmlQualifiedName myXmlQualifiedName2 =
   new XmlQualifiedName("s0:MathServiceHttpGet");

Port myHttpGetPort= new Port();
myHttpGetPort.Name="MathServiceHttpGet";
myHttpGetPort.Binding=myXmlQualifiedName2;
HttpAddressBinding myHttpAddressBinding = new HttpAddressBinding();
myHttpAddressBinding.Location =
   "http://localhost/ServiceCollection_Item/AddSub_CS.asmx";
myHttpGetPort.Extensions.Add(myHttpAddressBinding);

// Add the ports to the service.
myService.Ports.Add(myHttpGetPort);
myService.Ports.Add(mySoapPort);

// Add the service to the ServiceCollection.
myServiceCollection .Add(myService);

// Write to a new WSDL file.
myServiceDescription.Write("output.wsdl");

Applies to

.NET Framework 4.8.1 та інші версії
Продукт Версії
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

Write(Stream)

Writes out the ServiceDescription to the specified Stream.

C#
public void Write(System.IO.Stream stream);

Parameters

stream
Stream

A Stream, passed by reference, which contains the Web Services Description Language (WSDL) file produced.

Examples

C#
FileStream myFileStream = new FileStream("output.wsdl",
   FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter myStreamWriter = new StreamWriter(myFileStream);

// Write the WSDL.
Console.WriteLine("Writing a new WSDL file.");
myServiceDescription.Write(myStreamWriter);
myStreamWriter.Close();
myFileStream.Close();

Applies to

.NET Framework 4.8.1 та інші версії
Продукт Версії
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

Write(TextWriter)

Writes out the ServiceDescription as a Web Services Description Language (WSDL) file to the TextWriter.

C#
public void Write(System.IO.TextWriter writer);

Parameters

writer
TextWriter

A TextWriter that contains the WSDL file produced.

Applies to

.NET Framework 4.8.1 та інші версії
Продукт Версії
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

Write(XmlWriter)

Writes out the ServiceDescription to the XmlWriter as a Web Services Description Language (WSDL) file.

C#
public void Write(System.Xml.XmlWriter writer);

Parameters

writer
XmlWriter

An XmlWriter, passed by reference, which contains the WSDL file produced.

Examples

ServiceDescription_Read#4

Applies to

.NET Framework 4.8.1 та інші версії
Продукт Версії
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)