我正在用PHP编写代码以使用curl发送soap请求。在肥皂请求中,我必须发送具有许多回车符的文本文件的数据。我尝试使用 、\r、\r、chr(13) 等发送"回车",但所有这些都从服务器给出以下错误
发送的数据中的行应仅由单个 CR 字符分隔。此文件似乎使用 LF 作为分隔符。
以下是我的肥皂请求。我正在用linux开发并向Windows服务器发送请求。
<?php
$submitFileTxt .= "Line1 Text"."r";
$submitFileTxt .= "Line2 Text"."r";
$submitFIleTxt .= "Test,Test,Test"."r";
$submitFIleTxt .= "Testtext,Testtext,Testtext"."r";
$wsdl = "somewsdlurl?wsdl";
$local_cert = "certificate file path";
$password = '';
$xml_post_string = "<s:Envelope xmlns:a='http://www.w3.org/2005/08/addressing' xmlns:s='http://www.w3.org/2003/05/soap-envelope'>
<s:Header>
<a:Action s:mustUnderstand='1'>Data submit method</a:Action>
</s:Header>
<s:Body>
<Submit>
<data xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
<OutputFileBody>{$submitFIleTxt}</OutputFileBody>
<OutputFilename>Some file name</OutputFilename>
</data>
</Submit>
</s:Body>
</s:Envelope>";
$headers = array(
"Content-type: application/soap+xml;charset="utf-8"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"Content-length: ".strlen($xml_post_string),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $wsdl);
curl_setopt($ch, CURLOPT_SSLCERTTYPE, "pem");
curl_setopt($ch, CURLOPT_SSLCERT, $local_cert);
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $password);
curl_setopt($ch, CURLOPT_SSLKEY, $local_cert);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
您可以使用
代替 oo \r,并使用
代替 。