我正在使用Microsoft ASP.NET Web API 2,我的一个端点必须在内部调用传统的asmx Web服务.
这是正确的方法吗?
- ...................................................
- 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 ),postData.Length );
- reqStream.Close();
- }
- WebResponse resp = req.GetResponse();
…………………………………………
更新:我确实有一堆非Microsoft技术Web服务(没有asnx或svc).上述方法对于那些类型的服务是否足够好?