Xml Post请求Wcf服务(500内部服务器错误)

时间:2016-12-15 12:05:36

标签: c# xml wcf http-post

我必须向Api发出Xml帖子请求,并且不知道丢失了什么,我总是得到两个错误。我的要求是......

         string oRequest = "";
        oRequest = "<soapenv:Envelope   xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\""
                        +"xmlns:typ=\"http://www.website.net/lmsglobal/ws/v1/extint/types\"" 
                        +"xmlns:typ1=\"http://www.website.net/lmsglobal/xsd/v1/types\">";
            oRequest = oRequest + "<soapenv:Header/>";
            oRequest = oRequest + "<soapenv:Body>";
            oRequest = oRequest + "<typ:GetAccountBalanceRequest>";
            oRequest = oRequest + "<typ:Authentication>";
            oRequest = oRequest + "<typ1:Principal>";
            oRequest = oRequest + "<typ1:PrincipalValue >88888888888</ typ1:PrincipalValue>";
            oRequest = oRequest + "<typ1:PrincipalClassifier >0</ typ1:PrincipalClassifier>";
            oRequest = oRequest + "</typ1:Principal>";
            oRequest = oRequest + "</typ:Authentication>";               
            oRequest = oRequest + "</typ:GetAccountBalanceRequest>";
            oRequest = oRequest + "</soapenv:Body>";
            oRequest = oRequest + "</soapenv:Envelope>";

            byte[] data = Encoding.UTF8.GetBytes(oRequest);
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://mywebsite.in/Services/v1/soap");
            request.Method = "POST";
            request.ContentType = "text/xml;charset=UTF-8";

            Stream dataStream = request.GetRequestStream();
            dataStream.Write(data, 0, data.Length);
            dataStream.Close();

            HttpWebResponse resp = (HttpWebResponse)request.GetResponse();
            string result = new StreamReader(resp.GetResponseStream()).ReadToEnd();

错误

  • ((System.Net.ConnectStream)newStream).Length引发类型&#39; System.NotSupportedException&#39;

  • 的异常
  • ((System.Net.ConnectStream)newStream).Lengththrew类型&#39; System.NotSupportedException&#39;在

    处获得这些错误

    Stream dataStream = request.GetRequestStream();

最后 500内部服务器错误。我错过了什么是错的?这个请求来自 SOAP UI 工具,它也会给出响应。

0 个答案:

没有答案