views:

53

answers:

1

I have a simple ASP .NET web service running and I want call it from a php client. I m using nusoap soap client.

The following is the client side php code:

<?php
require_once('lib/nusoap.php');       
$wsdl="http://localhost:64226/Service1.asmx?wsdl";
$client=new soapclient($wsdl, 'wsdl');  
$param=array('number1'=>'2', 'number2'=>'3');
echo $client->call('add',$param);
?>

The web methods I have created in web service are as follows:

namespace WebService3
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{

    [WebMethod]
    public string HelloWorld()
    {
        return "Hello World";
    }

    [WebMethod]
    public string add(int x, int y)
    {
        int z = x + y;
        return z.ToString();
    }
}
}

However when I run the above php code it does not return the added value of the passed parameters. Instead it previews the word 'Arrays'

I m not experienced in php programming. Am I doing something wrong the above codes? Need a quick solution to resolve this and invoke the web service from php.

Thanks in advance !

A: 

Substitute this line

echo $client->call('add',$param);

by this one

echo $client->__soapCall('add', $param);

See also this question.

Artefacto
when I substitute with $client->__soapCall('add', $param) it gives the following error : Call to undefined method soapclient::__soapCall()
chathuradd
@chathuradd Oh, I thought you were using the SoapClient bundled with PHP. In that case, refer to the documentation of your soap library.
Artefacto
Now I m using SoapClient bundled with php and I managed to get it working :) but using a different code:class Addition{ public $x = 12; public $y = 20; } $client = new SoapClient('http://localhost:64226/Service1.asmx?wsdl');$result = $client->add(new Addition());echo $result->addResult; But still __soapCall function that you have mentioned does not work probably due to some error in parameter passing which I could not figure out exactly.
chathuradd