我正在尝试从php调用WCF服务。当我调用php页面时,调用AuthorizeCard方法时会出现Not found错误。我通过调用$ client-> __ getFunctions()验证了该方法的存在。我认为这可能与服务调用需要具有下面定义的属性的.net ChargeDetails对象这一事实有关。因此,在尝试一组值时,我也尝试使用$ container / stdClass(),我在另一个stackoverflow上找到了关于如何模仿.net类的答案。任何想法,为什么我会收到此错误或stdClass是如何通过一个版本的ChargeDetails类?
<?php
define('NEWLINE', "<br />\n");
class SoapClientNG extends \SoapClient{
public function __doRequest($req, $location, $action, $version = SOAP_1_1,$one_way=0){
$xml = explode("\r\n", parent::__doRequest($req, $location, $action, $version, 0));
print_r($xml);
$response = preg_replace( '/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', "", $xml[5] );
return $response;
}
}
$client = new SoapClientNG("https://www.oururl.com/api/CreditCardProcessingPhp.svc?wsdl", array('cache_wsdl' => 0));
try{
$container = new stdClass();
$container->request->CardExpirationDate = '06/18';
$container->request->CardNumber = '1411111111111111';
$container->request->CardVerificationNumber = '123';
$container->request->ChargeAmount = '10';
$container->request->ChargeComment = 'Test charge';
$card = array(
'CardExpirationDate' => '01/18',
'CardNumber' => '1411111111111111',
'CardVerificationNumber' => '123',
'ChargeAmount' => '10',
'ChargeComment' => 'Test charge'
);
//$functions = $client->__getFunctions ();
//var_dump ($functions);
$webService = $client->AuthorizeCard($card);
}
catch (Exception $e){
print($client->__getLastResponse());
exit();
}
$client = null;
?>