0
public void processVoucher()
{
try
{
string url = "http://192.168.xxx.xx:xxxx/context-root-xxxxxxxx/AccountsPayableManagerPort?WSDL/processVoucher";
StreamReader str = new StreamReader(@"F:\IntelliChief integration to JD Edwards for AP Invoice entry\processVoucher_input_payload.xml");
string ipParameter = str.ReadToEnd();
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.ContentType = "application/xml";
req.KeepAlive = true;
req.Timeout = 30000;
req.Accept = "application/xml";//"text/xml";
req.Headers.Clear();
req.Method = "POST";
Encoding encode = Encoding.GetEncoding("utf-8");
using (Stream stm = req.GetRequestStream())
{
using (StreamWriter stmw = new StreamWriter(stm))
{
stmw.Write(ipParameter);
}
}
var response = req.GetResponse(); // here i am getting Unsupported Media Type issue
Stream responseStream = response.GetResponseStream();
StreamReader strReader = new StreamReader(responseStream, encode, true);
string result = strReader.ReadToEnd();
}
catch (Exception ex)
{
MessageBox.Show("Error Message:" + ex.Message);
throw;
}
}
我得到了使用Web服務的要求,顯示結果,我試圖通過使用HttpWebRequest類來使用Web服務。我在req.GetResponse()運行異常任何幫助表示讚賞。Web服務動態使用HttpWebRequest不支持的媒體類型
不要清除標題,這可能是什麼問題。 –
好吧,我嘗試一次... –
嗨馬克,我試着通過評論行req.Headers.Clear()行代碼,但仍然是拋出相同的錯誤 –