Javascript问题 - 在公共标识符之后需要空间

时间:2015-11-20 04:30:45

标签: xml web-services parsing sap hana

我正在尝试编写一个javascript来将XML发送到外部Web服务,然后处理它并发回XML。我是新手,在这段代码中犯了一些错误,这反过来又在输出上产生了以下错误。 Error screenshot

代码是 -

    var dest = $.net.http.readDestination("Path","AddrService"));
var client = new $.net.http.Client();
var req = new $.net.http.Request( $.net.http.GET, "service/1services/addr");
var data = + '<?xml version="1.0" encoding="UTF-8"?>'
+ '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:rfc:functions">'
+ '<soapenv:Header/>'
+ '<soapenv:Body>'
   + '<urn:_-SIE_-ADDR_WS>'
      + '<IH_REQUESTER>9001</IH_REQUESTER>'

      + '<IF_ADDR_DIRECT>X</IF_ADDR_DIRECT>'
      + '<IT_ADDR_DIRECT>'
         + '<item>'
            + '<CONTROLLER>'
               + '<item>'
                  + '<FIELD/>'
                  + '<VALUE/>'
               + '</item>'
            + '</CONTROLLER>'
            + '<RECORD_ID>1</RECORD_ID>'
            + '<ORGANIZATION/>'
            + '<ADDRESS_LINE1>Hauptstrasse 6</ADDRESS_LINE1>'
            + '<ADDRESS_LINE2/>'
            + '<ADDRESS_LINE3/>'
            + '<ADDRESS_LINE4/>'
            + '<ADDRESS_LINE5/>'
            + '<ADDRESS_LINE6/>'
            + '<ADDRESS_LINE7/>'
            + '<ADDRESS_LINE8/>'
            + '<DOUBLE_DEPENDENT_LOCALITY/>'
            + '<DEPENDENT_LOCALITY/>'
            + '<LOCALITY>Zurich</LOCALITY>'
            + '<SUB_ADMINISTRATIVE_AREA/>'
            + '<ADMINISTRATIVE_AREA/>'
            + '<POSTAL_CODE>8090</POSTAL_CODE>'
            + '<SUB_NATIONAL_AREA/>'
            + '<COUNTRY>CH</COUNTRY>'
            + '<RECORD_OPTIONS/>'
         + '</item>'
      + '</IT_ADDR_DIRECT>'


   + '</urn:_-SIE_-ADDR_WS>'
+ '</soapenv:Body>'
+ '</soapenv:Envelope>' ;

try{

            var response = client.getResponse();
            response.contentType = "text/xml";
            req.setBody(data);
            client.request(req, dest);          
            var resBody = response.body.asString();
            $.response.status = $.net.http.OK; 
            $.response.setBody(resBody); 

}catch(errObj){
    $.response.setBody(errObj.message);
}

我已经在下面的链接中提出了问题,这解释了我在整个代码中的进展。它还包含我尝试作为单独附件发送的XML。

请让我知道你的想法。

谢谢, 希亚姆

3 个答案:

答案 0 :(得分:1)

var dest = $.net.http.readDestination("Path","AddrService"));

尝试删除这个双'))'

var dest = $.net.http.readDestination("Path","AddrService");

答案 1 :(得分:0)

这通常是由请求中发送的html引起的。检查您发送到服务器的请求是否密切,您可能会发现类似以下的内容:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"

答案 2 :(得分:0)

您是否尝试在+

之后删除var data = + '...