This documentation is archived and is not being maintained.
ServiceDescription::CanRead Method
Visual Studio 2010
Gets a value that indicates whether an XmlReader represents a valid Web Services Description Language (WSDL) file that can be parsed.
Assembly: System.Web.Services (in System.Web.Services.dll)
Parameters
- reader
- Type: System.Xml::XmlReader
An XmlReader
Return Value
Type: System::Booleantrue if the XmlSerializer can recognize the node on which the XmlReader is positioned; otherwise false.
// 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: