SoapContext Class
Contains the WSE-specific features of a SOAP message. This class cannot be inherited.
Namespace: Microsoft.Web.Services2
Assembly: Microsoft.Web.Services2 (in microsoft.web.services2.dll)
Usage
'Usage
Dim soapContext1 As SoapContext
Syntax
'Declaration
NotInheritable Public Class SoapContext
public sealed class SoapContext
public sealed ref class SoapContext
public final class SoapContext
public class SoapContext
Example
The following example is a simple Xml Web service that returns various properties of a SoapContext . The example uses the Current method of the RequestSoapContext class to get the SoapContext .
using System; using System.ComponentModel; using System.Web.Services;
using Microsoft.Web.Services2; using Microsoft.Web.Services2.Security;
namespace www.cohowinery.com { public class YourWebService : System.Web.Services.WebService
{ public YourWebService() { // This call is required by the ASP.NET Web Services
Designer InitializeComponent(); }
//Required by the Web Services Designer private IContainer components = null;
private void InitializeComponent() { }
[WebMethod] public string ReturnSoapContextInfo() { string message;
try { SoapContext requestContext = RequestSoapContext.Current;
// Verifies that a SOAP request was received. if (requestContext == null) {
throw new ApplicationException("Either a non-SOAP request was" + "received or
the WSE is not properly installed for " + "the Web application hosting the XML
Web service."); }
message = string.Format("ContentType = {0}", requestContext.ContentType);
message += string.Format("Attachments.Count = {0}", requestContext.Attachments.Count
); message += string.Format("Attachments.Envelope.Body= {0}", requestContext.Envelope.Body
); return message; }
catch(Exception exc) { message = string.Format("ERROR = {0}", exc.Message);
return message; } } } }
Remarks
Web service clients access their SoapContext using the RequestSoapContext and ResponseSoapContext properties of a WebServicesClientProtocol . Web services access their SoapContext using the static Current property of the RequestSoapContext and ResponseSoapContext classes. The SoapContext can also be obtained using the SoapContext property of a SoapWebResponse or SoapWebRequest .
To access the current SOAP context from within a custom filter, use the Microsoft.Web.Services2.SoapContext.Current property. The Microsoft.Web.Services2.RequestSoapContext.Current and Microsoft.Web.Services2.ResponseSoapContext.Current properties are not valid during pipeline processing when customs filters execute.
Inheritance Hierarchy
System.Object
Microsoft.Web.Services2.SoapContext
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms
Development Platforms
Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Longhorn, and Windows 2000
Target Platforms
Windows 2000, Windows 2000 Server, Windows 2000 Advanced Server, Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Longhorn, Pocket PC, Windows CE, Smart Phone
See Also
Reference
Microsoft.Web.Services2 Namespace
RequestSoapContext
ResponseSoapContext