2013-01-06 69 views
1

我是來自PHP的WS調用的新手。任何人都可以告訴我如何從這個WS中讀取數據。__soapCall - 如何撥打正確的電話?

這裏是我的代碼

$wsdl = "https://test.saljfinans.handelsbanken.se/xml/netxservice.wsdl"; 

$username  = 'user'; 
$password  = 'password'; 
$contractNumber = XXXXXX; 
$orderNumber = '7871'; 
$call = array("contractNumber" => $contractNumber, "orderNumber" => $orderNumber); 


$client = new SoapClient($wsdl, array('cache_wsdl' => WSDL_CACHE_NONE, 'trace' => 1)); 
//var_dump($client->__getFunctions()); 
//var_dump($client->__getTypes()); 



$name = 'namespace'; 
$text = ''; 
$text .= '<authHeaderRequest><credentials><username>'.$username.'</username><password>'.$password.'</password></credentials></authHeaderRequest>'; 
$var = new SoapVar($text, XSD_ANYXML, null, null, null); 
$header = new SoapHeader($name, 'authHeaderRequest', $var); 
$client->__setSoapHeaders($header); 

$response = $client->__soapCall("getInvoiceOrder", array("getInvoiceOrderRequest_t" => $call), null, $header); 

我得到 致命錯誤:未捕獲的SOAPFault異常:[客戶] SOAP的錯誤:編碼:對象有沒有 '要求' 屬性

怎麼辦我打電話給它工作?

回答

0

我現在有一些更多的信息,但我不明白它的工作。我只是得到

請求= soapenv:Server.generalException

class getInvoiceOrder { 
    public $request; 
} 

class getInvoiceOrderRequest_t { 
    public $contractNumber; 
    public $orderNumber; 
} 



ini_set("soap.wsdl_cache_enabled", 0); 
$wsdl = "https://test.saljfinans.handelsbanken.se/xml/netxservice.wsdl"; 

$username  = 'user'; 
$password  = 'password'; 
$contractNumber = 550158; 
$orderNumber = '7871'; 

$params = new getInvoiceOrder(); 
$params->request = new getInvoiceOrderRequest_t; 
$params->request->orderNumber = $orderNumber; 
$params->request->contractNumber = $contractNumber; 
$param[] = $params; 


$client = new SoapClient($wsdl, array('cache_wsdl' => WSDL_CACHE_NONE, 'trace' => 1)); 


$name = 'namespace'; 
$text = ''; 
$text .= '<authHeaderRequest><credentials><username>'.$username.'</username><password>'.$password.'</password></credentials></authHeaderRequest>'; 
$var = new SoapVar($text, XSD_ANYXML, null, null, null); 
$header = new SoapHeader($name, 'authHeaderRequest', $var); 
try { 
    $client->__setSoapHeaders($header); 
} catch(SoapFault $client) { 
    printf("<br/> Request = %s </br>", htmlspecialchars($client->faultcode)); 
    print $client->getMessage(); 
    print $client->getTraceAsString(); 
} 


try { 
    $response = $client->__soapCall("getInvoiceOrder", $param, null, $header); 
} catch(SoapFault $client) { 
    printf("<br/> Request = %s </br>", htmlspecialchars($client->faultcode)); 
    print $client->getMessage(); 
    print $client->getTraceAsString(); 
} 
+0

你設法得到它的工作?因爲我遇到的問題完全一樣:/ – Muqito