How to pass xsi type of parameter in PHP SoapClient

758 Views Asked by At

I am trying to consume soapclient based API of https://developer.signicat.com/documentation/signing/get-started-with-signing/full-flow-example/

There are tow methods of it 1- you have to upload a document and it returns you an SDS ID, this part works fine

2- then you need to use this SDS ID in second part of API to create a sign request method name is createRequest(),

This is where I am getting problem, I have passed all the parameters but still getting an error on one parameter which is xsi:type I am not sure how to pass this parameter from php array.

Here is the sample XML

 <document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ref-sds-id="090520195vbxk9uuw4dks9tjm2pmpy7sx3na397xz6qclxtepaslnb00q7" send-to-archive="false" xsi:type="sds-document">
                        <sign-text-entry/>
                        <description>Loan contract.pdf</description>
                    </document>

here xsi:type="sds-document" this part is causing the issue

My Code:

    $url = 'https://preprod.signicat.com/ws/documentservice-v3?wsdl';

    $soap_setting = array(
            "trace" => 1,  

            'features' => SOAP_SINGLE_ELEMENT_ARRAYS + SOAP_USE_XSI_ARRAY_TYPE 
        );


    $client = new SoapClient($url,$soap_setting);


    $subject_type = $client->__getTypes();
    $functions = $client->__getFunctions();



    $subject = array(
        'national-id'=> '198003010306',
        'first-name'  => 'Oskar',
        'last-name'   => 'Johansson',
        'email'       => '[email protected]'
    );

    $notification = array(
        'recipient' => 'http://localhost/sign/php/',
        'type' => 'URL',
        'message' => 'Please seign ${taskUrl}',
        'header'=> 'Test',
        'notification-id' => '001'
    );
    $sdsdocument = array(
        'ref-sds-id' => '100520193oz5vev0onyueul43ury4vz8g1hsnhr7w69pcwnoan96ojbtbb',
        'send-to-archive' => true,
        'description'=> 'test',
        'sign-text-entry'=> 'test',
        'xsi:type' => 'sds-document'

    );
    $documentaction = array(
        'document'=> $sdsdocument,

        'type'=> 'sign',
        'optional'=> true,
        'send-result-to-archive'=> true
    );
    $tasks = array(
        'subject'=> $subject,
        'document-action'=> $documentaction,
        'notification'=> $notification,
        'on-task-postpone'=> 'http://localhost/sign/php/?requestId=${requestId}&taskId=${taskId}&status=taskpostponed',
        'on-task-complete'=> 'http://localhost/sign/php/?requestId=${requestId}&taskId=${taskId}&status=taskcomplete',
        'on-task-cancel'=> 'http://localhost/sign/php/?requestId=${requestId}&taskId=${taskId}&status=taskcancelled',
        'configuration'=> 'default',
        'signature' =>array('method'=>'nbid-sign'),
        'id'=> 'task00001',
        'bundle'=> False
    );

    $request = array(
        'language'=> 'en',
        'task'=> $tasks
    );



    $tparam = array(
        'service'=>'demo',
        'password'=>'Bond007',
        'request' =>$request
    );


    $create = $client->createRequest($tparam);
    echo '<pre>';
    print_r($create);
    echo $client->__getLastRequestHeaders();
    echo '</pre>';

The Error I am getting: Fatal error: Uncaught SoapFault exception: [soap:Client] Failed to register new document action request: Document with id null must have subtype archive-document, sds-document, result-document, upload-document or provided-document

0

There are 0 best solutions below