Welcome Guest, Not a member yet? Register   Sign In
Problems testing free WebService WSDL using PHP soap functions
#1

[eluser]CARP[/eluser]
Hi
I'm trying to make a test for a webservice. I've found a free webservice for weather information, but I can't make it work. I have to make it work through a proxy, but I guess this time proxy is working, because the errors I get are not related to it

I have this code in my soap/index controller

Code:
try
        {            
            $url = 'http://www.webservicex.net/globalweather.asmx?WSDL';
            $conn_params = array(
                'proxy_host' => '10.2.0.1',
                'proxy_port' => '6588'
            );
            $serv_params = array(
                'CityName' => 'San Juan',
                'CountryName' => 'Argentina'
            );
            $client = new SoapClient($url, $conn_params);
            $client->__soapCall('GetWeather', $serv_params);
        }
        catch (Exception $e) {
            echo "Error!<br />";
            echo $e -> getMessage ();
        }

I'm getting all these errors

Quote:Error!
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---&gt; System.Data.SqlClient.SqlException: Procedure or function 'getWeather' expects parameter '@CountryName', which was not supplied. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at WebServicex.GlobalWeather.GetWeather(String CityName, String CountryName) --- End of inner exception stack trace ---

Does any1 know what I'm doing badly? Am I sending or calling the functions in bad way?

Thanks
#2

[eluser]Jelmer[/eluser]
I'm no expert, but isn't this the most important part:
Quote:System.Data.SqlClient.SqlException: Procedure or function ‘getWeather’ expects parameter ‘@CountryName’, which was not supplied.
Maybe you need to include the @ sign with the variable names?
#3

[eluser]CARP[/eluser]
Yes, tried adding @ with the parameter, but no luck

EDIT: This code worked (without proxy. Gotta test behing proxy)

Code:
$url = 'http://www.webservicex.net/globalweather.asmx?WSDL';
        $conn_params = array(
            'proxy_host' => '10.2.0.1',
            'proxy_port' => '6588'
        );
        $ser_params = array (
            'GetWeather' => array (
                "CityName" => "San Juan",
                "CountryName" => "Argentina"
            )
        );        
        
        //$client = new SoapClient($url);
        $client = new SoapClient($url);
        $result = $client->__soapCall('GetWeather', $ser_params);
        print_r ($result);

I've only changed the $ser_params array, and included a sub_array

Hope this can be useful for others




Theme © iAndrew 2016 - Forum software by © MyBB