Comment : initialiser les données en mémoire cache lorsqu'une extension SOAP est configurée

Cette rubrique est spécifique à une technologie existante. Les services Web XML et les clients du service Web XML doivent à présent être créés à l'aide de Windows Communication Foundation.

L'exemple de code suivant initialise les données mises en cache dans la méthode GetInitializer, en fonction de la configuration finale de l'extension SOAP. Si l'extension SOAP est configurée à l'aide d'un attribut, dans ce cas un TraceExtensionAttribute, le nom de fichier spécifié dans l'attribut est mis en cache. Si l'extension SOAP est configurée à l'aide d'un fichier de configuration, le nom de fichier mis en cache est calculé en fonction du type du service Web.

Exemple

' When the SOAP extension is accessed for the first time, the XML
' Web service method it is applied to is accessed to store the file
' name passed in, using the corresponding SoapExtensionAttribute.
Public Overloads Overrides Function GetInitializer(methodInfo As _
   LogicalMethodInfo, attribute As SoapExtensionAttribute) As Object 
 Return CType(attribute, TraceExtensionAttribute).Filename
End Function

' The extension was configured to run using a configuration file 
' instead of an attribute applied to a specific Web service method.
' Return a file name, based on the class implementing the XML Web 
' service's type.

Public Overloads Overrides Function GetInitializer(WebServiceType As _
   Type) As Object
  ' Return a file name to log the trace information, based on the type.
  Return "C:\" + WebServiceType.FullName + ".log"    
End Function
// When the SOAP extension is accessed for the first time, the XML
// Web service method it is applied to is accessed to store the file
// name passed in, using the corresponding SoapExtensionAttribute.
public override object GetInitializer(LogicalMethodInfo methodInfo,
   SoapExtensionAttribute attribute) 
{
   return ((TraceExtensionAttribute) attribute).Filename;
}
// The extension was configured to run using a configuration file instead of
// an attribute applied to a specific Web service method.
public override object GetInitializer(Type WebServiceType) 
{
// Return a file name to log the trace information, based on the type.
   return "C:\\" + WebServiceType.FullName + ".log";}

Voir aussi

Tâches

Procédure pas à pas : altération du message SOAP à l'aide d'extensions SOAP