次の方法で共有


ServiceCollection.Add メソッド

指定した ServiceServiceCollection の末尾に追加します。

Public Function Add( _
   ByVal service As Service _) As Integer
[C#]
public int Add(Serviceservice);
[C++]
public: int Add(Service* service);
[JScript]
public function Add(
   service : Service) : int;

パラメータ

  • service
    コレクションに追加する Service インスタンス。

戻り値

service パラメータが追加された、0 から始まるインデックス番号。

使用例

 
' 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 = _
   "https://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 = _
   "https://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)

[C#] 
// 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 = 
   "https://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 = 
   "https://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);

[C++] 
// Build a new Service.
Service* myService = new Service();
myService->Name = S"MathService";
XmlQualifiedName* myXmlQualifiedName = 
   new XmlQualifiedName(S"s0:MathServiceSoap");

// Build a new Port for SOAP.
Port* mySoapPort= new Port();

mySoapPort->Name = S"MathServiceSoap";

mySoapPort->Binding = myXmlQualifiedName;

SoapAddressBinding* mySoapAddressBinding = new SoapAddressBinding();
mySoapAddressBinding->Location = 
   S"https://localhost/ServiceCollection_Item/AddSub_CS.asmx";
mySoapPort->Extensions->Add(mySoapAddressBinding);

// Build a new Port for HTTP-GET.
XmlQualifiedName* myXmlQualifiedName2 = 
   new XmlQualifiedName(S"s0:MathServiceHttpGet");

Port* myHttpGetPort= new Port();
myHttpGetPort->Name=S"MathServiceHttpGet";
myHttpGetPort->Binding=myXmlQualifiedName2;
HttpAddressBinding* myHttpAddressBinding = new HttpAddressBinding();
myHttpAddressBinding->Location = 
   S"https://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);

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

ServiceCollection クラス | ServiceCollection メンバ | System.Web.Services.Description 名前空間