ServiceDescriptionBaseCollection Class
.NET Framework 2.0
Forms the basis for the strongly typed collections that are members of the System.Web.Services.Description namespace.
Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)
Assembly: System.Web.Services (in system.web.services.dll)
static void MyMethod( ServiceDescriptionBaseCollection^ myServiceCollection ) { Type^ myType = myServiceCollection->GetType(); if ( myType->Equals( System::Web::Services::Description::ServiceCollection::typeid ) ) { // Remove the services at index 0 of the collection. (dynamic_cast<ServiceCollection^>(myServiceCollection))->Remove( myServiceDescription->Services[ 0 ] ); // Build a new Service. Service^ myService = gcnew Service; myService->Name = "MathService"; XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MathServiceSoap" ); // Build a new Port for SOAP. Port^ mySoapPort = gcnew Port; mySoapPort->Name = "MathServiceSoap"; mySoapPort->Binding = myXmlQualifiedName; SoapAddressBinding^ mySoapAddressBinding = gcnew SoapAddressBinding; mySoapAddressBinding->Location = "http://localhost/" "ServiceDescriptionBaseCollection/AddSubtractService.CS.asmx"; mySoapPort->Extensions->Add( mySoapAddressBinding ); // Build a new Port for HTTP-GET. XmlQualifiedName^ myXmlQualifiedName2 = gcnew XmlQualifiedName( "s0:MathServiceHttpGet" ); Port^ myHttpGetPort = gcnew Port; myHttpGetPort->Name = "MathServiceHttpGet"; myHttpGetPort->Binding = myXmlQualifiedName2; HttpAddressBinding^ myHttpAddressBinding = gcnew HttpAddressBinding; myHttpAddressBinding->Location = "http://localhost/" "ServiceDescriptionBaseCollection/AddSubtractService.CS.asmx"; myHttpGetPort->Extensions->Add( myHttpAddressBinding ); // Add the ports to the Service. myService->Ports->Add( myHttpGetPort ); myService->Ports->Add( mySoapPort ); // Add the Service to the ServiceCollection. myServiceDescription->Services->Add( myService ); } else if ( myType->Equals( System::Web::Services::Description::BindingCollection::typeid ) ) { // Remove the Binding in the BindingCollection at index 0. (dynamic_cast<BindingCollection^>(myServiceCollection))->Remove( myServiceDescription->Bindings[ 0 ] ); // Build a new Binding. Binding^ myBinding = gcnew Binding; myBinding->Name = "MathServiceSoap"; XmlQualifiedName^ myXmlQualifiedName = gcnew XmlQualifiedName( "s0:MathServiceSoap" ); myBinding->Type = myXmlQualifiedName; SoapBinding^ mySoapBinding = gcnew SoapBinding; mySoapBinding->Transport = "http://schemas.xmlsoap.org/soap/http"; mySoapBinding->Style = SoapBindingStyle::Document; // Create the operations for the binding. OperationBinding^ addOperationBinding = CreateOperationBinding( "Add", myServiceDescription->TargetNamespace ); OperationBinding^ subtractOperationBinding = CreateOperationBinding( "Subtract", myServiceDescription->TargetNamespace ); // Add the operations to the Binding. myBinding->Operations->Add( subtractOperationBinding ); myBinding->Operations->Add( addOperationBinding ); myBinding->Extensions->Add( mySoapBinding ); // Add the Binding to the Bindings collection. myServiceDescription->Bindings->Add( myBinding ); } else if ( myType->Equals( System::Web::Services::Description::PortTypeCollection::typeid ) ) { // Remove the PortType at index 0. (dynamic_cast<PortTypeCollection^>(myServiceCollection))->Remove( myServiceDescription->PortTypes[ 0 ] ); // Build a new PortType. PortType^ myPortType = gcnew PortType; myPortType->Name = "MathServiceSoap"; // Build an Add Operation for the PortType. Operation^ myAddOperation = gcnew Operation; myAddOperation->Name = "Add"; // Build the Input and Output messages for the Operations. OperationInput^ myOperationInputMessage1 = gcnew OperationInput; XmlQualifiedName^ myXmlQualifiedName1 = gcnew XmlQualifiedName( "s0:AddSoapIn" ); myOperationInputMessage1->Message = myXmlQualifiedName1; OperationOutput^ myOperationOutputMessage1 = gcnew OperationOutput; XmlQualifiedName^ myXmlQualifiedName2 = gcnew XmlQualifiedName( "s0:AddSoapOut" ); myOperationOutputMessage1->Message = myXmlQualifiedName2; // Add the messages to the operations. myAddOperation->Messages->Add( myOperationInputMessage1 ); myAddOperation->Messages->Add( myOperationOutputMessage1 ); // Build an Add Operation for the PortType. Operation^ mySubtractOperation = gcnew Operation; mySubtractOperation->Name = "Subtract"; // Build the Input and Output messages for the operations. OperationInput^ myOperationInputMessage2 = gcnew OperationInput; XmlQualifiedName^ myXmlQualifiedName3 = gcnew XmlQualifiedName( "s0:SubtractSoapIn" ); myOperationInputMessage2->Message = myXmlQualifiedName3; OperationOutput^ myOperationOutputMessage2 = gcnew OperationOutput; XmlQualifiedName^ myXmlQualifiedName4 = gcnew XmlQualifiedName( "s0:SubtractSoapOut" ); myOperationOutputMessage2->Message = myXmlQualifiedName4; // Add the messages to the operations. mySubtractOperation->Messages->Add( myOperationInputMessage2 ); mySubtractOperation->Messages->Add( myOperationOutputMessage2 ); // Add the operations to the PortType. myPortType->Operations->Add( myAddOperation ); myPortType->Operations->Add( mySubtractOperation ); // Add the PortType to the collection. myServiceDescription->PortTypes->Add( myPortType ); } }
public static void MyMethod(ServiceDescriptionBaseCollection
myServiceCollection)
{
Type myType = myServiceCollection.GetType();
if (myType.Equals(System.Web.Services.Description.ServiceCollection.
class.ToType())) {
// Remove the services at index 0 of the collection.
((ServiceCollection)(myServiceCollection)).
Remove(myServiceDescription.get_Services().get_Item(0));
// Build a new Service.
Service myService = new Service();
myService.set_Name("MathService");
XmlQualifiedName myXmlQualifiedName = new
XmlQualifiedName("s0:MathServiceSoap");
// Build a new Port for SOAP.
Port mySoapPort = new Port();
mySoapPort.set_Name("MathServiceSoap");
mySoapPort.set_Binding(myXmlQualifiedName);
SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding();
mySoapAddressBinding.set_Location("http://localhost/"
+ "ServiceDescriptionBaseCollection/"
+ "AddSubtractService.JSL.asmx");
mySoapPort.get_Extensions().Add(mySoapAddressBinding);
// Build a new Port for HTTP-GET.
XmlQualifiedName myXmlQualifiedName2 = new
XmlQualifiedName("s0:MathServiceHttpGet");
Port myHttpGetPort = new Port();
myHttpGetPort.set_Name("MathServiceHttpGet");
myHttpGetPort.set_Binding(myXmlQualifiedName2);
HttpAddressBinding myHttpAddressBinding = new HttpAddressBinding();
myHttpAddressBinding.set_Location("http://localhost/"
+ "ServiceDescriptionBaseCollection/"
+ "AddSubtractService.JSL.asmx");
myHttpGetPort.get_Extensions().Add(myHttpAddressBinding);
// Add the ports to the Service.
myService.get_Ports().Add(myHttpGetPort);
myService.get_Ports().Add(mySoapPort);
// Add the Service to the ServiceCollection.
myServiceDescription.get_Services().Add(myService);
}
else {
if (myType.Equals(System.Web.Services.Description.
BindingCollection.class.ToType())) {
// Remove the Binding in the BindingCollection at index 0.
((BindingCollection)(myServiceCollection)).
Remove(myServiceDescription.get_Bindings().get_Item(0));
// Build a new Binding.
Binding myBinding = new Binding();
myBinding.set_Name("MathServiceSoap");
XmlQualifiedName myXmlQualifiedName = new
XmlQualifiedName("s0:MathServiceSoap");
myBinding.set_Type(myXmlQualifiedName);
SoapBinding mySoapBinding = new SoapBinding();
mySoapBinding.set_Transport("http://"
+ "schemas.xmlsoap.org/soap/http");
mySoapBinding.set_Style(SoapBindingStyle.Document);
// Create the operations for the binding.
OperationBinding addOperationBinding = CreateOperationBinding(
"Add", myServiceDescription.get_TargetNamespace());
OperationBinding subtractOperationBinding =
CreateOperationBinding("Subtract",
myServiceDescription.get_TargetNamespace());
// Add the operations to the Binding.
myBinding.get_Operations().Add(subtractOperationBinding);
myBinding.get_Operations().Add(addOperationBinding);
myBinding.get_Extensions().Add(mySoapBinding);
// Add the Binding to the Bindings collection.
myServiceDescription.get_Bindings().Add(myBinding);
}
else {
if (myType.Equals(System.Web.Services.Description.
PortTypeCollection.class.ToType())) {
// Remove the PortType at index 0.
((PortTypeCollection)(myServiceCollection)).
Remove(myServiceDescription.get_PortTypes().get_Item(0));
// Build a new PortType.
PortType myPortType = new PortType();
myPortType.set_Name("MathServiceSoap");
// Build an Add Operation for the PortType.
Operation myAddOperation = new Operation();
myAddOperation.set_Name("Add");
// Build the Input and Output messages for the Operations.
OperationInput myOperationInputMessage1 = new
OperationInput();
XmlQualifiedName myXmlQualifiedName1 = new
XmlQualifiedName("s0:AddSoapIn");
myOperationInputMessage1.set_Message(myXmlQualifiedName1);
OperationOutput myOperationOutputMessage1 = new
OperationOutput();
XmlQualifiedName myXmlQualifiedName2 = new
XmlQualifiedName("s0:AddSoapOut");
myOperationOutputMessage1.set_Message(myXmlQualifiedName2);
// Add the messages to the operations.
myAddOperation.get_Messages().Add(myOperationInputMessage1);
myAddOperation.get_Messages().Add(myOperationOutputMessage1);
// Build an Add Operation for the PortType.
Operation mySubtractOperation = new Operation();
mySubtractOperation.set_Name("Subtract");
// Build the Input and Output messages for the operations.
OperationInput myOperationInputMessage2 =
new OperationInput();
XmlQualifiedName myXmlQualifiedName3 = new
XmlQualifiedName("s0:SubtractSoapIn");
myOperationInputMessage2.set_Message(myXmlQualifiedName3);
OperationOutput myOperationOutputMessage2 =
new OperationOutput();
XmlQualifiedName myXmlQualifiedName4 = new
XmlQualifiedName("s0:SubtractSoapOut");
myOperationOutputMessage2.set_Message(myXmlQualifiedName4);
// Add the messages to the operations.
mySubtractOperation.get_Messages().
Add(myOperationInputMessage2);
mySubtractOperation.get_Messages().
Add(myOperationOutputMessage2);
// Add the operations to the PortType.
myPortType.get_Operations().Add(myAddOperation);
myPortType.get_Operations().Add(mySubtractOperation);
// Add the PortType to the collection.
myServiceDescription.get_PortTypes().Add(myPortType);
}
}
}
} //MyMethod
System.Object
System.Collections.CollectionBase
System.Web.Services.Description.ServiceDescriptionBaseCollection
Derived Classes
System.Collections.CollectionBase
System.Web.Services.Description.ServiceDescriptionBaseCollection
Derived Classes
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: