I would like to use php to call a c# webmethod but it's unsuccessful - why?
try {
$client = new SoapClient($VerifyUser);
$params = array(
'Merchant_id' => $tbl_result['tbl_merchant']['data'][0]->Merchant_id,
'Merchant_code' => $tbl_result['tbl_merchant']['data'][0]->Merchant_code
);
$response = $client->VerifyUser(
array(
'Merchant_id'=>$tbl_result['tbl_merchant']['data'][0]->Merchant_id
)
)->VerifyUserResult;
} catch (Exception $e) {
print_r($e->getMessage());
}
////////////// C#
[WebMethod]
public static string VerifyUser(string Merchant_id)
{
return "";
}
There is an error as below:
Function ("VerifyUser") is not a valid method for this service
Now i change to below:
$clsUser = array( 'xxx' => 'xxx' );
$urlWebService = "xxx.asmx?WSDL";
$response = WebSoapClient("VerifyUser", $urlWebService, $clsUser);
function WebSoapClient($function ,$url, $data = array() ) {
$response = null;
try {
$client = new SoapClient($url);
$response = $client->__soapCall( $function, $data );
} catch (Exception $e) {
ErrorLog("WebSoapClient->". $function . " - " . $e->getMessage());
}
return $response;
}
/C#
[WebMethod]
public string VerifyUser(clsUser clsUser) {
//xxx...
}
but in C# param is null...