1

I'm trying to receive a SOAP request on an ASP.NET webservice but I'm stucking here right now.

The first thing I tried was to just receive a simple string in my webservice but my webservice denied that request, because it was a "dangerous request". The second thing I tried was to use XmlDocument and XElement as input date type but when I try that I get an IndexOutOfRangeException in SoapUI and can't call that method simply in the browser.

Is there any trick to accept SOAP requests in the WebMethod?

To make it easier to understand, I'm looking for a solution like that:

[WebMethod]
public XmlDocument Method(string soapRequest)
{
    XmlDocument xmlAnswer = doSomethingWithRequest(soapRequest);

    return xmlAnswer;
}
Zumarta
  • 145
  • 3
  • 18

1 Answers1

0

Unfortunately I couldn't find any way to do it with such a simple solution like I asked for. I tried XmlElement how it is mentioned in this (very old) article.

I did it now in that way:

// Create array for holding request in bytes
byte[] inputStream = new byte[HttpContext.Current.Request.ContentLength];

// Read the entire request input stream
HttpContext.Current.Request.InputStream.Read(inputStream, 0, inputStream.Length);

// Set stream position back to beginning
HttpContext.Current.Request.InputStream.Position = 0;

// Get the XML request
string xmlRequestString = Encoding.UTF8.GetString(inputStream);

And that works fine for me.

Community
  • 1
  • 1
Zumarta
  • 145
  • 3
  • 18