当使用JavaScript发送HTTP请求时,从Web服务器收到500:内部服务器错误作为响应。

3

我的代码如下:

    var http_url = ""+MDM_HTTP_URL;

    var httpClient = new A_HttpRequest();
    httpClient.open ("POST", http_url);

    httpClient.setRequestHeader("SOAPAction","invokeEPSMDMRTIDealService");
    httpClient.setRequestHeader("Content-Type","text/xml");
    httpClient.setRequestHeader("charset","UTF-8");


    var roleObj = Acumen.getRole();
    var userObj = Acumen.getUser();


    var roleName = roleObj.name;
    roleName = roleName.replace(/\&/g,'&');
    print("RAJIV_USER:"+roleName+"\t"+userObj.name+"\t"+userObj.id);


    var soap_request = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:com=\"http://com.cisco.eps.mdm.webservice.xmlSchema\"><soapenv:Header/><soapenv:Body><com:EPSMDMRTIDealServiceRequest><com:OPTY_NUMBER>"+_DEAL_ID_+"</com:OPTY_NUMBER><com:USER_ID>"+userObj.id+"</com:USER_ID><com:USER_NAME>"+userObj.name+"</com:USER_NAME><com:ROLE>"+roleName+"</com:ROLE></com:EPSMDMRTIDealServiceRequest></soapenv:Body></soapenv:Envelope>";

    var http_response = httpClient.send(soap_request);
    var soapResponse = http_response.getHttpResponseBody();

    print("RESPONSE HEADER IS::\n"+http_response.getHttpResponseHeader());
    print("RESPONSE XML : " +  soapResponse);
    return soapResponse;

当我执行以上程序时,它会输出以下内容:
RESPONSE HEADER IS::
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=UTF-8
Transfer-Encoding: chunked
Date: Tue, 13 Aug 2013 12:44:00 GMT
Connection: close



RESPONSE XML : <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode></faultcode><faultstring>com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '/' (code 47) in prolog; expected '&lt;'
 at [row,col {unknown-source}]: [1,1]</faultstring><detail /></soapenv:Fault></soapenv:Body></soapenv:Envelope> 

有人能帮我解决这个问题吗?


500内部服务器错误意味着服务器崩溃了。显然有一个漏洞。那个服务器是你的吗? - Álvaro González
1个回答

0
只是猜测:检查_DEAL_ID_userObj.iduserObj.nameroleName的内容。其中一个可能包含服务器端解析器抱怨的/字符。另一个猜测:删除<soapenv:Header />或将其更改为<soapenv:Header></soapenv:Header>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接