Good day.
i am hoping that someone could assist me. I am creating a web service (this is the first time i have ever created a web service). i have worked with web services/API in the past from a client side by creating soap xml messages and sent and received messages back and forth. Now i need to create my own web Service and am needing a little assistance with creating it correctly.
i initially created a simple web method as follows.
[WebMethod(Description = "Soap Request")]
public string Request(string xmlDocument)
{
//do work
}
but when i tried consuming this method i received the following error:
System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client
i then tried (after googling) to change the method as follows:
[WebMethod(Description = "Soap Request")]
public string Request(XmlDocument xmlDocument)
{
//do work
}
but that didnt seem to work either, when i tried to send an xml soap message to this method it came through empty. What i then did was to create the method with parameters matching the elements in my xml Soap message. the method then picked up each element and populated the parameters correctly as follows.
public void Request(string parm1, string parm2)
{
//do work
}
with the following xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:Request>
<tem:Parm1>111</tem:Parm1>
<tem:Parm2>222</tem:Parm2>
</tem:Request>
</soapenv:Body>
</soapenv:Envelope>
i would like to find out, is this the correct way to handle the incoming message or is there something else i should be doing to accept the incoming xml message? i thought that i could create the method as i had initially done that it would accept the xml string passed to it and i could work with the message as i did when receiving xml message back from web services i used in the past.
please forgive me if i have duplicated a question, i could not find anything that would give me a definite answer.
i have started creating the web service in Visual Studio 2019.
any assistance or advise would be greatly appreciated.