당신은 또한 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;
}
}
}
참고 : 아래 존스의 의견을 반영하기 위해 업데이트되었습니다.
깨 있지만 Web.config의에 IHttpModule을 등록해야 할 수도 있습니다 <의 system.webServer> <이름 = "LogModule"유형 = "MyNameSpace.LogModule"를 추가 /> –