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> 

谁能帮我解决这个问题?

4

1 回答 1

0

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

于 2013-08-14T07:35:35.823 回答