This documentation is archived and is not being maintained.
Service Class
Visual Studio 2010
Groups together a set of related instances of the Port class that are associated with an XML Web service. This class cannot be inherited.
System::Object
System.Web.Services.Description::DocumentableItem
System.Web.Services.Description::NamedItem
System.Web.Services.Description::Service
System.Web.Services.Description::DocumentableItem
System.Web.Services.Description::NamedItem
System.Web.Services.Description::Service
Assembly: System.Web.Services (in System.Web.Services.dll)
The Service type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Documentation | Gets or sets the text documentation for the instance of the DocumentableItem. (Inherited from DocumentableItem.) |
![]() | DocumentationElement | Gets or sets the documentation element for the DocumentableItem. (Inherited from DocumentableItem.) |
![]() | ExtensibleAttributes | Gets or sets an array of type XmlAttribute that represents attribute extensions of WSDL to comply with Web Services Interoperability (WS-I) Basic Profile 1.1. (Inherited from DocumentableItem.) |
![]() | Extensions | Gets the collection of extensibility elements associated with the Service. (Overrides DocumentableItem::Extensions.) |
![]() | Name | Gets or sets the name of the item. (Inherited from NamedItem.) |
![]() | Namespaces | Gets or sets the dictionary of namespace prefixes and namespaces used to preserve namespace prefixes and namespaces when a ServiceDescription object is constructed. (Inherited from DocumentableItem.) |
![]() | Ports | Gets the collection of Port instances contained in the Service. |
![]() | ServiceDescription | Gets the ServiceDescription of which the Service is a member. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
#using <System.Xml.dll> #using <System.Web.Services.dll> #using <System.dll> using namespace System; using namespace System::Web::Services::Description; using namespace System::Xml; Port^ CreatePort( String^ PortName, String^ BindingName, String^ targetNamespace ) { Port^ myPort = gcnew Port; myPort->Name = PortName; myPort->Binding = gcnew XmlQualifiedName( BindingName,targetNamespace ); // Create a SoapAddress extensibility element to add to the port. SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding; mySoapAddressBinding->Location = "http://localhost/ServiceClass/MathService_CS.asmx"; myPort->Extensions->Add( mySoapAddressBinding ); return myPort; } int main() { try { // Read a WSDL document. ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_CS.wsdl" ); ServiceCollection^ myServiceCollection = myServiceDescription->Services; int noOfServices = myServiceCollection->Count; Console::WriteLine( "\nTotal number of services: {0}", noOfServices ); // Gets a reference to the service. Service^ myOldService = myServiceCollection[ 0 ]; Console::WriteLine( "No. of ports in the service: {0}", myServiceCollection[ 0 ]->Ports->Count ); Console::WriteLine( "These are the ports in the service:" ); for ( int i = 0; i < myOldService->Ports->Count; i++ ) Console::WriteLine( "Port name: {0}", myOldService->Ports[ i ]->Name ); Console::WriteLine( "Service name: {0}", myOldService->Name ); Service^ myService = gcnew Service; myService->Name = "MathService"; // Add the Ports to the newly created Service. for ( int i = 0; i < myOldService->Ports->Count; i++ ) { String^ PortName = myServiceCollection[ 0 ]->Ports[ i ]->Name; String^ BindingName = myServiceCollection[ 0 ]->Ports[ i ]->Binding->Name; myService->Ports->Add( CreatePort( PortName, BindingName, myServiceDescription->TargetNamespace ) ); } Console::WriteLine( "Newly created ports -" ); for ( int i = 0; i < myService->Ports->Count; i++ ) Console::WriteLine( "Port name: {0}", myOldService->Ports[ i ]->Name ); // Add the extensions to the newly created Service. int noOfExtensions = myOldService->Extensions->Count; Console::WriteLine( "No. of extensions: {0}", noOfExtensions ); if ( noOfExtensions > 0 ) { for ( int i = 0; i < myOldService->Ports->Count; i++ ) myService->Extensions->Add( myServiceCollection[ 0 ]->Extensions[ i ] ); } // Remove the service from the collection. myServiceCollection->Remove( myOldService ); // Add the newly created service. myServiceCollection->Add( myService ); myServiceDescription->Write( "MathService_New.wsdl" ); } catch ( Exception^ e ) { Console::WriteLine( "Exception: {0}", e->Message ); } }
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:


