SYRACUSE WS Unauthorized error

SUGGESTED

Hi 

I'm trying to use X3 V12 webservices from PHP application, below the code I used to save a new order : 

$soapclient=new SoapClient($wsdl, $options);
    $callContext = array('codeLang'=>$code_lang, 'codeUser'=>$username, 'password'=>$password, 'poolAlias'=>$pool_alias, 'requestConfig'=>$REQUEST_CONFIG);                        
    $response = $soapclient->__soapCall('save', array($callContext, $publicname, $xmlInput),   array( 'uri' => 'http://www.adonix.com/WSS', 'soapaction' => ''));
I got this error : SoapFault: Unauthorized in ....
The username used have super admin rights, and I can run the same WS from X3 tester without any problems. Please help !!!
  • 0
    SUGGESTED

    After tons of research, I found the solution, 

    I Have to add credentials in option object, as shown below : 

    $options = [
            'cache_wsdl'     => WSDL_CACHE_NONE,
            'trace'          => 1,
            'stream_context' => stream_context_create(
                [
                    'ssl' => [
                        'verify_peer'       => false,
                        'verify_peer_name'  => false,
                        'allow_self_signed' => true
                    ]
                ]
            ),
            'login'          => $username,
            'password'       => $password
        ];
    then create a new object with options : 
    $soapclient=new SoapClient($wsdl, $options);
    but you have to get rid of the credentials in call contaxt object : 
    $callContext = array('codeLang'=>$code_lang, 'poolAlias'=>$pool_alias, 'requestConfig'=>$REQUEST_CONFIG);  
    Hope this will help people in my situation.