Export (0) Print
Expand All

MimeXmlBinding Class

Represents an extensibility element added to a MimePart, an InputBinding or an OutputBinding. It specifies the schema for XML messages that are not SOAP compliant. This class cannot be inherited.

For a list of all members of this type, see MimeXmlBinding Members.

System.Object
   System.Web.Services.Description.ServiceDescriptionFormatExtension
      System.Web.Services.Description.MimeXmlBinding

[Visual Basic]
NotInheritable Public Class MimeXmlBinding
   Inherits ServiceDescriptionFormatExtension
[C#]
public sealed class MimeXmlBinding :
   ServiceDescriptionFormatExtension
[C++]
public __gc __sealed class MimeXmlBinding : public
   ServiceDescriptionFormatExtension
[JScript]
public class MimeXmlBinding extends
   ServiceDescriptionFormatExtension

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

For more information about specifying protocols for XML Web services, see Building XML Web Services Using ASP.NET. For more information about Web Services Description Language (WSDL), see the specification at http://www.w3.org/TR/wsdl/.

Example

[Visual Basic, C#, C++] The following example demonstrates a typical use of the MimeXmlBinding class.

[Visual Basic] 
Imports System
Imports System.Web.Services.Description
Imports System.Collections
Imports System.Xml

Class MyXmlBinding
   
   Public Shared Sub Main()
      Try
         Dim myDescription As ServiceDescription = ServiceDescription.Read _
                                       ("MimeXmlBinding_Part_3_Input_VB.wsdl")
         ' Create the 'Binding' object.
         Dim myBinding As New Binding()
         ' Initialize 'Name' property of 'Binding' class.
         myBinding.Name = "MimeXmlBinding_Part_3_ServiceHttpPost"
         Dim myXmlQualifiedName As New XmlQualifiedName("s0:MimeXmlBinding_Part_3_ServiceHttpPost")
         myBinding.Type = myXmlQualifiedName
         ' Create the 'HttpBinding' object.
         Dim myHttpBinding As New HttpBinding()
         myHttpBinding.Verb = "POST"
         ' Add the 'HttpBinding' to the 'Binding'.
         myBinding.Extensions.Add(myHttpBinding)
         ' Create the 'OperationBinding' object.
         Dim myOperationBinding As New OperationBinding()
         myOperationBinding.Name = "AddNumbers"
         Dim myHttpOperationBinding As New HttpOperationBinding()
         myHttpOperationBinding.Location = "/AddNumbers"
         ' Add the 'HttpOperationBinding' to 'OperationBinding'.
         myOperationBinding.Extensions.Add(myHttpOperationBinding)
         ' Create the 'InputBinding' object.
         Dim myInputBinding As New InputBinding()
         Dim myMimeContentBinding As New MimeContentBinding()
         myMimeContentBinding.Type = "application/x-www-form-urlencoded"
         myInputBinding.Extensions.Add(myMimeContentBinding)
         ' Add the 'InputBinding' to 'OperationBinding'.
         myOperationBinding.Input = myInputBinding
         ' Create an OutputBinding.
         Dim myOutputBinding As New OutputBinding()
         Dim myMimeXmlBinding As New MimeXmlBinding()

         ' Initialize the Part property of the MimeXmlBinding. 
         myMimeXmlBinding.Part = "Body"

         ' Add the MimeXmlBinding to the OutputBinding.
         myOutputBinding.Extensions.Add(myMimeXmlBinding)
         ' Add the 'OutPutBinding' to 'OperationBinding'.
         myOperationBinding.Output = myOutputBinding
         ' Add the 'OperationBinding' to 'Binding'.
         myBinding.Operations.Add(myOperationBinding)
         ' Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'.
         myDescription.Bindings.Add(myBinding)
         ' Write the 'ServiceDescription' as a WSDL file.
         myDescription.Write("MimeXmlBinding_Part_3_Output_VB.wsdl")
         Console.WriteLine("WSDL file with name 'MimeXmlBinding_Part_3_Output_VB.wsdl' is" + _
                                                                     " created successfully.")
      Catch e As Exception
         Console.WriteLine("Exception: {0}", e.Message)
      End Try
   End Sub 'Main
End Class 'MyXmlBinding

[C#] 
using System;
using System.Web.Services.Description;
using System.Collections;
using System.Xml;

class MyXmlBinding
{
   public static void Main()
   {
      try
      {
         ServiceDescription myDescription = 
            ServiceDescription.Read("MimeXmlBinding_Part_3_Input_CS.wsdl");
         // Create the 'Binding' object.
         Binding myBinding = new Binding();
         // Initialize 'Name' property of 'Binding' class.
         myBinding.Name = "MimeXmlBinding_Part_3_ServiceHttpPost";
         XmlQualifiedName 
            myXmlQualifiedName = new XmlQualifiedName("s0:MimeXmlBinding_Part_3_ServiceHttpPost");
         myBinding.Type = myXmlQualifiedName;
         // Create the 'HttpBinding' object.
         HttpBinding myHttpBinding = new HttpBinding();
         myHttpBinding.Verb="POST";
         // Add the 'HttpBinding' to the 'Binding'.
         myBinding.Extensions.Add(myHttpBinding);
         // Create the 'OperationBinding' object.
         OperationBinding myOperationBinding = new OperationBinding();
         myOperationBinding.Name = "AddNumbers";
         HttpOperationBinding myHttpOperationBinding = new HttpOperationBinding();
         myHttpOperationBinding.Location="/AddNumbers";
         // Add the 'HttpOperationBinding' to 'OperationBinding'.
         myOperationBinding.Extensions.Add(myHttpOperationBinding);   
         // Create the 'InputBinding' object.
         InputBinding myInputBinding = new InputBinding();
         MimeContentBinding myMimeContentBinding = new MimeContentBinding();
         myMimeContentBinding.Type="application/x-www-form-urlencoded";
         myInputBinding.Extensions.Add(myMimeContentBinding);
         // Add the 'InputBinding' to 'OperationBinding'.
         myOperationBinding.Input = myInputBinding;   
         // Create an OutputBinding.
         OutputBinding myOutputBinding = new OutputBinding();
         MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding();

         // Initialize the Part property of the MimeXmlBinding. 
         myMimeXmlBinding.Part="Body";

         // Add the MimeXmlBinding to the OutputBinding.
         myOutputBinding.Extensions.Add(myMimeXmlBinding);
         // Add the 'OutPutBinding' to 'OperationBinding'.
         myOperationBinding.Output = myOutputBinding; 
         // Add the 'OperationBinding' to 'Binding'.
         myBinding.Operations.Add(myOperationBinding);
         // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'.
         myDescription.Bindings.Add(myBinding);
         // Write the 'ServiceDescription' as a WSDL file.
         myDescription.Write("MimeXmlBinding_Part_3_Output_CS.wsdl");
         Console.WriteLine("WSDL file with name 'MimeXmlBinding_Part_3_Output_CS.wsdl' is"
                                                           + " created successfully.");
      }
      catch(Exception e)
      {
         Console.WriteLine( "Exception: {0}", e.Message );
      }
    }
}

[C++] 
#using <mscorlib.dll>
#using <System.Xml.dll>
#using <System.Web.Services.dll>
#using <System.dll>
using namespace System;
using namespace System::Web::Services::Description;
using namespace System::Collections;
using namespace System::Xml;

int main()
{
   try
   {
      ServiceDescription* myDescription =
         ServiceDescription::Read(S"MimeXmlBinding_Part_3_Input_CS.wsdl");
      // Create the 'Binding' object.
      Binding* myBinding = new Binding();
      // Initialize 'Name' property of 'Binding' class.
      myBinding->Name = S"MimeXmlBinding_Part_3_ServiceHttpPost";
      XmlQualifiedName*myXmlQualifiedName = 
         new XmlQualifiedName(S"s0:MimeXmlBinding_Part_3_ServiceHttpPost");
      myBinding->Type = myXmlQualifiedName;
      // Create the 'HttpBinding' object.
      HttpBinding* myHttpBinding = new HttpBinding();
      myHttpBinding->Verb=S"POST";
      // Add the 'HttpBinding' to the 'Binding'.
      myBinding->Extensions->Add(myHttpBinding);
      // Create the 'OperationBinding' object.
      OperationBinding* myOperationBinding = new OperationBinding();
      myOperationBinding->Name = S"AddNumbers";
      HttpOperationBinding* myHttpOperationBinding = new HttpOperationBinding();
      myHttpOperationBinding->Location=S"/AddNumbers";
      // Add the 'HttpOperationBinding' to 'OperationBinding'.
      myOperationBinding->Extensions->Add(myHttpOperationBinding);
      // Create the 'InputBinding' object.
      InputBinding* myInputBinding = new InputBinding();
      MimeContentBinding* myMimeContentBinding = new MimeContentBinding();
      myMimeContentBinding->Type=S"application/x-www-form-urlencoded";
      myInputBinding->Extensions->Add(myMimeContentBinding);
      // Add the 'InputBinding' to 'OperationBinding'.
      myOperationBinding->Input = myInputBinding;
      // Create an OutputBinding.
      OutputBinding* myOutputBinding = new OutputBinding();
      MimeXmlBinding* myMimeXmlBinding = new MimeXmlBinding();

      // Initialize the Part property of the MimeXmlBinding.
      myMimeXmlBinding->Part=S"Body";

      // Add the MimeXmlBinding to the OutputBinding.
      myOutputBinding->Extensions->Add(myMimeXmlBinding);
      // Add the 'OutPutBinding' to 'OperationBinding'.
      myOperationBinding->Output = myOutputBinding;
      // Add the 'OperationBinding' to 'Binding'.
      myBinding->Operations->Add(myOperationBinding);
      // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'.
      myDescription->Bindings->Add(myBinding);
      // Write the 'ServiceDescription' as a WSDL file.
      myDescription->Write(S"MimeXmlBinding_Part_3_Output_CS.wsdl");
      Console::WriteLine(S"WSDL file with name 'MimeXmlBinding_Part_3_Output_CS.wsdl' is"
         S" created successfully.");
   }
   catch(Exception* e)
   {
      Console::WriteLine( S"Exception: {0}", e->Message );
   }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Web.Services.Description

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Web.Services (in System.Web.Services.dll)

See Also

MimeXmlBinding Members | System.Web.Services.Description Namespace

Show:
© 2014 Microsoft