Consommer un web service C# avec un client PHP
Bonjour à tous,
j'ai écrit un service web en c# que voici:
Code:
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
|
using System;
using System.Web.Services;
namespace WebService1
{
/// <summary>
/// Description résumée de Service1
/// </summary>
[WebService(Namespace = "http://www.smarty.com")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public int Somme(int a, int b)
{
return a + b;
}
}
} |
j'ai aussi écrit un client php dont voici le code:
Code:
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
|
<?php
$d = $_POST['val1'];
$g = $_POST['val2'];
echo $d."<br />";
echo $g."<br />";
ini_set("soap.wsdl_cache_enabled", "0");
try{
$wsdl = "http://localhost:1090/Service1.asmx?WSDL";
$clientSOAP = new SoapClient($wsdl);
echo $clientSOAP->Somme($d,$g);
/*
*
renvoie Erreur
Catchable fatal error: Object of class stdClass could not be
converted to string in C:\wamp\www\php\traitement.php on line 18
**/
echo "le resultat est :";
/*
*
renvoie Erreur toujours 1
**/
$res = $clientSOAP->Somme($d,$g);
echo "le resultat est :" + $res;
}
catch(SoapFault $e){
echo "Code erreur :" + $e->faultcode + "," + $e->faultstring + "";
}
?> |
en appelant le service web dans mon fichier php,
j'ai cette erreur :
Citation:
Catchable fatal error: Object of class stdClass could not be converted to string in C:\wamp\www\php\traitement.php on line 18
alors que quand je teste le service web dans visual studio(afficher le service web dans le navigateur tout
se passe très bien).
merci d'avance.