即时通讯问题。 我明白了。CORS麻烦无法解决jquery,laravel5.2
function soapRequest()
{
var soap_str='';
soap_str+='<?xml version="1.0" encoding="UTF-8"?>';
soap_str+='<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"';
soap_str+='xmlns:ns1="https://www.pagofacil.net/st/public/Wsstransaccion/?wsdl"';
soap_str+='xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"';
soap_str+='xmlns:xsd="http://www.w3.org/2001/XMLSchema"';
soap_str+='xmlns:ns2="http://xml.apache.org/xml-soap"';
soap_str+='xmlns:enc="http://www.w3.org/2003/05/soap-encoding">';
soap_str+='<env:Body>';
soap_str+=' <ns1:transaccion env:encodingStyle="http://www.w3.org/2003/05/soapencoding">';
soap_str+=' <param0 xsi:type="ns2:Map"><item><key xsi:type="xsd:string">nombre</key><value xsi:type="xsd:string">Juan A</value></item><item><key xsi:type="xsd:string">apellidos</key> <value xsi:type="xsd:string">Lopez Hernández</value></item> <item> <key xsi:type="xsd:string">numeroTarjeta</key> <value xsi:type="xsd:string">557956789</value> </item> <item> <key xsi:type="xsd:string">cp</key> <value xsi:type="xsd:string">11560</value> </item> <item> <key xsi:type="xsd:string">cvt</key> <value xsi:type="xsd:string">123</value> </item> <item> <key xsi:type="xsd:string">monto</key> <value xsi:type="xsd:string">100</value> </item> <item> <key xsi:type="xsd:string">mesExpiracion</key> <value xsi:type="xsd:string">10</value> </item> <item> <key xsi:type="xsd:string">anyoExpiracion</key> <value xsi:type="xsd:string">15</value> </item> <item> <key xsi:type="xsd:string">idSucursal</key> <value xsi:type="xsd:int">1</value> </item> <item> <key xsi:type="xsd:string">idUsuario</key> <value xsi:type="xsd:int">1</value> </item> <item> <key xsi:type="xsd:string">idServicio</key> <value xsi:type="xsd:int">3</value> </item> <item> <key xsi:type="xsd:string">telefono</key> <value xsi:type="xsd:string">5550220910</value> </item> <item> <key xsi:type="xsd:string">celular</key> <value xsi:type="xsd:string">555</value> </item> <item> <key xsi:type="xsd:string">calleyNumero</key> <value xsi:type="xsd:string">Anatole France 311</value> </item> <item> <key xsi:type="xsd:string">colonia</key> <value xsi:type="xsd:string">Polanco</value> </item> <item> <key xsi:type="xsd:string">municipio</key> <value xsi:type="xsd:string">Miguel Hidalgo</value> </item> <item> <key xsi:type="xsd:string">estado</key> <value xsi:type="xsd:string">Distrito Federal</value> </item> <item> <key xsi:type="xsd:string">pais</key> <value xsi:type="xsd:string">Mexico</value> </item> <item> <key xsi:type="xsd:string">email</key> <value xsi:type="xsd:string">[email protected]</value> </item> <item> <key xsi:type="xsd:string">param1</key> <value xsi:type="xsd:string"/> </item> <item> <key xsi:type="xsd:string">param2</key> <value xsi:type="xsd:string">2</value> </item> <item> <key xsi:type="xsd:string">param3</key> <value xsi:type="xsd:string">3</value> </item> <item> <key xsi:type="xsd:string">param4</key> <value xsi:type="xsd:string"/> </item> <item> <key xsi:type="xsd:string">param5</key> <value xsi:type="xsd:string"/> </item> </param0> ';
soap_str+='</ns1:transaccion> </env:Body> </env:Envelope>';
var str=soap_str;
function createCORSRequest(method,url)
{
var xhr= new XMLHttpRequest();
if ("withCredentials" in xhr){
xhr.open(method,url,false);
}
else
{
//CORS not supported
console.log("CORS not supported");
alert("CORS not supported");
xhr=null;
}
return xhr;
}
var xhr= createCORSRequest("POST","https://www.pagofacil.net/st/public/Wsstransaccion/");
alert(xhr);
if(!xhr)
{
console.log("xhr issues");
return;
}
xhr.onload = function()
{
var results = xhr.responseText;
console.log(results);
}
xhr.setRequestHeader('Content-Type','text/xml');
xhr.setRequestHeader("Access-Control-Allow-Origin","http://localhost:8000/");
alert(str);
xhr.send(str);
}
soapRequest();
我得到了以下错误。 1寄存器:895个OPTIONS pagofacil.net/st/public/Wsstransaccion/ 500(内部服务错误) 2-寄存器:895的XMLHttpRequest不能加载pagofacil.net/st/public/Wsstransaccion/。对预检请求的响应不会通过访问控制检查:请求的资源上不存在“访问控制 - 允许来源”标头。因此不允许访问原产地'http://localhost:8000'。该响应的HTTP状态码为500. 3-register:895 Uncaught NetworkError:未能在'XMLHttpRequest'上执行'send':未能加载'pagofacil.net/st/public/Wsstransaccion/'。
我已经试过REST,JSON邮政和我得到了与SOAP一样CORS麻烦。 我甚至试图禁用mozilla上的CORS安全选项,但没有工作(同样的错误)。
我不是寻找一个解决方案在这里,但我不知道我在哪里可以看一下。 谢谢大家。
简而言之,pagofacil.net服务器不允许CORS。
非常感谢您与其第三方公司进行验证。 –