简体   繁体   English

415不支持的媒体类型jQuery

[英]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). 我得到了错误415(不支持的媒体类型)。 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. 415错误表示服务器错误。 For whatever reason, it's not liking your request. 无论出于什么原因,它都不喜欢您的请求。
  2. Why are you trying to make your own SOAP envelopes? 您为什么要制作自己的SOAP信封? Quick Google search for "jquery soap" return this SOAP plugin . 快速的Google搜索“ jquery soap”返回此SOAP插件 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? 是否有var body = "在SOAP消息中包含var body = "
  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. 您有var body = "<soapenv ,但是永远不要关闭此引号。同一行是xmlns:soapenv=\\"http ,您不会关闭的另一引号。

But ultimately, I'd suggest using a third-party SOAP library for jQuery, rather than trying to roll your own envelope. 但最终,我建议为jQuery使用第三方SOAP库,而不要尝试自己动手做信封。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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