简体   繁体   中英

calling asp.net parameterized web service method form php

I'm trying to consume an ASP.Net web service using a php client. The asp method recieves parameters and returns a value based on it.

This is my client.php code:

require_once 'nusoap.php'; 
$wsdl="http://localhost:49642/New_Flex_WebService/php.asmx?WSDL";
$client = new nusoap_client($wsdl, true);
$cars = array("hi", "hello");
//$result=$client->call('TestMethod');
$result = $client->call->TestMethod($cars);
print_r ($shortened);

This is my asmx page code:

[WebMethod]
public string TestMethod(string Param1, string Param2)
{
   return Param1 + " " + Param2;
}

According the Calling An ASMX Web Service From Different Languages article, you have to provide names for the calling this way:

$cars = array("Param1" => "hi", "Param2" => "hello");
//$result=$client->call('TestMethod');
$result = $client->call->TestMethod($cars);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM