Bonjour,

Je dois ouvrir un socket (SSL) chez UPS, afin d'écrire une methode POST permettant l'envois d'un fichier XML.

La méthode POST à l'air de fonctionner (je reçois un message d'erreur en retour comme quoi une entité de mon fichier XML n'est pas correcte), mais ce message s'affiche également si je n'envois pas de fichier XML. Etant donné que je suis certain que ce fichier XML est ok (testé chez UPS), le problème doit survenir pendant la transaction.

Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
$y = fopen("rrep.txt","w"); 
$sXML = $xml_file;
 
$sRtn = '';
 
$this->sUPSURL = 'https://wwwcie.ups.com/ups.app/xml/Return';   
 
// Send the request to UPS via CURL
$ch = curl_init();// initialize a cURL session
 
curl_setopt($ch, CURLOPT_URL, $this->sUPSURL);  // set the post-tourl
 
curl_setopt($ch, CURLOPT_HEADER, 0);// Header control
 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,  0);
 
curl_setopt($ch, CURLOPT_VERBOSE, 1);
 
curl_setopt($ch, CURLOPT_POST, 1);   // tell it to make a POST, nota GET
 
curl_setopt($ch, CURLOPT_POSTFIELDS, $sXML);    // put the query string here
 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    // This allows theoutput to be set into a variable.
curl_setopt($ch, CURLOPT_STDERR, $y);
$sRtn = curl_exec ($ch);// execute the curl session and return the output to a variable.
 
 
curl_close($ch);                                // close the curlsession
 
fclose($y);
La variable $sXML est une string d emon fichier XML.
La valeur de retour, dans mon cas l'erreur est reçue dans $sRtn.

Et le contenu de rep.txt (info sur la transaction) est:
Code x : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
* About to connect() to wwwcie.ups.com:443
* Connected to wwwcie.ups.com (84.53.153.242) port 443
* SSL connection using AES256-SHA
* Server certificate:
*      subject: /CN=wwwcie.ups.com/C=US/ST=New Jersey/L=Mahwah/O=United Parcel Service/OU=UPS Akamai
*      start date: 2006-12-05 17:13:31 GMT
*      expire date: 2007-12-05 17:13:31 GMT
*      common name: wwwcie.ups.com (matched)
*      issuer: /C=US/O=Akamai Technologies Inc/CN=Akamai Subordinate CA 3
> POST /ups.app/xml/Return HTTP/1.1
Host: wwwcie.ups.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Content-Length: 1794
Content-Type: application/x-www-form-urlencoded

MYXML FILE HERE
< Server: Apache/2.0.46 (Red Hat) mod_ssl/2.0.46 OpenSSL/0.9.7a
< Content-Length: 458
< Content-Type: application/xml
< Expires: Tue, 19 Dec 2006 16:16:53 GMT
< Cache-Control: max-age=0, no-cache, no-store
< Pragma: no-cache
< Date: Tue, 19 Dec 2006 16:16:53 GMT
< Connection: keep-alive
* Connection #0 left intact
* Closing connection #0
Je ne sais d'ailleur pas comment interpreter tout ça.

Si quelqu'un a une idée d'ou peut provenir l'erreur, ça serait bienvenue