如何在PHP SoapClient

时间:2019-05-10 10:40:30

标签: php xml soap soap-client soapfault

我正在尝试使用https://developer.signicat.com/documentation/signing/get-started-with-signing/full-flow-example/的基于soapclient的API

有两种方法 1-您必须上传一个文档,它会返回一个SDS ID,这部分工作正常

2-然后您需要在API的第二部分中使用此SDS ID来创建签名请求方法,名称为createRequest(),

这是我遇到的问题,我已经传递了所有参数,但仍然在xsi:type的一个参数上遇到错误,我不确定如何从php数组传递此参数。

这是示例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>

此处xsi:type =“ sds-document”这是导致问题的原因

我的代码:

    $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'       => 'kamran@creativerays.com'
    );

    $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>';

我得到的错误: 致命错误:未捕获的SoapFault异常:[soap:Client]无法注册新文档操作请求:ID为null的文档必须具有子类型存档文档,sds文档,结果文档,上载文档或提供的文档

0 个答案:

没有答案
相关问题