I need to format/build a request for this SOAP "service":
http://api.notificationmessaging.com/NMSOAP/NotificationService?wsdl
Ideally I would like to use the native PHP SOAP class, but I'm beginning to wonder if this class is not the cause of my problems.
The manual provides this example:
<soapenv:Body>
<api:sendObject>
<arg0>
<content>
<entry>
<key>1</key>
<value>
<![CDATA[
<table width="600">
<tr>
<td>
<font size="2" face="Arial">Our powerful algorithms already
found a matching profile that matches your criteria:
<br>Celina72 </font>
<img src="http://mypath/to/my/image.gif" width="50"
height="50" border="0" />
</td>]]></value>
</entry>
</content>
<dyn>
<entry>
<key>FIRSTNAME</key>
<value>john</value>
</entry>
</dyn>
<email>johnblum#flowerpower.com</email>
<encrypt>BdX7CqkmjSivyBgIcZoN4sPVLkx7FaXGiwsO</encrypt>
<notificationId>6464</notificationId>
<random>985A8B992601985A</random>
<senddate>2008-12-12T00:00:00</senddate>
<synchrotype>NOTHING</synchrotype>
<uidkey>EMAIL</uidkey>
</arg0>
</api:sendObject>
</soapenv:Body>
</soapenv:Envelope>
Here is the garbage that my PHP request produces (from __getLastRequest())
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://api.service.nsapi.emailvision.com/" xmlns:ns2="http://xml.apache.org/xml-soap">
<SOAP-ENV:Body>
<ns1:sendObject/>
<param1>AAAAAAAAAAAAAAAAAAAAAAAAAAA</param1>
<param2>123456789</param2>
<param3>BBBBBBBBBBBB</param3>
<param4>2013-09-09T00:00:00</param4>
<param5>NOTHING</param5>
<param6>EMAIL</param6>
<param7>
<ns2:Map>
<item>
<key>2</key>
<value>TEST</value>
</item>
</ns2:Map>
</param7>
<param8>
<ns2:Map>
<item>
<key>FIRSTNAME</key>
<value>John</value>
</item>
</ns2:Map>
<ns2:Map>
<item>
<key>LASTNAME</key>
<value>Smith</value>
</item>
</ns2:Map>
</param8>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
My call:
$client = new SoapClient('http://api.notificationmessaging.com/NMSOAP/NotificationService?wsdl', array( 'trace' => 1, 'exceptions' => 0 ) );
The params look like this (modified with dummy data):
$email = 'john.smith#example.com';
$encrypt = 'AAAAAAAAAAAAAAAAAAAAAAAAAAA';
$notification_id = 123456789;
$random = 'BBBBBBBBBBBB';
$senddate = '2013-09-09T00:00:00';
$synchrotype = 'NOTHING';
$uidkey = 'EMAIL';
$content = array();
$content[] = array(
2 => 'TEST'
);
$dyn = array();
$dyn[] = array(
'FIRSTNAME' => 'John'
);
$dyn[] = array(
'LASTNAME' => 'Smith'
);
$params = array(
'email' => $email,
'encrypt' => $encrypt,
'notificationId' => $notification_id,
'random' => $random,
'senddate' => $senddate,
'synchrotype' => $synchrotype,
'uidkey' => $uidkey,
'content' => $content,
'dyn' => $dyn
);
I then execute the request like this :
$res = $client->__soapCall( 'sendObject', array( $email, $encrypt, $notification_id, $random, $senddate, $synchrotype, $uidkey, $content, $dyn ) );
Why is PHP unable to format my request correctly? Is there a mor direct approach where I could write the XML "by hand" and then post it using cURL?
"Is there a more direct approach where I could write the XML?"
By using a SoapVar and setting the encode parameter of the constructor to XSD_ANYXML you can write the raw XML.
There should be a way where the WSDL helps build the XML though.
You could try something like this:
$wsdl = "http://api.notificationmessaging.com/NMSOAP/NotificationService?wsdl";
$client = new SoapClient($wsdl, array( 'soap_version' => SOAP_1_1,
'trace' => true,
));
try {
$xml = '<arg0>
<content>
<entry>
<key>1</key>
<value>
<![CDATA[
<table width="600">
<tr>
<td>
<font size="2" face="Arial">Our powerful algorithms already
found a matching profile that matches your criteria:
<br>Celina72 </font>
<img src="http://mypath/to/my/image.gif" width="50"
height="50" border="0" />
</td>]]></value>
</entry>
</content>
<dyn>
<entry>
<key>FIRSTNAME</key>
<value>john</value>
</entry>
</dyn>
<email>johnblum#flowerpower.com</email>
<encrypt>BdX7CqkmjSivyBgIcZoN4sPVLkx7FaXGiwsO</encrypt>
<notificationId>6464</notificationId>
<random>985A8B992601985A</random>
<senddate>2008-12-12T00:00:00</senddate>
<synchrotype>NOTHING</synchrotype>
<uidkey>EMAIL</uidkey>
</arg0>';
$args = array(new SoapVar($xml, XSD_ANYXML));
$res = $client->__soapCall('sendObject', $args);
return $res;
} catch (SoapFault $e) {
echo "Error: {$e}";
}
echo "<hr>Last Request";
echo "<pre>", htmlspecialchars($client->__getLastRequest()), "</pre>";
i know that the topic is about 1 year old,
but i find some good informations in it, that give me a very good help , and i finaly succed to make it work with the php method sendObject()
so i hope my contribution will help others people too...
at first the call of sendObject() this way : $client->__soapCall seems not working at all
you have to call it directly : $client->sendObject
in this topic, i think that it is a using of the API of emailvision (smartfocus, now...)
this method sendObject does not need a generated token by openApiConnection()
oki, now , it is the code to make it work
<?php
$email = 'johann.******#gmail.com';
$encrypt = '******************************';
$notification_id = '**************';
$random = '********************';
$senddate = '2013-09-09T00:00:00';
$synchrotype = 'NOTHING';
$uidkey = 'EMAIL';
$params = array(
'arg0' => array(
'content' => array( 1 => 'mon_test'),
'dyn' => array( 'FIRSTNAME' => 'yoyo'),
'email' => $email,
'encrypt' => $encrypt,
'notificationId' => $notification_id,
'random' => $random,
'senddate' => $senddate,
'synchrotype' => $synchrotype,
'uidkey' => $uidkey
)
);
$client = new SoapClient('http://api.notificationmessaging.com/NMSOAP/NotificationService?wsdl', array( 'trace' => 1, 'exceptions' => 0 ) );
$res = $client->sendObject( $params );
echo "<br /><br /><br />";
echo "REQUEST 1 :" . htmlspecialchars($client->__getLastRequest()) . "<br />";
echo "RESPONSE 1 :" . htmlspecialchars($client->__getLastResponse()) . "<br /><br /><br />";
?>
you have to know that $encrypt ,$notification_id , $random are generated by creating a transactionnal message, you can get this informations in the interface of campagn commander
take care of the schema of input xml, there is a node arg0, then you have to make a level arg0 in your array parameters
to make it work directly with xml :
<?php
$wsdl = "http://api.notificationmessaging.com/NMSOAP/NotificationService?wsdl";
$client = new SoapClient($wsdl, array( 'soap_version' => SOAP_1_1, 'trace' => true, ));
try {
$xml = '
<ns1:sendObject>
<arg0>
<content>
<entry>
<key>1</key>
<value>
<![CDATA[
<table width="600">
<tr>
<td>
<font size="2" face="Arial">Our powerful algorithms already found a matching profile that matches your criteria:
<br>Celina72 </font>
<img src="http://mypath/to/my/image.gif" width="50" height="50" border="0" />
</td>]]>
</value>
</entry>
</content>
<dyn>
<entry>
<key>FIRSTNAME</key>
<value>john</value>
</entry>
</dyn>
<email>johann*******#gmail.com</email>
<encrypt>*********************</encrypt>
<notificationId>**************</notificationId>
<random>**********************</random>
<senddate>2008-12-12T00:00:00</senddate>
<synchrotype>NOTHING</synchrotype>
<uidkey>EMAIL</uidkey>
</arg0>
</ns1:sendObject>
';
$args = array(new SoapVar($xml, XSD_ANYXML));
$res = $client->__soapCall('sendObject', $args);
//return $res;
}
catch (SoapFault $e) {
echo "Error: {$e}";
}
echo "<hr>Last Request";
echo "<pre>", htmlspecialchars($client->__getLastRequest()), "</pre>";
echo "<hr>Last Response";
echo "<pre>", htmlspecialchars($client->__getLastResponse()), "</pre>";
?>
it s important to write the first node like this : <ns1:sendObject>
<api:sendObject> does not work
Related
Im trying to use PHP's SimpleXMLElement to parse a YouTube channel feed and include the description. I can do this easily to get the title and video url.
Here is what I have that can get the descriptions
$channel_id = 'UCtNjkMLQQOX251hjGqimx2w';
$yt_url = 'https://www.youtube.com/feeds/videos.xml?channel_id=';
$xml_str = file_get_contents($yt_url.$channel_id);
$xml = new SimpleXMLElement($xml_str);
$xml->registerXPathNamespace('prefix', 'http://www.w3.org/2005/Atom');
$result = $xml->xpath("//media:description");
foreach($result as $r){
print $r;
print '<br />';
}
The Raw xml from YouTube looks something like this.
<entry>
<id>yt:video:OTYFJaT-Glk</id>
<yt:videoId>OTYFJaT-Glk</yt:videoId>
<yt:channelId>UCtNjkMLQQOX251hjGqimx2w</yt:channelId>
<title>Guitar E.R. - Setting up wood shop for O Positive custom speaker cabinets.</title>
<link rel="alternate" href="https://www.youtube.com/watch?v=OTYFJaT-Glk"/>
<author>
<name>Guitar ER</name>
<uri>https://www.youtube.com/channel/UCtNjkMLQQOX251hjGqimx2w</uri>
</author>
<published>2020-10-18T16:38:51+00:00</published>
<updated>2020-10-20T01:04:59+00:00</updated>
<media:group>
<media:title>Guitar E.R. - Setting up wood shop for O Positive custom speaker cabinets.</media:title>
<media:content url="https://www.youtube.com/v/OTYFJaT-Glk?version=3" type="application/x-shockwave-flash" width="640" height="390"/>
<media:thumbnail url="https://i4.ytimg.com/vi/OTYFJaT-Glk/hqdefault.jpg" width="480" height="360"/>
<media:description>In this video Doctor John Moran of Guitar E.R. gives us a glimpse into the new wood shop where he will be building custom guitar and bass cabinets, likely under the name O Positive Cabinets.</media:description>
<media:community>
<media:starRating count="0" average="0.00" min="1" max="5"/>
<media:statistics views="22"/>
</media:community>
</media:group>
</entry>
<entry>
As you can see the title and uri and pretty easy to get, but I'm having trouble combining my code to get the Title, URI and Description.
Here is my code to get the Title and URI
$xml_str = file_get_contents($yt_url.$channel_id);
$xml = new SimpleXMLElement($xml_str);
foreach($xml->entry as $entry){
print $entry->title;
print '<br />';
print $entry->author->uri;
print '<br />';
}
After working on this for awhile I was able to come up with a solution, not sure if this is the best answer though.
<?
$channel_id = 'UCtNjkMLQQOX251hjGqimx2w';
$yt_url = 'https://www.youtube.com/feeds/videos.xml?channel_id=';
$xml_str = file_get_contents($yt_url.$channel_id);
$xml = new SimpleXMLElement($xml_str);
$xml->registerXPathNamespace('prefix', 'http://www.w3.org/2005/Atom');
$yt_data = array();
foreach($xml->entry as $entry){
$videoid = (string)$entry->children('yt', true)->videoId;
$yt_data[] = array(
'id' => $videoid,
'title' => (string)$entry->title,
'description' => (string)$entry->children('media', true)->group->description,
'img' => (string)'https://img.youtube.com/vi/'.$videoid.'/maxresdefault.jpg',
'thumb' => (string)'https://img.youtube.com/vi/'.$videoid.'/mqdefault.jpg',
'published' => (string)$entry->published,
'updated' => (string)$entry->updated,
'channel' => (string)$entry->children('yt', true)->channelId,
'author' => (string)$entry->author->name,
'uri' => (string)$entry->author->uri,
'views' => (string)$entry->children('media', true)->group->community->statistics->attributes()['views'],
'ratings_count' => (string)$entry->children('media', true)->group->community->starRating->attributes()['count'],
'ratings_avg' => (string)$entry->children('media', true)->group->community->starRating->attributes()['average'],
);
}
foreach($yt_data as $yt){
print '<div class="ytVidWrap">';
print '<a href="https://www.youtube.com/watch?v='.$yt['id'].'" target="_blank">';
print '<img src="'.$yt['thumb'].'" alt="YouTube Video" />';
print '<h1>'.$yt['title'].'</h1>';
print '<p>'.$yt['description'].'</p>';
print '<p>'.$yt['views'].' views • '.date('M j, Y',strtotime($yt['published'])).'</p>';
print '</a>';
print '</div>';
}
?>
Hy all!
I try to do DHL Express, but I get caught up very much with DHL not really wanting to help. So I would like to ask for help.
And since I do not get back tracking numbers for anything just underlying XML, so I would like to ask for help. Thank you very much for helping me.
What I try:
// The url of the service
$url = 'https://wsbexpress.dhl.com:443/sndpt/expressRateBook?WSDL';
// the soap operation which is called
$action = 'createShipmentRequest';
// the xml input of the service
$xmlrequest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rat="http://scxgxtt.phx-dc.dhl.com/euExpressRateBook/RateMsgRequest">
<soapenv:Header>
<wsse:Security soapenv:mustunderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:id="UsernameToken-5" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>*********</wsse:Username>
<wsse:Password type="PasswordText">*******</wsse:Password>
<wsse:Nonce encodingtype="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">eUYebYfsjztETJ4Urt8AJw==</wsse:Nonce>
<wsu:Created>' . date('Y-m-d H:i:s') . '</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
<soapenv:Header/>
<soapenv:Body>
<rat:RateRequest>
<RequestedShipment>
<DropOffType>REGULAR_PICKUP</DropOffType>
<Account>407194546</Account>
<Currency>EUR</Currency>
<UnitOfMeasurement>SI</UnitOfMeasurement>
<Ship>
<Shipper>
<StreetLines>Street number 22</StreetLines>
<City>City</City>
<PostalCode>111111</PostalCode>
<CountryCode>DE</CountryCode>
</Shipper>
<Recipient>
<StreetLines>Street number 22</StreetLines>
<City>City</City>
<PostalCode>111111</PostalCode>
<CountryCode>DE</CountryCode>
</Recipient>
</Ship>
<Packages>
<RequestedPackages number="1">
<Weight>
<Value>0.5</Value>
</Weight>
<Dimensions>
<Length>3</Length>
<Width>2</Width>
<Height>1</Height>
</Dimensions>
</RequestedPackages>
</Packages>
<ShipTimestamp>2018-07-18T08:00:00 GMT+0100</ShipTimestamp>
<Content>NON_DOCUMENTS</Content>
<PaymentInfo>DAP</PaymentInfo>
</RequestedShipment>
</rat:RateRequest>
</soapenv:Body>
</soapenv:Envelope>';
try {
// the soap client accepts options, we specify the soap version
// The trace option enables tracing of request so faults can be backtraced.
// The exceptions option is a boolean value defining whether soap errors throw exceptions of type SoapFault.
$opts = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$options = array(
'encoding' => 'UTF-8',
'verifypeer' => false,
'verifyhost' => false,
'soap_version' => SOAP_1_2,
'trace' => 1,
'exceptions' => 1,
'connection_timeout' => 180,
'stream_context' => stream_context_create($opts),
'cache_wsdl' => WSDL_CACHE_NONE,
);
// create the soapclient and invoke __doRequest method
$client = new SoapClient($url, $options);
$output = $client->__doRequest($xmlrequest, $url, $action, 1);
} catch (SoapFault $fault) {
echo "<h2>SOAP Fault!</h2><p>";
echo "FaultCode: {$fault->faultcode} <br/>";
echo "FaultString: {$fault->faultstring} <br/>";
echo"</p/>";
}
echo "<h2>WSDL URL: </h2><p>";
echo $url;
echo "</p/>";
echo "<h2>Action: </h2><p>";
echo $action;
echo "</p/>";
echo "<h2>XMLRequest: </h2><p>";
echo $xmlrequest;
echo "</p/>";
if (!isset($output)) {
echo "<h2>SOAP Fault!</h2><p>";
echo "FaultCode: {$output->faultcode} <br/>";
echo "FaultString: {$output->faultstring} <br/>";
} else {
echo "<h2>Output: </h2><p>";
file_put_contents('dhl.xml', $output);
echo $output;
echo "</p/>";
}
Return: https://justpaste.it/52zqa (sorry too long)
The question is what do I get to get this xml?
Not returning the shipment number and returning the corresponding data
I think you are getting an WSDL because your URL is asking for it. Try removing the ?WSDL:
$url = 'https://wsbexpress.dhl.com:443/sndpt/expressRateBook';
References:
How to get the wsdl file from a webservice's URL
SOAP request returned wsdl instead of expected SOAP response
Our SOAP request doesn't work because it seems that SOAP is converting our XML string into < and >
$client = new SoapClient("https://some-test-url/xxx.asmx?wsdl", array('trace' => true) );
$soapparams = array (
"UserName" => 'uname',
"Password" => 'pword',
"GroupID" => 1,
"xmlstring" => '
<![CDATA[
<DocumentElement>
<tbl>
<var1>Q</var1>
<var2>W</var2>
<var3>E</var3>
</tbl>
</DocumentElement>
]]>
'
);
$response = $client->__soapCall('functionHere', array($soapparams));
$raw_request_header = $client->__getLastRequestHeaders();
$raw_request_body = $client->__getLastRequest();
$raw_response_body = $client->__getLastResponse();
echo "<br /><br />Raw Request: ";
echo "<code>";
print htmlentities($raw_request_body);
echo "</code>";
Im getting this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
<SOAP-ENV:Body>
<ns1:functionHere>
<ns1:UserName>uname</ns1:UserName>
<ns1:Password>pword</ns1:Password>
<ns1:GroupID>1</ns1:GroupID>
<ns1:xmlstring>
<![CDATA[
<DocumentElement>
<tbl>
<var1>Q</var1>
<var2>W</var2>
<var3>E</var3>
</tbl>
</DocumentElement>
]]>
</ns1:xmlstring>
</ns1:functionHere>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
How can I prevent this to happen? I hope someone can help us with this.
I'm trying to pass a fairly complex parameter string which I have an XML example of and I'm trying to encode it properly using PHP. The example request I was given is this:
<?xml version="1.0" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body xmlns:tns="http://172.16.53.121/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://www.amtrak.com/TrainStatus/2006/01/01" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsdns1="http://www.amtrak.com/schema/2006/01/01" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<TrainStatusRQ xmlns="http://www.amtrak.com/schema/2006/01/01" xmlns:ota="http://www.opentravel.org/OTA/2003/05" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="1.0" EchoToken="TestToken">
<POS>
<ota:Source>
<ota:RequestorID Type="WAS" ID="ToBeProvidedByAmtrak">
<ota:CompanyName CompanyShortName="ToBeProvidedByAmtrak"/>
</ota:RequestorID>
</ota:Source>
</POS>
<TrainStatusInfo TrainNumber="3">
<TravelDate>
<ota:DepartureDateTime>2006-01-07</ota:DepartureDateTime>
</TravelDate>
<Location LocationCode="KNG"/>
</TrainStatusInfo>
</TrainStatusRQ>
</SOAP-ENV:Body>
And I'm going to call it use it like this
try
{
$client = new SoapClient($soapURL, $soapOptions);
$trainStatus = $client->processTrainStatus($TrainStatusRQ);
var_dump($trainStatus);
//var_dump($client->__getTypes());
}
catch(SoapFault $e)
{
echo "<h2>Exception Error!</h2></b>";
echo $e->faultstring;
}
Its the encoding of $TrainStatusRQ that I cant seem to figure out since there are attributes and multilevel parameters. This is as close as I have gotten.
$RQStruc = array(
"POS" => array(
"Source"=> array(
"RequestorID" => array(
'type'=>'WAS',
'ID'=>'0',
'CompanyName'=>array(
'CompanyShortName'=>"0"
)
)
)
),
"TrainStatusInfo" => array(
'TrainNumber'=>$TrainNumber,
'TravelDate' => array(
'DepartureDateTime' => array(
'_' => $today
)
),
"Location" => array(
'LocationCode'=>$LocationCode
)
)
);
$TrainStatusRQ = new SoapVar($RQStruc, XSD_ANYTYPE, "TrainStatusRQ","http://www.amtrak.com/schema/2006/01/01" );
I had similar problems when dealing with a .NET service.
What I ended up with was assembling the structure as plain string.
$p = array();
foreach ($items as $item) {
$p[] = "
<MyEntity class='entity'> // the attribute was required by .NET
<MyId>{$item->SomeID}</MyId>
<ItemId>{$item->ItemId}</ItemId>
<Qty>{$item->Qty}</Qty>
</MyEntity>";
}
$exp = implode("\n", $p);
$params['MyEntity'] = new \SoapVar("<MyEntity xmlns='http://schemas.microsoft.com/dynamics/2008/01/documents/MyEntity'>$exp</MyEntity>", XSD_ANYXML);
Worked without problems.
Passing in the XML as a string with XSD_ANYXML as the type was the answer. I also needed to leave out the third and fourth parameters in the SoapVar() function call.
$XML = '<TrainStatusRQ xmlns="http://www.amtrak.com/schema/2006/01/01" xmlns:ota="http://www.opentravel.org/OTA/2003/05" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="1.0" EchoToken="TestToken">
<POS>
<ota:Source>
<ota:RequestorID Type="WAS" ID="foo">
<ota:CompanyName CompanyShortName="bat"/>
</ota:RequestorID>
</ota:Source>
</POS>
<TrainStatusInfo TrainNumber="'.$TrainNumber.'">
<TravelDate>
<ota:DepartureDateTime>'.$Today.'</ota:DepartureDateTime>
</TravelDate>
</TrainStatusInfo>
</TrainStatusRQ>';
$TrainStatusRQ = new SoapVar($XML,XSD_ANYXML);
I get the error message : "looks like we got no XML document" .
This is my php script :
<?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);
and this is the result of __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>
and this is how the request should look according to the documentation :
<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>
What am i doing wrong ? Any help is appreciated !
I came across the same problem, I turned to get solution in a different way.
It might not be the best way, but it works.
Source for the solution 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;