有人可以帮我吗,过去1周来我一直在努力工作,我找不到任何解决方案。我在使用Soap客户端调用函数时遇到此错误使用方法“ GetProductByPartNo”的错误,具有errorCode测试“ HTTP” 。它正在使用我们的安全性。希望有人能帮助我。 谢谢你们
<?php
class WsseAuthHeader extends SoapHeader
{
private $wss_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
function __construct($user, $pass, $ns = null) {
if ($ns) {
$this->wss_ns = $ns;
}
$auth = new stdClass();
$auth->Username = new SoapVar($user, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
$auth->Password = new SoapVar($pass, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
$username_token = new stdClass();
$username_token->UsernameToken = new SoapVar($auth, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns);
$security_sv = new SoapVar(
new SoapVar($username_token, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns),
SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'Security', $this->wss_ns);
parent::__construct($this->wss_ns, 'Security', $security_sv, true);
}
}
try {
$wsse_header = new WsseAuthHeader('user', 'password');
$x = new SoapClient('http://example.com/Service/CTOProduct.svc?wsdl', array("trace" => 1, "exception" => 0, 'soap_version' => SOAP_1_2));
$x->__setSoapHeaders(array($wsse_header));
} catch(Exception $e) {
exit("SoapClient Error \"".$e->getMessage()."\"");
}
if(!empty($x)) {
try {
$response = $x->__soapCall("GetProductByPartNo", array("2014",true));
var_dump($response);
} catch (SoapFault $e) {
exit("Error using Method \"GetProductByPartNo\" having errorCode test \"".$e->faultcode."\"");
}
}`enter code here`
?>