Bonjour.

Je suis actuellement en train de développer un web service en .NET c# avec le système WCF de Microsoft. Ce web service permet notamment de récupérer, en passant un code postal en paramètre, les villes correspondant à ce code postal.

Ce web service devra être utilisé par tous les navigateurs possibles et interprété par tous les langages possibles. D'ou l'utilisation du fichier wsdl.

Malheureusement, en PHP, je n'arrive pas à interpréter les informations récupérées..

je donne les sources pour mieux comprendre :

mon fichier wsdl :

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
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" name="Service1" targetNamespace="http://tempuri.org/">
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://localhost:8080/testCPAlogie?xsd=xsd0" namespace="http://tempuri.org/"/>
<xsd:import schemaLocation="http://localhost:8080/testCPAlogie?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
<xsd:import schemaLocation="http://localhost:8080/testCPAlogie?xsd=xsd2" namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="IService1_getVille_InputMessage">
<wsdl:part name="parameters" element="tns:getVille"/>
</wsdl:message>
<wsdl:message name="IService1_getVille_OutputMessage">
<wsdl:part name="parameters" element="tns:getVilleResponse"/>
</wsdl:message>
<wsdl:message name="IService1_cpVille_InputMessage">
<wsdl:part name="parameters" element="tns:cpVille"/>
</wsdl:message>
<wsdl:message name="IService1_cpVille_OutputMessage">
<wsdl:part name="parameters" element="tns:cpVilleResponse"/>
</wsdl:message>
<wsdl:portType name="IService1">
<wsdl:operation name="getVille">
<wsdl:input wsaw:Action="http://tempuri.org/IService1/getVille" message="tns:IService1_getVille_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IService1/getVilleResponse" message="tns:IService1_getVille_OutputMessage"/>
</wsdl:operation>
<wsdl:operation name="cpVille">
<wsdl:input wsaw:Action="http://tempuri.org/IService1/cpVille" message="tns:IService1_cpVille_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IService1/cpVilleResponse" message="tns:IService1_cpVille_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_IService1" type="tns:IService1">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getVille">
<soap:operation soapAction="http://tempuri.org/IService1/getVille" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="cpVille">
<soap:operation soapAction="http://tempuri.org/IService1/cpVille" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Service1">
<wsdl:port name="BasicHttpBinding_IService1" binding="tns:BasicHttpBinding_IService1">
<soap:address location="http://localhost:8080/testCPAlogie"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
mon code php :

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
<?php
 
if(isset($_POST['codePostal'])){
	$client = new SoapClient("http://localhost:8080/testCPAlogie?wsdl");
	$parameters = array("cp" => $_POST['codePostal']);
	$result = $client->getVille($parameters);
 
}
 
?>
 
<html>
<body>
	<form method="post" action="CodePostal.php">
	<p>Entrez ici le code postal : </p>
	<input type="text" name="codePostal"/>
	<input type="submit" value="Valider" />
</form>
<?php
	if(isset($_POST['codePostal'])){
	//foreach($result as $valeur){
	//	echo $valeur,'<br />';
	//} 
	$res = (string) $result;
	echo $res;
}
?>
</body>
</html>
ma méthode getVille :

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
public List<String> getVille(Int32 cp)
        {
            List<String> villes = new List<String>();
            string connectionString = "Data Source=localhost/PAE;User Id=demoiard;Password=alogie;";
            using (OracleConnection conn = new OracleConnection())
            {
                conn.ConnectionString = connectionString;
                conn.Open();
 
                OracleCommand commande = conn.CreateCommand();
                string sql;
                sql = "SELECT commune FROM zone where C_POSTAL="+cp+"";
                commande.CommandText = sql;
                OracleDataReader reader = commande.ExecuteReader();
                while (reader.Read())
                {
                    String ville = null;
                    ville = Convert.ToString(reader["COMMUNE"]);
 
                    villes.Add(ville);
                }
                if (villes != null)
                {
                    Console.WriteLine("yeah"); 
                }
                return villes.ToList();
            }
        }
clairement, je suis quasiment sûr que c'est le type retourné (ma list<String>) n'est pas interprétable par le php mais je voudrais savoir si il y a une solution pour les lire, savoir si je fais quelque chose de mal ? :p


merci d'avance.