2 回答
TA贡献1863条经验 获得超2个赞
最好不要尝试手动构造 xml。请尝试以下操作:
$url = 'https://webservices.abcb2b.eu/Centric/CS/Trade/csprod/StockService.svc?wsdl';
$username = 'username';
$password = 'pass';
$client = new SoapClient($url, array('trace' => 1, "exception" => 0));
$wssNamespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
$usernameToken = new SoapVar(array(
new SoapVar(array(
new SoapVar($username, XSD_STRING, null, null, 'Username', $wssNamespace),
new SoapVar($password, XSD_STRING, null, null, 'Password', $wssNamespace)
), SOAP_ENC_OBJECT, null, null, 'UsernameToken', $wssNamespace)
), SOAP_ENC_OBJECT, null, null, null, $wssNamespace);
$client->__setSoapHeaders(new SoapHeader($wssNamespace, 'Security', $usernameToken));
try {
$client->GetStock(array(
'request' => array(
'StockRequests' => array(
'StockRequest' => array(
'CustomerNo' => 123,
'Division' => 'AGU_NL',
'Item' => '113504',
'Language' => 'NL',
'Login' => '123',
)
)
)
));
} catch(\SoapFault $e) {
echo '<pre>';
print_r($e->getMessage());
echo '</pre>';
}
- 2 回答
- 0 关注
- 223 浏览
添加回答
举报