0

Web サービスを呼び出すと、正常に接続され、そのメソッドも返されますが、この関数の 1 つを呼び出すと、不正なエラーが発生します。

私のコードはここにあります

try { 
$service = new SoapClient("http://www.go-to-orbit.com/oos/solo/soapServer.php?wsdl");

$header = new SoapHeader('http://oncore.qubitwebtechnologies.com/', 'AuthorisationHeader', array('login' => "ONCORE",'password' => "ONCORE"), false);
$service->__setSoapHeaders(array($header));   

var_dump($service->__getFunctions());

$response = $service->__soapCall("getAllOnHand", array() );
}
catch (Exception $e)
{
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}

print_r($response);

結果は

    array(2) { [0]=> string(18) "Map getAllOnHand()" [1]=> string(33) "int getOnHand(string $partNumber)" } Caught exception: Unauthorized 

私はこれを2日間試しましたが、うまくいきませんでした。誰か助けてください。

エラーメッセージ

Exception object(SoapFault)#4 (9) { ["message":protected]=> string(12) "Unauthorized" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(47) "/home/qubitweb/public_html/oncore/jumi/soap.php" ["line":protected]=> int(87) ["trace":"Exception":private]=> array(1) { [0]=> array(6) { ["file"]=> string(47) "/home/qubitweb/public_html/oncore/jumi/soap.php" ["line"]=> int(87) ["function"]=> string(10) "__soapCall" ["class"]=> string(10) "SoapClient" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(12) "getAllOnHand" [1]=> array(0) { } } } } ["previous":"Exception":private]=> NULL ["faultstring"]=> string(12) "Unauthorized" ["faultcode"]=> string(6) "Sender" } 
4

1 に答える 1

2
class SOAPStruct
{
    function __construct($user, $pass) 
    {
        $this->username = $user;
        $this->password = $pass;
    }
}

$service = new SoapClient("http://www.go-to-orbit.com/oos/solo/soapServer.php?wsdl");

$auth = new SOAPStruct("ONCORE","ONCORE");

$header = new     SoapHeader("http://oncore.qubitwebtechnologies.com/","AuthHeader",$auth,false); 

$service->__setSoapHeaders($header);   

$response = $service->getAllOnHand();


var_dump( $response );

このコードは現在機能しています。AuthHeader、ユーザー名、パスワードなどの同じキーに値を設定する必要があります。

于 2012-07-27T05:51:31.043 に答える