तुम भी contents of the Request.InputStream पढ़ सकते हैं।
इस तरह से मामलों के लिए यह अधिक उपयोगी है जब आप इनपुट की सामग्री के आधार पर WebMethod के भीतर सत्यापन या अन्य कार्रवाइयां करना चाहते हैं।
using System;
using System.Collections.Generic;
using System.Web;
using System.Xml;
using System.IO;
using System.Text;
using System.Web.Services;
using System.Web.Services.Protocols;
namespace SoapRequestEcho
{
[WebService(
Namespace = "http://soap.request.echo.com/",
Name = "SoapRequestEcho")]
public class EchoWebService : WebService
{
[WebMethod(Description = "Echo Soap Request")]
public XmlDocument EchoSoapRequest(int input)
{
// Initialize soap request XML
XmlDocument xmlSoapRequest = new XmlDocument();
// Get raw request body
Stream receiveStream = HttpContext.Current.Request.InputStream
// Move to begining of input stream and read
receiveStream.Position = 0;
using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8))
{
// Load into XML document
xmlSoapRequest.Load(readStream);
}
// Return
return xmlSoapRequest;
}
}
}
नोट: नीचे जॉन्स टिप्पणी प्रतिबिंबित करने के लिए अद्यतन किया गया।
स्रोत
2011-05-21 02:01:22
टूट गया है हो सकता है, लेकिन आप स्पष्ट web.config में IHttpModule रजिस्टर करने के लिए आवश्यकता हो सकती है <जोड़ने नाम = "LogModule" type = "MyNameSpace.LogModule" /> –