$ length = strlen($ requestXml); $ ch = curl_init($ serviceUrl);CURLソープで正しい応答が得られないPHP
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: text/xml; charset=utf-8',
"SOAPAction: \"https://example.com/PMAPI/example/$action\"",
"Content-length: ".strlen($requestXml)
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookieFIle.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookieFIle.txt");
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$xml= simplexml_load_string($output);
print_r($xml);
出力私は取得しています:
xml形式ではありません。しかし、ソースの表示コードはXML形式です。しかし、私はこの出力文字列を解析してxmlパーサにしても機能しませんでした。
出力は、ビューソースページで見ることができる次の形式にする必要があります。
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><TopUpRequestResponse xmlns="https://dollarphone.com/PMAPI/PinManager"><TopUpRequestResult><responseCode>1</responseCode><TransId>27464347</TransId></TopUpRequestResult></TopUpRequestResponse></soap:Body></soap:Envelope>
オブジェクトにアクセスしようとしているとき。エラーは "非オブジェクトのプロパティを取得しようとしています"です。
どうかこの問題を解決するのに手伝ってください。
ありがとうございます。あなたはSoapClientのようなものがあるのを知っていますよね? http://php.net/manual/en/class.soapclient.php – 1sloc
ええ、私は知っています。しかし、NTLM認証のようにSoapClientを試していると、認証の問題に直面しています。 – NDesai