MimePartCollection Class
.NET Framework 2.0
Represents a collection of instances of the MimePart class. This class cannot be inherited.
Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)
Assembly: System.Web.Services (in system.web.services.dll)
Each MimePart within the collection represents an extensibility element added to a MimeMultipartRelatedBinding, and specifies the MIME type for a corresponding MessagePart.
For more information about specifying protocols for XML Web services, see 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/.
The following example demonstrates the use of the properties and methods exposed by the MimePartCollection class.
#using <System.dll> #using <System.Xml.dll> #using <System.Web.Services.dll> using namespace System; using namespace System::Collections; using namespace System::Xml; using namespace System::Web::Services::Description; int main() { ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MimePartCollection_1_Input_cpp.wsdl" ); ServiceDescriptionCollection^ myServiceDescriptionCol = gcnew ServiceDescriptionCollection; myServiceDescriptionCol->Add( myServiceDescription ); XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "MimeServiceHttpPost","http://tempuri.org/" ); // Create a 'Binding' object. Binding^ myBinding = myServiceDescriptionCol->GetBinding( myXmlQualifiedName ); OperationBinding^ myOperationBinding = nullptr; for ( int i = 0; i < myBinding->Operations->Count; i++ ) if ( myBinding->Operations[ i ]->Name->Equals( "AddNumbers" ) ) myOperationBinding = myBinding->Operations[ i ]; OutputBinding^ myOutputBinding = myOperationBinding->Output; MimeMultipartRelatedBinding^ myMimeMultipartRelatedBinding = nullptr; IEnumerator^ myIEnumerator = myOutputBinding->Extensions->GetEnumerator(); while ( myIEnumerator->MoveNext() ) myMimeMultipartRelatedBinding = dynamic_cast<MimeMultipartRelatedBinding^>(myIEnumerator->Current); // Create an instances of 'MimePartCollection'. MimePartCollection^ myMimePartCollection = gcnew MimePartCollection; myMimePartCollection = myMimeMultipartRelatedBinding->Parts; Console::WriteLine( "Total number of mimepart elements initially is: {0}", myMimePartCollection->Count ); // Create an instance of 'MimePart'. MimePart^ myMimePart = gcnew MimePart; // Create an instance of 'MimeXmlBinding'. MimeXmlBinding^ myMimeXmlBinding = gcnew MimeXmlBinding; myMimeXmlBinding->Part = "body"; myMimePart->Extensions->Add( myMimeXmlBinding ); // Insert a mimepart at first position. myMimePartCollection->Insert( 0, myMimePart ); Console::WriteLine( "Inserting a mimepart object..." ); if ( myMimePartCollection->Contains( myMimePart ) ) { Console::WriteLine( "'MimePart' is succesffully added at position: {0}", myMimePartCollection->IndexOf( myMimePart ) ); Console::WriteLine( "Total number of mimepart elements after inserting is: {0}", myMimePartCollection->Count ); } myServiceDescription->Write( "MimePartCollection_1_Output_cpp.wsdl" ); Console::WriteLine( "MimePartCollection_1_Output_cpp.wsdl has been generated successfully." ); }
import System.*;
import System.Collections.*;
import System.Xml.*;
import System.Web.Services.Description.*;
public class MyMimePartCollection
{
public static void main(String[] args)
{
ServiceDescription myServiceDescription =
ServiceDescription.Read("MimePartCollection_1_Input_jsl.wsdl");
ServiceDescriptionCollection myServiceDescriptionCol =
new ServiceDescriptionCollection();
myServiceDescriptionCol.Add(myServiceDescription);
XmlQualifiedName myXmlQualifiedName =
new XmlQualifiedName("MimeServiceHttpPost", "http://tempuri.org/");
// Create a 'Binding' object.
Binding myBinding = myServiceDescriptionCol.
GetBinding(myXmlQualifiedName);
OperationBinding myOperationBinding = null;
for (int i = 0; i < myBinding.get_Operations().get_Count(); i++) {
if (myBinding.get_Operations().get_Item(i).get_Name().
Equals("AddNumbers")) {
myOperationBinding = myBinding.get_Operations().get_Item(i);
}
}
OutputBinding myOutputBinding = myOperationBinding.get_Output();
MimeMultipartRelatedBinding myMimeMultipartRelatedBinding = null;
IEnumerator myIEnumerator =
myOutputBinding.get_Extensions().GetEnumerator();
while (myIEnumerator.MoveNext()) {
myMimeMultipartRelatedBinding =
(MimeMultipartRelatedBinding)myIEnumerator.get_Current();
}
// Create an instances of 'MimePartCollection'.
MimePartCollection myMimePartCollection = new MimePartCollection();
myMimePartCollection = myMimeMultipartRelatedBinding.get_Parts();
Console.WriteLine("Total number of mimepart elements initially is: "
+ myMimePartCollection.get_Count());
// Create an instance of 'MimePart'.
MimePart myMimePart = new MimePart();
// Create an instance of 'MimeXmlBinding'.
MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding();
myMimeXmlBinding.set_Part("body");
myMimePart.get_Extensions().Add(myMimeXmlBinding);
// Insert a mimepart at first position.
myMimePartCollection.Insert(0, myMimePart);
Console.WriteLine("Inserting a mimepart object...");
if (myMimePartCollection.Contains(myMimePart)) {
Console.WriteLine("'MimePart' is succesffully added at position: "
+ myMimePartCollection.IndexOf(myMimePart));
Console.WriteLine("Total number of mimepart elements "
+ "after inserting is: " + myMimePartCollection.get_Count());
}
myServiceDescription.Write("MimePartCollection_1_Output_JSL.wsdl");
Console.WriteLine("MimePartCollection_1_Output_JSL.wsdl has been "
+ "generated successfully.");
} //main
} //MyMimePartCollection
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: