Bonjour, je tente d'envoyer un flux XML SOAP en POST à un webservice. Cela fait plusieurs heures que je lutte à trouver la solution....En vain. Voici le code que j'utilise et l'erreur retournée par le serveur.

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
header('POST /admin/wbsContact.asmx HTTP/1.1 Host: xxxxxxxxxxxxxxx Content-Type: text/xml; charset=utf-8 Content-Length:300000 SOAPAction: "http://tempuri.org/ContactCreateUpdate"' );
 
error_reporting(E_ALL);
 
// The POST URL and parameters
$request =  'http://xxxxxxxxxxxxxxxx/admin/wbsContact.asmx?op=ContactCreateUpdate';
 
$postargs = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ContactCreateUpdate xmlns="http://tempuri.org/">
 
      <intPortail_id>347</intPortail_id>
      <ostContact>
        <strContact_idExterne>1</strContact_idExterne>
        <strContact_lastName>test</strContact_lastName>
        <strContact_firstName>test</strContact_firstName>
        <strContact_phone>test</strContact_phone>
        <strContact_mobilePhone>test</strContact_mobilePhone>
        <strContact_eMail>test</strContact_eMail>
        <strContact_idMd5>test</strContact_idMd5>
        <strContact_login>test</strContact_login>
        <strContact_password>test</strContact_password>
        <datContact_birthdate>20/11/1978</datContact_birthdate>
        <bytContact_title>1</bytContact_title>
      </ostContact>
      <ostAddress>
        <intCountry_id>73</intCountry_id>
        <strAddress_address1stLine>test</strAddress_address1stLine>
        <strAddress_address2ndLine></strAddress_address2ndLine>
        <strAddress_city>test</strAddress_city>
        <strAddress_zipCode>test</strAddress_zipCode>
        <strAddress_regionName>FRANCE</strAddress_regionName>
      </ostAddress>
      <intContact_id>0</intContact_id>
      <strLangue>FR</strLangue>
    </ContactCreateUpdate>
  </soap:Body>
</soap:Envelope>'; 
 
// Get the curl session object
$session = curl_init($request);
 
// Set the POST options.
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $postargs);
curl_setopt($session, CURLOPT_HEADER, true);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
 
// Do the POST and then close the session
$response = curl_exec($session);
curl_close($session);
 
// Get HTTP Status code from the response
$status_code = array();
preg_match('/\d\d\d/', $response, $status_code);
 
// Check for errors 
/*
switch( $status_code[0] ) {
	case 200:
		// Success
		break;
	case 503:
		die('Your call to Yahoo Web Services failed and returned an HTTP status of 503. That means: Service unavailable. An internal problem prevented us from returning data to you.');
		break;
	case 403:
		die('Your call to Yahoo Web Services failed and returned an HTTP status of 403. That means: Forbidden. You do not have permission to access this resource, or are over your rate limit.');
		break;
	case 400:
		// You may want to fall through here and read the specific XML error
		die('Your call to Yahoo Web Services failed and returned an HTTP status of 400. That means:  Bad request. The parameters passed to the service did not match as expected. The exact error is returned in the XML response.');
		break;
	default:
		die('Your call to Yahoo Web Services returned an unexpected HTTP status of:' . $status_code[0]);
}*/
 
// Get the XML from the response, bypassing the header
if (!($xml = strstr($response, '<?xml'))) {
	$xml = null;
}
echo $response;

// Output the XML
echo htmlspecialchars($xml, ENT_QUOTES);
//echo $postargs;
?>
Et voici la réponse du serveur:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
HTTP/1.1 100 Continue HTTP/1.1 415 Unsupported Media Type Date: Tue, 13 Jul 2010 15:10:35 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Cache-Control: private Content-Type: application/soap+xml; charset=utf-8 Content-Length: 2
Merci par avance à ceux qui sauront m'éclairer sur ce(s) point(s)