nuSOAP problem
Hej eksperterHar dette her script som kobler op imod en SOAP server.
Problemet er, at den server jeg bruger ikke har PHP 5 installeret og dermed ikke SOAP extensions.
Jeg har så istedet brugt nuSoap, men problemet er at jeg får denne fejl:
Fatal error: Call to undefined function: __dorequest() in /hsphere/local/home/mettecar/mettecarus.dk/soap.php on line 97
Dvs. at nuSoap åbenbart ikke understøtter "__dorequest()". Hvilken kommando skal jeg evt. bruge istedet?
Her er mit script:
<?php
// phpinfo();
// Include the SOAP classes
require_once($HTTP_SERVER_VARS['DOCUMENT_ROOT']."/nuSoap/lib/nusoap.php");
function XMLtoArray($XML) {
print 'test1';
$xml_parser = xml_parser_create();
xml_parse_into_struct($xml_parser, $XML, $vals);
xml_parser_free($xml_parser);
$_tmp='';
foreach ($vals as $xml_elem){
print 'test2';
$x_tag=$xml_elem['tag'];
$x_level=$xml_elem['level'];
$x_type=$xml_elem['type'];
if ($x_level!=1 && $x_type == 'close') {
if (isset($multi_key[$x_tag][$x_level]))
$multi_key[$x_tag][$x_level]=1;
else
$multi_key[$x_tag][$x_level]=0;
}
if ($x_level!=1 && $x_type == 'complete') {
if ($_tmp==$x_tag)
$multi_key[$x_tag][$x_level]=1;
$_tmp=$x_tag;
}
}
foreach ($vals as $xml_elem){
$x_tag=$xml_elem['tag'];
$x_level=$xml_elem['level'];
$x_type=$xml_elem['type'];
if ($x_type == 'open')
$level[$x_level] = $x_tag;
$start_level = 1;
$php_stmt = '$xml_array';
if ($x_type=='close' && $x_level!=1)
$multi_key[$x_tag][$x_level]++;
while($start_level < $x_level){
$php_stmt .= '[$level['.$start_level.']]';
if (isset($multi_key[$level[$start_level]][$start_level]) && $multi_key[$level[$start_level]][$start_level])
$php_stmt .= '['.($multi_key[$level[$start_level]][$start_level]-1).']';
$start_level++;
}
$add='';
if (isset($multi_key[$x_tag][$x_level]) && $multi_key[$x_tag][$x_level] && ($x_type=='open' || $x_type=='complete')){
if (!isset($multi_key2[$x_tag][$x_level]))
$multi_key2[$x_tag][$x_level]=0;
else
$multi_key2[$x_tag][$x_level]++;
$add='['.$multi_key2[$x_tag][$x_level].']';
}
if (isset($xml_elem['value']) && trim($xml_elem['value'])!='' && !array_key_exists('attributes',$xml_elem)){
if ($x_type == 'open')
$php_stmt_main=$php_stmt.'[$x_type]'.$add.'[\'content\'] = $xml_elem[\'value\'];';
else
$php_stmt_main=$php_stmt.'[$x_tag]'.$add.' = $xml_elem[\'value\'];';
eval($php_stmt_main);
}
if (array_key_exists('attributes',$xml_elem)){
if (isset($xml_elem['value'])){
$php_stmt_main=$php_stmt.'[$x_tag]'.$add.'[\'content\'] = $xml_elem[\'value\'];';
eval($php_stmt_main);
}
foreach ($xml_elem['attributes'] as $key=>$value){
$php_stmt_att=$php_stmt.'[$x_tag]'.$add.'[$key] = $value;';
eval($php_stmt_att);
}
}
}
return $xml_array;
}
function payment($cardnumber, $expiremonth, $expireyear, $cvc, $orderid, $amount){
$wsdl ='https://ssl.ditonlinebetalingssystem.dk/remote/subscription.asmx?WSDL';
$client = new SoapClient($wsdl);
$xml .='<?xml version="1.0" encoding="utf-8"?>';
$xml .=' <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
$xml .=' <soap:Body>';
$xml .=' <authorizePayment xmlns="https://ssl.ditonlinebetalingssystem.dk/remote/">';
$xml .=' <cardnumber>'.$cardnumber.'</cardnumber>';
$xml .=' <expiremonth>'.$expiremonth.'</expiremonth>';
$xml .=' <expireyear>'.$expireyear.'</expireyear>';
$xml .=' <cvc>'.$cvc.'</cvc>';
$xml .=' <orderid>'.$orderid.'</orderid>';
$xml .=' <amount>'.$amount.'</amount>';
$xml .=' <currency>208</currency>';
$xml .=' <instantcapture>1</instantcapture>';
$xml .=' <test>0</test>';
$xml .=' <merchantnumber>88888888</merchantnumber>';
$xml .=' </authorizePayment>';
$xml .=' </soap:Body>';
$xml .=' </soap:Envelope>';
$action = "https://ssl.ditonlinebetalingssystem.dk/remote/authorizePayment";
$resultset = $client->__doRequest($xml, $wsdl, $action, null);
$results = XMLtoArray($resultset);
unset($client);
print $results;
return $results['SOAP:ENVELOPE']['SOAP:BODY']['AUTHORIZEPAYMENTRESPONSE'];
}
print 'tester<bR>';
ECHO payment('5555555555555000', '12', '2012', '113', '12', '100')
?>