0
私はPHPでカールを使用してSOAPリクエストを送信していますが、私は応答をのvar_dumpと私はPHPでcurlを使ってSOAPリクエストからXMLレスポンスを読み込んで解析するには?
$soapUrl = "https://hosting/Wsdl"; // asmx URL of WSDL
$xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<MY DATA>
</soapenv:Body>
</soapenv:Envelope>';
$headers = array(
"Host: hosting,
"Connection: Keep-Alive",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"Content-type: text/xml;charset=\"utf-8\"",
"SOAPAction: http://hosting.com/SOAPAction",
"Content-length: ".strlen($xml_post_string),
);
$url = $soapUrl;
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// converting
$response = curl_exec($ch);
curl_close($ch);
// converting
var_dump($response);
$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);
// convertingc to XML
$parser = simplexml_load_string($response);
echo '<pre>';
var_dump($parser);
echo '</pre>';
に
string(9965) "RESPONSE DATA"
object(SimpleXMLElement)#164 (0) { }
として返すレスポンスをXMLにそれを解析することができない場合の応答が文字列として返します
ご協力いただき、ありがとうございます。
こんにちはが、そのは、タグ名を返さないを使用します。あなたはtagnamesを得る方法を知らせることができますか? – androidBeckhamania