我收到错误消息:“看起来我们没有XML文档”。
这是我的php脚本:
<?php
$client = new SoapClient("http://ws-argos.cls.fr/argosDws/services/DixService?wsdl", array('trace' => 1, "exceptions" => 0));
$result = $client->getXml(array (
'username' => 'my username',
'password' => 'my password',
'platformId' => '1',
'nbPassByPtt' => 100,
'nbDaysFromNow' => 10,
'mostRecentPassages' => true
));
echo "====== REQUEST HEADERS =====" . PHP_EOL;
var_dump($client->__getLastRequestHeaders());
echo "========= REQUEST ==========" . PHP_EOL;
var_dump($client->__getLastRequest());
echo "========= RESPONSE =========" . PHP_EOL;
var_dump($result);
这是__getLastRequest()的结果:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://service.dataxmldistribution.argos.cls.fr/types">
<SOAP-ENV:Body>
<ns1:xmlRequest>
<ns1:username>my username</ns1:username>
<ns1:password>my password</ns1:password>
<ns1:platformId>1</ns1:platformId>
<ns1:nbPassByPtt>100</ns1:nbPassByPtt>
<ns1:nbDaysFromNow>10</ns1:nbDaysFromNow>
<ns1:mostRecentPassages>true</ns1:mostRecentPassages>
</ns1:xmlRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
这就是请求应该根据文档看起来的样子:
<soap:Envelope
xmlns:soap=”http://www.w3.org/2003/05/soap-envelope”
xmlns:typ=”http://service.dataxmldistribution.argos.cls.fr/types”>
<soap:Header/>
<soap:Body>
<typ:xmlRequest>
<typ:username>mturiot</typ:username>
<typ:password>qt</typ:password>
<typ:platformId>1</typ:platformId>
<typ:nbPassByPtt>2</typ:nbPassByPtt>
<typ:nbDaysFromNow>10</typ:nbDaysFromNow>
<typ:mostRecentPassages>true</typ:mostRecentPassages>
</typ:xmlRequest>
</soap:Body>
</soap:Envelope>
我做错了什么?任何帮助表示赞赏!
答案 0 :(得分:0)
我遇到了同样的问题,我转向以不同的方式获得解决方案。 它可能不是最好的方式,但它确实有效。
解决方案的来源found here
$param = array(
'username'=>$username,
'password'=>$password,
'platformId'=>$platformId,
'nbDaysFromNow'=>20
);
$client = new SoapClient("http://ws-argos.cls.fr/argosDws/services/DixService?wsdl",
array('trace' => 1,
"exceptions" => 0,
'style'=> SOAP_DOCUMENT,
'use'=> SOAP_LITERAL));
$results = $client->getXml($param);
$results = $client->__getLastResponse();
//Handle BOM
$xml = explode("\r\n", $results);
//The resultant CDATA is at 6th tag
$response = preg_replace( '/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', "", $xml[6] );
//Get the CDATA content alone
$explode1 = explode("<return>", $response);
$xmlVar = explode("</return>", $explode1[1]);
$finalXML = $xmlVar[0];
//Convert string as XML
$xmlElem = simplexml_load_string('<xml>' . $finalXML . '</xml>');
echo $xmlElem;