weixin_33724570 2015-12-24 11:20 采纳率: 0%
浏览 33

jQuery Ajax SOAP没有响应

I do not know what exactly happening with me. I am trying to call soap service but im not getting any response.

function soap_call(){     
    var wsUrl = "https://ws.cert.transactionexpress.com/portal/merchantframework/MerchantWebServices-v1?wsdl";
    var soapRequest = 
        '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://postilion/realtime/merchantframework/xsd/v1/"> \
          <SOAP-ENV:Body> \
            <v1:UpdtRecurrProfRequest> \
                 <v1:merc> \
                    <v1:id>7777778598</v1:id> \
                    <v1:regKey>BLHP7DK5W385J6WZ</v1:regKey> \
                    <v1:inType>1</v1:inType> \
                    <v1:prodType>5</v1:prodType> \
                 </v1:merc> \
                 <v1:cust> \
                    <v1:type>0</v1:type> \
                    <v1:contact> \
                       <v1:fullName>Test Person</v1:fullName> \
                       <v1:addrLn1>123 Main</v1:addrLn1> \
                       <v1:addrLn2>Second Floor</v1:addrLn2> \
                       <v1:city>Gilbert</v1:city> \
                       <v1:state>AZ</v1:state> \
                       <v1:zipCode>85296</v1:zipCode> \
                       <v1:type>1</v1:type> \
                       <v1:stat>1</v1:stat> \
                    </v1:contact> \
                    <v1:pmt> \
                       <v1:type>0</v1:type> \
                       <v1:card> \
                          <v1:pan>4485896261017708</v1:pan> \
                          <v1:sec>999</v1:sec> \
                          <v1:xprDt>1602</v1:xprDt> \
                       </v1:card> \
                       <v1:ordNr>Cust Ref ID  Can be used for extra info</v1:ordNr> \
                       <v1:desc>Can be used to name wallet again</v1:desc> \
                       <v1:indCode>2</v1:indCode> \
                    </v1:pmt> \
                 </v1:cust> \
              </v1:UpdtRecurrProfRequest> \
          </SOAP-ENV:Body> \
        </SOAP-ENV:Envelope>' ;
        jQuery.ajax({
            type: "POST",
            url: wsUrl,
            contentType: "text/xml; charset=\"utf-8\"",
            dataType: "xml",
            data: soapRequest,
            //processData: false,
            //async:true,
            headers: {
                SOAPAction: "UpdtRecurrProf"
            },
            complete: function (xmlHttpRequest) {
                alert(xmlHttpRequest.responseXML);
            },

        });

    }

I tried to call using this link , then it gave me correct response.

I do not have expertise in soap. I will appreciate if anyone can help me out from here.

  • 写回答

1条回答 默认 最新

  • weixin_33749131 2015-12-24 11:40
    关注

    Just checked your request with a Postman - there's everything absolutely fine with a request itself. Here's the response I had:

    <?xml version='1.0' encoding='UTF-8'?>
    <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
        <S:Body>
            <ns2:UpdtRecurrProfResponse xmlns="http://postilion/realtime/portal/soa/xsd/Faults/2009/01" xmlns:ns2="http://postilion/realtime/merchantframework/xsd/v1/">
                <ns2:custId>1450956517822188336</ns2:custId>
                <ns2:pmtId>1450956517853193808</ns2:pmtId>
                <ns2:rspCode>00</ns2:rspCode>
            </ns2:UpdtRecurrProfResponse>
        </S:Body>
    </S:Envelope>
    

    The problem appears because of you use javascript and same origin policy doesn't allow you to request domains, which are different from yours - this helps to protect from XSS attacks.

    It could be possible to request remote host though, if it provides a CORS header, like Access-Control-Allow-Origin: *, which allows all domains to request it, but looking at the response, it does not return this header it this case:

    Cache-Control → private
    Content-Encoding → gzip
    Content-Type → text/xml;charset=utf-8
    Date → Thu, 24 Dec 2015 11:28:37 GMT
    Server → WebServer
    Transfer-Encoding → chunked
    

    Also you should see this error message in your browser console, which approves my suggestion.

    Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource

    So the problem is not with SOAP request itself, but with that you try to request it via javascript. Make a request through on your backend (PHP for instance) - and it should go smoothly.

    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题