1

我是来自 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 异常:[Client] SOAP-ERROR: Encoding: object has not 'request' property

如何调用它?

4

1 回答 1

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(); 
}
于 2013-01-08T08:20:26.497 回答