次の方法で共有


SoapHeaderCollection クラス

SoapHeader クラスのインスタンスのコレクションを格納します。

この型のすべてのメンバの一覧については、SoapHeaderCollection メンバ を参照してください。

System.Object
   System.Collections.CollectionBase
      System.Web.Services.Protocols.SoapHeaderCollection

Public Class SoapHeaderCollection
   Inherits CollectionBase
[C#]
public class SoapHeaderCollection : CollectionBase
[C++]
public __gc class SoapHeaderCollection : public CollectionBase
[JScript]
public class SoapHeaderCollection extends CollectionBase

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

使用例

 
<System.Web.Services.WebServiceBindingAttribute(Name := "MathSvcSoap", _
    Namespace := "http://tempuri.org/")>  _
Public Class MathSvc
   Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
   Public mySoapHeaders() As SoapHeader

   <SoapHeaderAttribute("mySoapHeaders", _
      Direction := SoapHeaderDirection.In), _
   System.Web.Services.Protocols.SoapDocumentMethodAttribute( _
      "http://tempuri.org/Add", _
      Use := System.Web.Services.Description.SoapBindingUse.Literal, _
      ParameterStyle := System.Web.Services.Protocols.SoapParameterStyle.Wrapped), _
   MySoapExtensionAttribute()>  _
   Public Function Add(xValue As System.Single, yValue As System.Single) _
      As System.Single
      Dim mySoapHeaderCollection As New SoapHeaderCollection()
      Dim mySoapHeader As MySoapHeader
      mySoapHeader = New MySoapHeader()
      mySoapHeader.text = "This is the first SOAP header"
      mySoapHeaderCollection.Add(mySoapHeader)
      mySoapHeader = New MySoapHeader()
      mySoapHeader.text = "This is the second SOAP header"
      mySoapHeaderCollection.Add(mySoapHeader)
      mySoapHeader = New MySoapHeader()
      mySoapHeader.text = "This header is inserted before the first header"
      mySoapHeaderCollection.Insert(0, mySoapHeader)
      mySoapHeaders = New MySoapHeader(mySoapHeaderCollection.Count-1) {}
      mySoapHeaderCollection.CopyTo(mySoapHeaders, 0)
      Dim results() As Object = _
         Me.Invoke("Add", New Object() {xValue, yValue})
      Return CType(results(0), System.Single)
   End Function 'Add

   <System.Diagnostics.DebuggerStepThroughAttribute()>  _
   Public Sub New()
      Me.Url = "https://localhost/MathSvc_SoapHeaderCollection.vb.asmx"
   End Sub 'New

   Public Function BeginAdd(xValue As System.Single, yValue As System.Single, _
      callback As System.AsyncCallback, asyncState As Object) _
      As System.IAsyncResult
      Return Me.BeginInvoke("Add", New Object() {xValue, yValue}, _
         callback, asyncState)
   End Function 'BeginAdd

   Public Function EndAdd(asyncResult As System.IAsyncResult) As System.Single
      Dim results As Object() = Me.EndInvoke(asyncResult)
      Return CType(results(0), System.Single)
   End Function 'EndAdd
End Class 'MathSvc

[C#] 
[System.Web.Services.WebServiceBindingAttribute(Name="MathSvcSoap",
   Namespace="http://tempuri.org/")]
public class MathSvc : System.Web.Services.Protocols.SoapHttpClientProtocol 
{ 
   public SoapHeader[] mySoapHeaders;
   
   [SoapHeaderAttribute("mySoapHeaders", 
      Direction=SoapHeaderDirection.In)]
   [System.Web.Services.Protocols.SoapDocumentMethodAttribute(
      "http://tempuri.org/Add", 
      Use=System.Web.Services.Description.SoapBindingUse.Literal, 
      ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
   [MySoapExtensionAttribute()]
   public System.Single Add(System.Single xValue, System.Single yValue) 
   {
      SoapHeaderCollection mySoapHeaderCollection = new SoapHeaderCollection();
      MySoapHeader mySoapHeader;
      mySoapHeader = new MySoapHeader();
      mySoapHeader.text = "This is the first SOAP header";
      mySoapHeaderCollection.Add(mySoapHeader);
      mySoapHeader = new MySoapHeader();
      mySoapHeader.text = "This is the second SOAP header";
      mySoapHeaderCollection.Add(mySoapHeader);
      mySoapHeader = new MySoapHeader();
      mySoapHeader.text = "This header is inserted before the first header";
      mySoapHeaderCollection.Insert(0, mySoapHeader);
      mySoapHeaders = new MySoapHeader[mySoapHeaderCollection.Count];
      mySoapHeaderCollection.CopyTo(mySoapHeaders, 0);
      object[] results = this.Invoke("Add", 
         new object[] {xValue, yValue});
      return ((System.Single)(results[0]));
   }

   [System.Diagnostics.DebuggerStepThroughAttribute()]
   public MathSvc() 
   {
      this.Url = "https://localhost/MathSvc_SoapHeaderCollection.cs.asmx";
   }

   public System.IAsyncResult BeginAdd(System.Single xValue,
      System.Single yValue, System.AsyncCallback callback, object asyncState) 
   {
      return this.BeginInvoke("Add", new object[] {xValue, yValue}, 
         callback, asyncState);
   }

   public System.Single EndAdd(System.IAsyncResult asyncResult) 
   {
      object[] results = this.EndInvoke(asyncResult);
      return ((System.Single)(results[0]));
   }
}

[C++] 
[System::Web::Services::WebServiceBindingAttribute(Name=S"MathSvcSoap",
   Namespace=S"http://tempuri.org/")]
public __gc class MathSvc : public System::Web::Services::Protocols::SoapHttpClientProtocol
{
public:
   SoapHeader* mySoapHeaders[];

   [SoapHeaderAttribute(S"mySoapHeaders",
      Direction=SoapHeaderDirection::In)]
   [System::Web::Services::Protocols::SoapDocumentMethodAttribute(
      S"http://tempuri.org/Add",
      Use=System::Web::Services::Description::SoapBindingUse::Literal,
      ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)]
   [MySoapExtensionAttribute]
   System::Single Add(System::Single xValue, System::Single yValue)
   {
      SoapHeaderCollection* mySoapHeaderCollection = new SoapHeaderCollection();
      MySoapHeader* mySoapHeader;
      mySoapHeader = new MySoapHeader();
      mySoapHeader->text = S"This is the first SOAP header";
      mySoapHeaderCollection->Add(mySoapHeader);
      mySoapHeader = new MySoapHeader();
      mySoapHeader->text = S"This is the second SOAP header";
      mySoapHeaderCollection->Add(mySoapHeader);
      mySoapHeader = new MySoapHeader();
      mySoapHeader->text = S"This header is inserted before the first header";
      mySoapHeaderCollection->Insert(0, mySoapHeader);
      mySoapHeaders = new MySoapHeader*[mySoapHeaderCollection->Count];
      mySoapHeaderCollection->CopyTo(mySoapHeaders, 0);

      Object* temp0 [] = {__box(xValue), __box(yValue)};
      Object* results[] = this->Invoke(S"Add", temp0);
      return *dynamic_cast<Single*>(results[0]);
   }

   [System::Diagnostics::DebuggerStepThroughAttribute]
   MathSvc()
   {
      this->Url = S"https://localhost/MathSvc_SoapHeaderCollection.cs.asmx";
   }

   System::IAsyncResult* BeginAdd(System::Single xValue,
      System::Single yValue, System::AsyncCallback* callback, Object* asyncState)
   {
      Object* temp1 [] = {__box(xValue), __box(yValue)};
      return this->BeginInvoke(S"Add", temp1, callback, asyncState);
   }

   System::Single EndAdd(System::IAsyncResult* asyncResult)
   {
      Object* results[] = this->EndInvoke(asyncResult);
      return *dynamic_cast<Single*>(results[0]);
   }
};

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

必要条件

名前空間: System.Web.Services.Protocols

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

アセンブリ: System.Web.Services (System.Web.Services.dll 内)

参照

SoapHeaderCollection メンバ | System.Web.Services.Protocols 名前空間 | SoapHeader | CollectionBase | IList