简体   繁体   中英

415 Unsupported Media Type jQuery

This is my code :

var myGTP = {};
var urlGTP = "http://gtpmain.wdf.xxxx.com:1080/sap/bc/srt/rfc/qte/rfc_read_struc_nodes/001/qte_rfc_read_struc_nodes/binding";

var soapMsg = 'var body = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/>' +
    '<soapenv:Header/> <soapenv:Body> <urn:_-qte_-rfcReadStrucNodes>' +
    '<IvLanguage>E</IvLanguage>' +
    '<IvStructureId>' + structureId + '</IvStructureId>' +
    '</urn:_-qte_-rfcReadStrucNodes> </soapenv:Body></soapenv:Envelope>';

$.ajax({
    url : urlGTP,
    dataType : 'jsonp',
    type : 'GET',
    async : false,
    data : soapMsg,
    contentType : 'text/xml; charset=UTF-8',
    username : "myuser",
    passowrd : "mypassword",
    success : function(data) {
        myGTP = data;
        console.log(data);
    },
    error : function() {
        alert("Error!");
    }
}); 

And I got the error 415 (Unsupported Media Type). I tried to figure for a few hours but I don't know what is the problem. Please help!

  1. A 415 error means server error. For whatever reason, it's not liking your request.
  2. Why are you trying to make your own SOAP envelopes? Quick Google search for "jquery soap" return this SOAP plugin . Unless you're making a library, or have specific need to do it yourself, it's not worth it.
  3. Is there a reason for including var body = " in your SOAP message?
  4. Your double-quotes are broken. You have var body = "<soapenv , but never close this quote. Same line is xmlns:soapenv=\\"http , another quote you don't close.

But ultimately, I'd suggest using a third-party SOAP library for jQuery, rather than trying to roll your own envelope.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM