CallContext.GetHeaders Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Retourne les en-têtes envoyés avec l'appel de méthode.
public:
static cli::array <System::Runtime::Remoting::Messaging::Header ^> ^ GetHeaders();
public static System.Runtime.Remoting.Messaging.Header[] GetHeaders ();
[System.Security.SecurityCritical]
public static System.Runtime.Remoting.Messaging.Header[] GetHeaders ();
static member GetHeaders : unit -> System.Runtime.Remoting.Messaging.Header[]
[<System.Security.SecurityCritical>]
static member GetHeaders : unit -> System.Runtime.Remoting.Messaging.Header[]
Public Shared Function GetHeaders () As Header()
Retours
- Header[]
En-têtes envoyés avec l'appel de méthode.
- Attributs
Exceptions
L'appelant immédiat n'a pas d'autorisation d'accès à l'infrastructure.
Exemples
L’exemple de code suivant envoie des en-têtes à une méthode distante et imprime le contenu de ces en-têtes dans la console lorsque la méthode distante retourne.
// Array of Headers with name and values initialized.
array<Header^>^ myArrSetHeader = { gcnew Header( "Header0","CallContextHeader0" ),
gcnew Header( "Header1","CallContextHeader1" ) };
// Pass the Header Array with method call.
// Header will be set in the method by'CallContext::SetHeaders' method in remote Object*.
Console::WriteLine( "Remote HeaderMethod output is {0}",
myService->HeaderMethod( "CallContextHeader", myArrSetHeader ) );
array<Header^>^ myArrGetHeader;
// Get Header Array.
myArrGetHeader = CallContext::GetHeaders();
if ( nullptr == myArrGetHeader )
{
Console::WriteLine( "CallContext::GetHeaders Failed" );
}
else
{
Console::WriteLine( "Headers:" );
}
for each ( Header^ myHeader in myArrGetHeader )
{
Console::WriteLine( "Value in Header '{0}' is '{1}'.",
myHeader->Name, myHeader->Value );
}
// Array of Headers with name and values initialized.
Header[] myArrSetHeader = {new Header("Header0","CallContextHeader0"),
new Header("Header1","CallContextHeader1")};
// Pass the Header Array with method call.
// Header will be set in the method by'CallContext.SetHeaders' method in remote object.
Console.WriteLine("Remote HeaderMethod output is " +
myService.HeaderMethod("CallContextHeader",myArrSetHeader));
Header[] myArrGetHeader;
// Get Header Array.
myArrGetHeader=CallContext.GetHeaders();
if (null == myArrGetHeader)
Console.WriteLine("CallContext.GetHeaders Failed");
else
Console.WriteLine("Headers:");
foreach(Header myHeader in myArrGetHeader)
{
Console.WriteLine("Value in Header '{0}' is '{1}'.",myHeader.Name,myHeader.Value);
}
' Array of Headers with name and values initialized.
Dim myArrSetHeader As Header() = {New Header("Header0", "CallContextHeader0"), _
New Header("Header1", "CallContextHeader1")}
' Pass the Header Array with method call.
' Header will be set in the method by'CallContext.SetHeaders' method in remote object.
Console.WriteLine("Remote HeaderMethod output is " _
+ myService.HeaderMethod("CallContextHeader", myArrSetHeader))
Dim myArrGetHeader() As Header
' Get Header Array.
myArrGetHeader = CallContext.GetHeaders()
If myArrGetHeader Is Nothing Then
Console.WriteLine("CallContext.GetHeaders Failed")
Else
Console.WriteLine("Headers:")
End If
Dim myHeader As Header
For each myHeader in myArrGetHeader
Console.WriteLine("Value in Header '{0}' is '{1}'.",myHeader.Name,myHeader.Value)
Next