簡體   English   中英

如何在IIS6上的ASP.NET中轉發SOAP請求?

[英]How to forward SOAP request in ASP.NET on IIS6?

我正在嘗試制作一個駐留在IIS 6上的應用程序(或Web服務),該應用程序將使用修改后的憑據將SOAP請求轉發到另一個Web服務應用程序。

現在,我的應用程序的Page_Load中有類似以下內容:

HttpWebRequest newRequest = (HttpWebRequest)WebRequest.Create(newUrl);
newRequest.ContentType = original.ContentType;
newRequest.ContentLength = original.ContentLength;
newRequest.Method = original.HttpMethod;
newRequest.UserAgent = original.UserAgent;
newRequest.Credentials = new NetworkCredential("login","password","domain");
HttpWebResponse response = (HttpWebResponse)newRequest.GetResponse();

問題是它在最后一行崩潰,因為ContentLength> 0並且我沒有打開RequestStream,因為我不知道如何從原始請求中獲取它。

我沒有將這個問題的標題命名為“如何從HttpWebRequest獲取SOAP請求”,因為我認為對我嘗試做的事情有更簡單的解決方案。 也許像Java中的某種請求分配器。

任何幫助將不勝感激。

SOAP請求沒有什么神奇之處-畢竟只是HTTP。 您應該可以使用以下方式復制請求正文:

Context.Request.InputStream.CopyTo(newRequest.GetRequestStream());

另外,您還應確保復制可能在原始請求中設置的所有其他重要HTTP標頭。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM