PHP code example of xjtuana / xjtu-webservice

1. Go to this page and download the library: Download xjtuana/xjtu-webservice library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xjtuana / xjtu-webservice example snippets


use Xjtuana\XjtuWs\WebService\WsUserInfo;
use Xjtuana\XjtuWs\WebService\XjtuWebServiceException;

try {

    $userinfo = new WsUserInfo(
        // url of the webservice
        'url',
        // config of the webservice
        [
            'auth' => ...,
        ],
        // options for SoapClient (see: http://php.net/manual/en/soapclient.soapclient.php)
        [
            'compression ' => ....,
            'connection_timeout' => ...., // default connection_timeout = 5
            ...
        ]
    );
    
    $result = $userinfo->getByNetid('netid');
    
} catch(XjtuWebServiceException $e) {
    echo $e->getMessage();
} catch(\SoapFault $e) {
    throw $e;
}

var_dump($result);

[
    'auth' => 'WS_AUTH',
]

    $userinfo->setFilter(['userno'])->getByNetid('netid');
    

[
    'auth' => 'WS_AUTH',
]

[
    'usr' => 'WS_USER',
    'pwd' => 'WS_PASSWORD',
]