当我使用wsdl和端点url执行我的curl php请求时获得空白响应
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了当我使用wsdl和端点url执行我的curl php请求时获得空白响应相关的知识,希望对你有一定的参考价值。
请帮助我,当我执行我的curl php请求和wsdl,端点url时得到空白响应。
这是我的代码:
//end point url
$e_url="https://tmcrmportal.inservices.tatamotors.com/home/B2C/com.eibus.web.soa
p.Gateway.wcp?organization=o=B2C;cn=cordys,cn=cbop,o=tatamotors.com";
//wsdl
$wsdl="WSDL";
//$curl = curl_init($e_url);
//request
$xml_post_string = '<?xml version="1.0"?>
<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\">
<SOAP:Header>
<wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">
<wsse:UsernameToken xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">
<wsse:Username>username</wsse:Username>
<wsse:Password>pwd</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP:Header>
<SOAP:Body>
<samlp:Request IssueInstant=\"2004-12-05T09:21:59Z\" MajorVersion=\"1\" MinorVersion=\"1\" RequestID=\"456789\" xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\">
<samlp:AuthenticationQuery>
<saml:Subject xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\">
<saml:NameIdentifier Format=\"urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified\">username</saml:NameIdentifier>
</saml:Subject>
</samlp:AuthenticationQuery>
</samlp:Request>
</SOAP:Body>
</SOAP:Envelope>';
$headers = array(
"Content-type: text/xml;charset="utf-8"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: "run"",
"Content-length: ".strlen($xml_post_string),
);
$ch = curl_init("ENDPOINTURL");
curl_setopt($ch, CURLOPT_URL, $wsdl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
if(curl_exec($ch) === false) {
$err = 'Curl error: ' . curl_error($ch);
print $err;
curl_close($ch);
} else {
$response = curl_exec($ch);
print $response.'Operation completed without any errors';
curl_close($ch);
}
答案
我猜你实际上得到了500错误,但在你的php配置中禁用了错误输出。如果是这样,请检查您的phpinfo()是否已安装curl模块。出于安全原因提出问题时,请避免显示您的真实凭据。
以上是关于当我使用wsdl和端点url执行我的curl php请求时获得空白响应的主要内容,如果未能解决你的问题,请参考以下文章