This documentation is archived and is not being maintained.

MimePart Class

Represents an extensibility element added to a MimeMultipartRelatedBinding, specifying the concrete MIME type for the MessagePart to which the MimePart applies. This class cannot be inherited.

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

System.Object
   System.Web.Services.Description.ServiceDescriptionFormatExtension
      System.Web.Services.Description.MimePart

[Visual Basic]
NotInheritable Public Class MimePart
   Inherits ServiceDescriptionFormatExtension
[C#]
public sealed class MimePart : ServiceDescriptionFormatExtension
[C++]
public __gc __sealed class MimePart : public
   ServiceDescriptionFormatExtension
[JScript]
public class MimePart 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 the use of the methods and properties exposed by the MimePart class.

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

Public Class MyMimePart
   Public Shared Sub Main()
      Dim myServiceDescription As ServiceDescription = _
         ServiceDescription.Read("MimePart_3_Input_vb.wsdl")
      Dim myServiceDescriptionCol As New ServiceDescriptionCollection()
      myServiceDescriptionCol.Add(myServiceDescription)
      Dim myXmlQualifiedName As _
         New XmlQualifiedName("MimeServiceHttpPost", "http://tempuri.org/")

      ' Create the Binding.
      Dim myBinding As Binding = _
         myServiceDescriptionCol.GetBinding(myXmlQualifiedName)
      Dim myOperationBinding As OperationBinding = Nothing
      Dim i As Integer
      For i = 0 To myBinding.Operations.Count - 1
         If myBinding.Operations(i).Name.Equals("AddNumbers") Then
            myOperationBinding = myBinding.Operations(i)
         End If
      Next i
      ' Create the OutputBinding.
      Dim myOutputBinding As OutputBinding = myOperationBinding.Output
      Dim myMimeXmlBinding As New MimeXmlBinding()
      myMimeXmlBinding.Part = "body"

      ' Create the MimePart.
      Dim myMimePart As New MimePart()
      myMimePart.Extensions.Add(myMimeXmlBinding)
      Dim myMimePartRelatedBinding As New MimeMultipartRelatedBinding()

      ' Add the MimePart to the MimePartRelatedBinding.
      myMimePartRelatedBinding.Parts.Add(myMimePart)
      myOutputBinding.Extensions.Add(myMimePartRelatedBinding)
      myServiceDescription.Write("MimePart_3_Output_vb.wsdl")
      Console.WriteLine( _
         "MimePart_3_Output_vb.wsdl has been generated successfully.")
   End Sub 'Main
End Class 'MyMimePart

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

public class MyMimePart
{
   public static void Main()
   {
      ServiceDescription myServiceDescription  = 
         ServiceDescription.Read("MimePart_3_Input_cs.wsdl");
      ServiceDescriptionCollection myServiceDescriptionCol = 
         new ServiceDescriptionCollection();
      myServiceDescriptionCol.Add(myServiceDescription);
      XmlQualifiedName myXmlQualifiedName = 
         new XmlQualifiedName("MimeServiceHttpPost","http://tempuri.org/");

      // Create the Binding.
      Binding myBinding = 
         myServiceDescriptionCol.GetBinding(myXmlQualifiedName);
      OperationBinding myOperationBinding= null;
      for(int i=0; i< myBinding.Operations.Count; i++) 
      {
         if(myBinding.Operations[i].Name.Equals("AddNumbers"))
         {
            myOperationBinding = myBinding.Operations[i];
         }
      }
      // Create the OutputBinding.
      OutputBinding myOutputBinding = myOperationBinding.Output;
      MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding();
      myMimeXmlBinding.Part = "body";

      // Create the MimePart.
      MimePart myMimePart = new MimePart();
      myMimePart.Extensions.Add(myMimeXmlBinding);
      MimeMultipartRelatedBinding myMimePartRelatedBinding =
         new MimeMultipartRelatedBinding();

      // Add the MimePart to the MimePartRelatedBinding.
      myMimePartRelatedBinding.Parts.Add(myMimePart);
      myOutputBinding.Extensions.Add(myMimePartRelatedBinding);
      myServiceDescription.Write("MimePart_3_Output_CS.wsdl");
      Console.WriteLine(
         "MimePart_3_Output_CS.wsdl has been generated successfully."); 
   }
}

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

int main()
{
   ServiceDescription* myServiceDescription  = 
      ServiceDescription::Read(S"MimePart_3_Input_cs.wsdl");
   ServiceDescriptionCollection* myServiceDescriptionCol = 
      new ServiceDescriptionCollection();
   myServiceDescriptionCol->Add(myServiceDescription);
   XmlQualifiedName* myXmlQualifiedName = 
      new XmlQualifiedName(S"MimeServiceHttpPost",S"http://tempuri.org/");

   // Create the Binding.
   Binding* myBinding = 
      myServiceDescriptionCol->GetBinding(myXmlQualifiedName);
   OperationBinding* myOperationBinding= 0;
   for(int i=0; i< myBinding->Operations->Count; i++) 
   {
      if(myBinding->Operations->Item[i]->Name->Equals(S"AddNumbers"))
      {
         myOperationBinding = myBinding->Operations->Item[i];
      }
   }
   // Create the OutputBinding.
   OutputBinding* myOutputBinding = myOperationBinding->Output;
   MimeXmlBinding* myMimeXmlBinding = new MimeXmlBinding();
   myMimeXmlBinding->Part = S"body";

   // Create the MimePart.
   MimePart* myMimePart = new MimePart();
   myMimePart->Extensions->Add(myMimeXmlBinding);
   MimeMultipartRelatedBinding* myMimePartRelatedBinding =
      new MimeMultipartRelatedBinding();

   // Add the MimePart to the MimePartRelatedBinding.
   myMimePartRelatedBinding->Parts->Add(myMimePart);
   myOutputBinding->Extensions->Add(myMimePartRelatedBinding);
   myServiceDescription->Write(S"MimePart_3_Output_CS.wsdl");
   Console::WriteLine(
      S"MimePart_3_Output_CS.wsdl has been generated successfully."); 
}

[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

MimePart Members | System.Web.Services.Description Namespace

Show: