当前位置:编程学习 > C#/ASP.NET >>

C#调用java写的webservice,在GetResponse()取得对方返回值时报500内部服务器错误

private string send(string data)
        {
          private System.Net.HttpWebRequest m_Client = null;
          private XmlDocument m_Dom = new XmlDocument();
          m_Dom.Load("template.xml");
          m_Client = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(RequestUrl);
            m_Client.Method = "POST";
            m_Client.Headers["SOAPAction"] = @"""""";               //双引号
            m_Client.ContentType = "text/xml; charset=utf-8";
            m_Client.Accept = "application/dime, multipart/related, text/*,application/soap+xml";
            m_Client.UserAgent = "Axis/1.4";
            m_Client.Headers["Cache-Control"] = "no-cache";
            m_Client.Headers["Pragma"] = "no-cache";

            //【发送】
            m_Client.ContentLength = data.Length;
            System.IO.Stream sendStread = m_Client.GetRequestStream();
            byte[] sendData = new ASCIIEncoding().GetBytes(data);
            sendStread.Write(sendData, 0, sendData.Length);
            sendStread.Close();
            //【接收】
            System.Net.HttpWebResponse myResponse = (System.Net.HttpWebResponse)m_Client.GetResponse();//调试到此处报远程服务器http:500错误,内部服务器错误
            System.IO.StreamReader reader = new System.IO.StreamReader(myResponse.GetResponseStream(),              Encoding.Default);
            string content = reader.ReadToEnd();
            return content;
        }

其中加载的template.xml文件格式如下:
<?xml version="1.0" encoding="UTF-8" ?> 
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Header>
  <ns1:username soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xsi:type="soapenc:string" xmlns:ns1="Authorization" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">jlnq</ns1:username> 
  <ns2:password soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xsi:type="soapenc:string" xmlns:ns2="Authorization" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1</ns2:password> 
  </soapenv:Header>
- <soapenv:Body>
- <ns3:invoke soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns3="http://server.webservice.core.epm">
  <path xsi:type="xsd:string">epm/am/calibrate/interfaces/service/ExaminationService</path> 
  <methodName xsi:type="xsd:string">GET_METER</methodName> 
  <dataXmlStr xsi:type="xsd:string"><?xml version='1.0' encoding='UTF-8'?><DBSET RESULT="1"><R><C N="CHK_NO">11111</C><C N="AR_TS_CHK">1</C><C N="BAR_CODE">txm0001</C></R></DBSET></dataXmlStr> 
  </ns3:invoke>
  </soapenv:Body>
  </soapenv:Envelope>

请问如何解决此问题,还是说这个报错一定得对方服务端来处理,客户端调用方是否有办法处理?急切期待中。。 http:500错误,内部服务器错误 Web服务 --------------------编程问答-------------------- 500错误是指对方服务器错误。如果对方页面没有问题的话,那说明你的参数,SESSION这些有问题。
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,