I am using Microsoft ASP.NET Web API 2
and one of my end points has to internally invoke a legacy asmx
web service.
Is this the correct way?
...................................................
WebRequest req = WebRequest.Create(myWebServiceURL);
req.Method = "POST";
eq.ContentType = "application/x-www-form-urlencoded";
string postData = whateverDataNeedsToBePosted;
using ( Stream reqStream = req.GetRequestStream() )
{
reqStream.Write( new ASCIIEncoding().GetBytes( postData ),
0, postData.Length );
reqStream.Close();
}
WebResponse resp = req.GetResponse();
................................................
UPDATE: I do have a bunch of non-Microsoft technology web services (no asnx or svc). Is the above method good enough for those type of services?