Quantcast
Channel: SCN : Discussion List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 5653

Cannot force content type to XML when making an XSJS call to webservice

$
0
0

Hi All,

I am trying to reach a webservice which throws an error of unsupported media type.

The sent block is an XML which is what is expected, but what reaches is text/html as per the admins.

 

When I try to force the change of media type by $.request.contentType = "application/xml"

I get the error : WebEntityRequest.contentType : cannot modify contentType

 

What could be the problem? Looking forward to your replies.

 

Code:

 

 

var destination = $.net.http.readDestination("path","Webservice);

var client = new $.net.http.Client();

var request = new $.net.http.Request($.net.http.POST, "");

var data = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'

+'<soapenv:Envelope xmlns:soapenv = "http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn = "urn:sap-com:document:sap:rfc:functions">'

      + '<soapenv:Header/>'

      + '<soapenv:Body>'

 

...some xml

    + '</soapenv:Body>'

      + '</soapenv:Envelope>' ;

 

 

try{

 

 

       

          request.setBody(data);

         $.request.contentType = "application/xml"   ; \\ This i just added after I got the unsupported media type problem

          client.request(request, destination);

          var response = client.getResponse();

           

         var resBody = response.body.asString();

        $.response.contentType = "text/xml";

            $.response.status = $.net.http.OK;

            $.response.setBody(data);

 

 

}

catch(errObj){

    $.response.setBody(errObj.message);

}


Viewing all articles
Browse latest Browse all 5653

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>