ServiceCollection.Add(Service) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Fügt am Ende der Service die angegebene ServiceCollection hinzu.
public:
int Add(System::Web::Services::Description::Service ^ service);
public int Add (System.Web.Services.Description.Service service);
member this.Add : System.Web.Services.Description.Service -> int
Public Function Add (service As Service) As Integer
Parameter
Gibt zurück
Der nullbasierte Index, an dem der service
-Parameter hinzugefügt wurde.
Beispiele
// 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/ServiceCollection_Item/AddSub_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/ServiceCollection_Item/AddSub_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.
myServiceCollection->Add( myService );
// Build a new Service.
Service myService = new Service();
myService.Name = "MathService";
XmlQualifiedName myXmlQualifiedName =
new XmlQualifiedName("s0:MathServiceSoap");
// Build a new Port for SOAP.
Port mySoapPort= new Port();
mySoapPort.Name = "MathServiceSoap";
mySoapPort.Binding = myXmlQualifiedName;
SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding();
mySoapAddressBinding.Location =
"http://localhost/ServiceCollection_Item/AddSub_CS.asmx";
mySoapPort.Extensions.Add(mySoapAddressBinding);
// Build a new Port for HTTP-GET.
XmlQualifiedName myXmlQualifiedName2 =
new XmlQualifiedName("s0:MathServiceHttpGet");
Port myHttpGetPort= new Port();
myHttpGetPort.Name="MathServiceHttpGet";
myHttpGetPort.Binding=myXmlQualifiedName2;
HttpAddressBinding myHttpAddressBinding = new HttpAddressBinding();
myHttpAddressBinding.Location =
"http://localhost/ServiceCollection_Item/AddSub_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.
myServiceCollection .Add(myService);
' Build a new Service.
Dim myService As New Service()
myService.Name = "MathService"
Dim myXmlQualifiedName As New XmlQualifiedName("s0:MathServiceSoap")
' Build a new Port for SOAP.
Dim mySoapPort As New Port()
mySoapPort.Name = "MathServiceSoap"
mySoapPort.Binding = myXmlQualifiedName
Dim mySoapAddressBinding As New SoapAddressBinding()
mySoapAddressBinding.Location = _
"http://localhost/ServiceCollection_Item/AddSub.vb.asmx"
mySoapPort.Extensions.Add(mySoapAddressBinding)
' Build a new Port for HTTP-GET.
Dim myXmlQualifiedName2 As _
New XmlQualifiedName("s0:MathServiceHttpGet")
Dim myHttpGetPort As New Port()
myHttpGetPort.Name = "MathServiceHttpGet"
myHttpGetPort.Binding = myXmlQualifiedName2
Dim myHttpAddressBinding As New HttpAddressBinding()
myHttpAddressBinding.Location = _
"http://localhost/ServiceCollection_Item/AddSub.vb.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.
myServiceCollection.Add(myService)