on 01-20-2016 5:38 PM
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);
}
Hi,
Fixed it.
To anyone who faces the same problem, the solution is to use the line:
request.contentType = "text/xml";
Cheers,
Shyam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.