__soapCall - 如何拨打正确的电话?

时间:2013-01-06 10:43:49

标签: php soap

我是PHP的WS调用的新手。任何人都可以告诉我如何从这个WS中读取数据。

这是我的代码

$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-ERROR:编码:对象没有'请求'属性

如何调用它?

1 个答案:

答案 0 :(得分:0)

我现在收到了更多信息,但无论如何我都无法工作。我得到了

Request = 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(); 
}