我需要对Web服务进行POST,但找不到退货。
我设法从SoapUI应用程序发出了请求,但是当我将相同的请求带到ASPNET MVC C#中的代码时,总是收到错误消息:“所请求的URL被拒绝”
基本上我不知道在哪里配置安全数据(用户,密码和密码类型,在这种情况下为PASSWORDTEXT)。
他们有一个例子吗?
我遗留下来的装备可以从网络上的其他示例中抢救出来
public void TestWSFalabella()
{
var _url = "url";
var _action = "";
XmlDocument soapEnvelopeXml = CreateSoapEnvelope();
HttpWebRequest webRequest = CreateWebRequest(_url, _action);
string auth = string.Format("Basic {0}", Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(string.Format("{0}:{1}", "usuario", "password"))));
webRequest.PreAuthenticate = true;
webRequest.Headers.Add(HttpRequestHeader.Authorization, auth);
webRequest.UseDefaultCredentials = false;
InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest);
// begin async call to web request.
IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);
// suspend this thread until call is complete. You might want to
// do something usefull here like update your UI.
asyncResult.AsyncWaitHandle.WaitOne();
// get the response from the completed web request.
string soapResult;
using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))
{
using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))
{
soapResult = rd.ReadToEnd();
}
Console.Write(soapResult);
}
}