This documentation is archived and is not being maintained.
ServiceDescription::PortTypes Property
Visual Studio 2010
Gets the collection of PortType elements contained in the ServiceDescription.
Assembly: System.Web.Services (in System.Web.Services.dll)
The PortTypeCollection returned by this property corresponds to the list of portType elements enclosed by the Web Services Description Language (WSDL) definitions root element. For more information about WSDL, see the specification at http://www.w3.org/TR/wsdl/.
// Creates an Operation for a PortType. Operation^ CreateOperation( String^ operationName, String^ inputMessage, String^ outputMessage, String^ targetNamespace ) { Operation^ myOperation = gcnew Operation; myOperation->Name = operationName; OperationMessage^ input = dynamic_cast<OperationMessage^>(gcnew OperationInput); input->Message = gcnew XmlQualifiedName( inputMessage,targetNamespace ); OperationMessage^ output = dynamic_cast<OperationMessage^>(gcnew OperationOutput); output->Message = gcnew XmlQualifiedName( outputMessage,targetNamespace ); myOperation->Messages->Add( input ); myOperation->Messages->Add( output ); return myOperation; } int main() { String^ myWsdlFileName = "MyWsdl_CS.wsdl"; XmlTextReader^ myReader = gcnew XmlTextReader( myWsdlFileName ); if ( ServiceDescription::CanRead( myReader ) ) { ServiceDescription^ myDescription = ServiceDescription::Read( myWsdlFileName ); // Remove the PortType at index 0 of the collection. PortTypeCollection^ myPortTypeCollection = myDescription->PortTypes; myPortTypeCollection->Remove( myDescription->PortTypes[ 0 ] ); // Build a new PortType. PortType^ myPortType = gcnew PortType; myPortType->Name = "Service1Soap"; Operation^ myOperation = CreateOperation( "Add", "s0:AddSoapIn", "s0:AddSoapOut", "" ); myPortType->Operations->Add( myOperation ); // Add a new PortType to the PortType collection of // the ServiceDescription. myDescription->PortTypes->Add( myPortType ); myDescription->Write( "MyOutWsdl.wsdl" ); Console::WriteLine( "New WSDL file generated successfully." ); } else { Console::WriteLine( "This file is not a WSDL file." ); } }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: