Catchable fatal error: Object of class stdClass could not be converted to string

0

Good morning brothers!

I have a webService in C # and I want to consume it with PHP but when I load it I get this error.

Catchable fatal error: Object of class stdClass could not be converted to string

I leave my code, thank you very much!

<?php

require("nusoap/lib/nusoap.php");
  // Llamada al WebService
  $wsdl ="http://192.168.1.1:8081/MyWebService.asmx?WSDL";
  $client = new SoapClient($wsdl);
  $result = $client->Saludo();
  $xml = $result;
  // procesar xml
  $xml = simplexml_load_string($xml->$result);
  print_r($xml);
?>

The return of the webService would be a greeting only.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

/// <summary>
/// Summary description for MyWebService
/// </summary>
[WebService(Namespace = "http://tempuraxs.mx/webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class MyWebService : System.Web.Services.WebService
{

    public MyWebService()
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string Saludo()
    {
        return "Has creado tu servicio web";
    }

}
    
asked by Ed Brennenburg 01.11.2018 в 16:52
source

1 answer

0

I used the nuSoap library and brought the webservice as silk.

Greetings!

<?php

    require("nusoap/lib/nusoap.php"); //libreria para acceder webservices
      // Llamada al WebService
      $wsdl ="http://192.168.1.1:8081/MyWebService.asmx?WSDL"; //Es el xml que te generó tu servicio 
      $client = new nusoap_client($wsdl,true); //se hace la isntancia de cliente nuSoap
      $result = $client->call('Saludo'); //ahi le decimos  que metodo del webservice va a ejecutar
      // procesar xml
      var_dump($result); //proporciona información de la variable
      echo $result['SaludoResult']; //imprimimos el resultado del webservice
    ?>
    
answered by 01.11.2018 в 17:37