请帮助我,当我使用请求和wsdl,端点网址执行我的curl php时获得空白响应。
这是我的代码:
//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);
}
答案 0 :(得分:0)
我猜你实际上得到了500错误,但在你的php配置中禁用了错误输出。如果是这样,请检查您的phpinfo()是否已安装curl模块。出于安全原因提出问题时,请避免显示您的真实凭据。