ServiceDescription.PortTypes Property
.NET Framework 3.0
Gets the collection of PortType elements contained in the ServiceDescription.
Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)
Assembly: System.Web.Services (in system.web.services.dll)
// 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." ); } }
public static void main(String[] args)
{
String myWsdlFileName = "MyWsdl_JSL.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.get_PortTypes();
myPortTypeCollection.Remove(myDescription.get_PortTypes().
get_Item(0));
// Build a new PortType.
PortType myPortType = new PortType();
myPortType.set_Name("Service1Soap");
Operation myOperation =
CreateOperation("Add", "s0:AddSoapIn", "s0:AddSoapOut", "");
myPortType.get_Operations().Add(myOperation);
// Add a new PortType to the PortType collection of
// the ServiceDescription.
myDescription.get_PortTypes().Add(myPortType);
myDescription.Write("MyOutWsdl.wsdl");
Console.WriteLine("New WSDL file generated successfully.");
}
else {
Console.WriteLine("This file is not a WSDL file.");
}
} //main
// Creates an Operation for a PortType.
public static Operation CreateOperation(String operationName,
String inputMessage, String outputMessage, String targetNamespace)
{
Operation myOperation = new Operation();
myOperation.set_Name(operationName);
OperationMessage input = (OperationMessage)new OperationInput();
input.set_Message(new XmlQualifiedName(inputMessage, targetNamespace));
OperationMessage output = (OperationMessage)new OperationOutput();
output.set_Message(new XmlQualifiedName(outputMessage, targetNamespace));
myOperation.get_Messages().Add(input);
myOperation.get_Messages().Add(output);
return myOperation;
} //CreateOperation
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: