我使用 IDispatchMessageInspector 在数据库中登录了SOAP Envelop。我需要使用SOAP Envlope调用我的WCF服务,其中包含wsHttpBinding。
我使用下面的代码来调用我的WCF服务。
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("ServiceURL");
req.Method = "POST";
string reqBody = theBomRequest; //it has entire soap
byte[] reqBodyBytes = Encoding.UTF8.GetBytes(reqBody);
req.ContentType = "application/soap+xml; charset=utf-8";
req.GetRequestStream().Write(reqBodyBytes, 0, reqBodyBytes.Length);
req.GetRequestStream().Close();
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Console.WriteLine("HTTP/{0} {1} {2}", resp.ProtocolVersion, (int)resp.StatusCode, resp.StatusDescription);
if (resp.ContentLength > 0)
{
Console.WriteLine(new StreamReader(resp.GetResponseStream()).ReadToEnd());
}
resp.Close();
在GetResponse,我收到(500)内部服务器错误
谢谢, 阿基夫