ServiceDescription.PortTypes Propiedad
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Obtiene la colección de los elementos PortType incluidos en ServiceDescription.
public:
property System::Web::Services::Description::PortTypeCollection ^ PortTypes { System::Web::Services::Description::PortTypeCollection ^ get(); };
public System.Web.Services.Description.PortTypeCollection PortTypes { get; }
member this.PortTypes : System.Web.Services.Description.PortTypeCollection
Public ReadOnly Property PortTypes As PortTypeCollection
Valor de propiedad
Colección de elementos PortType incluidos en el objeto ServiceDescription.
Ejemplos
// 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." );
}
}
static void Main()
{
string myWsdlFileName ="MyWsdl_CS.wsdl";
XmlTextReader myReader = new 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 = new 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.");
}
}
// Creates an Operation for a PortType.
public static Operation CreateOperation(string operationName,
string inputMessage, string outputMessage, string targetNamespace)
{
Operation myOperation = new Operation();
myOperation.Name = operationName;
OperationMessage input = (OperationMessage) new OperationInput();
input.Message = new XmlQualifiedName(inputMessage,targetNamespace);
OperationMessage output = (OperationMessage) new OperationOutput();
output.Message = new XmlQualifiedName(outputMessage,targetNamespace);
myOperation.Messages.Add(input);
myOperation.Messages.Add(output);
return myOperation;
}
Shared Sub Main()
Dim myWsdlFileName As String = "MyWsdl_VB.wsdl"
Dim myReader As New XmlTextReader(myWsdlFileName)
If ServiceDescription.CanRead(myReader) Then
Dim myDescription As ServiceDescription = _
ServiceDescription.Read(myWsdlFileName)
' Remove the PortType at index 0 of the collection.
Dim myPortTypeCollection As PortTypeCollection = _
myDescription.PortTypes
myPortTypeCollection.Remove(myDescription.PortTypes(0))
' Build a new PortType.
Dim myPortType As New PortType()
myPortType.Name = "Service1Soap"
Dim myOperation As Operation = _
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.")
End If
End Sub
' Creates an Operation for a PortType.
Public Shared Function CreateOperation(operationName As String, _
inputMessage As String, outputMessage As String, _
targetNamespace As String) As Operation
Dim myOperation As New Operation()
myOperation.Name = operationName
Dim input As OperationMessage = _
CType(New OperationInput(), OperationMessage)
input.Message = New XmlQualifiedName(inputMessage, targetNamespace)
Dim output As OperationMessage = _
CType(New OperationOutput(), OperationMessage)
output.Message = New XmlQualifiedName(outputMessage, targetNamespace)
myOperation.Messages.Add(input)
myOperation.Messages.Add(output)
Return myOperation
End Function 'CreateOperation
Comentarios
El PortTypeCollection devuelto por esta propiedad corresponde a la lista de portType
elementos incluidos en el elemento raíz lenguaje de descripción de servicios web (WSDL). definitions
Para obtener más información sobre WSDL, consulte la especificación WSDL.