2

我正在测试 Docusign PHP API 并尝试以下代码:

$envelopeId = '3e979aac-1d8d-4ab9-rand-envelopid';

    $api = new APIService();
    $api->setCredentials('devaccountemail', 'devaccountpassword');

    $userName = 'Test Signer';
    $userEmail = 'random@randor.com';
    $userId = '457';

    $RequestRecipientTokenParams = new RequestRecipientToken();
    $RequestRecipientTokenParams->EnvelopeID = $envelopeId;
    $RequestRecipientTokenParams->Username = $userName;
    $RequestRecipientTokenParams->Email = $userEmail;
    $RequestRecipientTokenParams->ClientUserID = $userId;

    $RequestRecipientTokenParams->AuthenticationAssertion->AssertionID = rand(0, 999);
    $RequestRecipientTokenParams->AuthenticationAssertion->AuthenticationInstant = date("Y")."-".date("m")."-".date("d")."T00:00:00.00";
    $RequestRecipientTokenParams->AuthenticationAssertion->AuthenticationMethod = RequestRecipientTokenAuthenticationAssertionAuthenticationMethod::Email;
    $RequestRecipientTokenParams->AuthenticationAssertion->SecurityDomain = "local IP Address";


    $RequestRecipientTokenParams->ClientURLs->OnAccessCodeFailed = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnAccessCodeFailed";
    $RequestRecipientTokenParams->ClientURLs->OnCancel = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnCancel";
    $RequestRecipientTokenParams->ClientURLs->OnDecline = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnDecline";
    $RequestRecipientTokenParams->ClientURLs->OnException = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnException";
    $RequestRecipientTokenParams->ClientURLs->OnFaxPending = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnFaxPending";
    $RequestRecipientTokenParams->ClientURLs->OnIdCheckFailed = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnIdCheckFailed";
    $RequestRecipientTokenParams->ClientURLs->OnSessionTimeout ="https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnSessionTimeout";
    $RequestRecipientTokenParams->ClientURLs->OnSigningComplete = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnSigningComplete";
    $RequestRecipientTokenParams->ClientURLs->OnTTLExpired = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnTTLExpired";
    $RequestRecipientTokenParams->ClientURLs->OnViewingComplete = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnViewingComplete";

    $RequestRecipientTokenResponse = $api->RequestRecipientToken($RequestRecipientTokenParams);

我收到以下错误:

SoapFault : One or both of Username and Password are invalid.

我提供的凭据是有效的,我可以使用这些凭据登录 demo.docusign.net 帐户。我不确定我在哪里做错了。

这是正在生成的 SOAP 请求:

<?xml version="1.0" encoding="UTF-8"?> 
    <SOAP-ENV:Envelope xmlns:SOAP-
     ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.docusign.net/API/3.0" 
     xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
         <SOAP-ENV:Header>
            <wsa:Action>http://www.docusign.net/API/3.0/RequestRecipientToken</wsa:Action>
            <wsa:To>https://www.docusign.net/API/3.0/api.asmx</wsa:To>
            <wsa:MessageID>uudi:638fd49c-2516-12a9-8159-17a9c602975e</wsa:MessageID>
            <wsa:ReplyTo>
                <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
            </wsa:ReplyTo>
            <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" SOAP-ENV:mustUnderstand="1">
                <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                    <wsu:Created>2013-09-18T12:30:20Z</wsu:Created>
                    <wsu:Expires>2013-09-18T12:35:20Z</wsu:Expires>
                </wsu:Timestamp>
                <wsse:UsernameToken>
                    <wsse:Username>bhargav.bonu@somedomain.com</wsse:Username>
                    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-
         token-profile-1.0#PasswordText">mypassword</wsse:Password>
                    <wsse:Nonce>0PZkAUVbHHiyjV8KZrN6x2x0S6cQ5WbAjTH4yn8dnc4=</wsse:Nonce>
                    <wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-
         utility-1.0.xsd">2013-09-18T12:29:18Z</wsu:Created>
                </wsse:UsernameToken>
            </wsse:Security>
        </SOAP-ENV:Header>
        <SOAP-ENV:Body>
            <ns1:RequestRecipientToken>
            <ns1:EnvelopeID>3e979aac-1d8d-4ab9-a45c-randElem</ns1:EnvelopeID>
            <ns1:Username>Test Signer</ns1:Username>
            <ns1:Email>Guest</ns1:Email>
            <ns1:AuthenticationAssertion>
                <ns1:AssertionID>175</ns1:AssertionID>
                <ns1:AuthenticationInstant>2013-09-18T00:00:00.00</ns1:AuthenticationInstant>
                <ns1:AuthenticationMethod>Email</ns1:AuthenticationMethod>
                <ns1:SecurityDomain>192.168.0.43</ns1:SecurityDomain></ns1:AuthenticationAssertion>
                <ns1:ClientURLs>
                    <ns1:OnSigningComplete>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&amp;event=OnSigningComplete</ns1:OnSigningComplete>
                    <ns1:OnViewingComplete>https://YourApp.com/DocuSignCallback.html?
         envelopeId=YourEnvelopeId&amp;event=OnViewingComplete</ns1:OnViewingComplete>
                    <ns1:OnCancel>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&amp;event=OnCancel</ns1:OnCancel>
                    <ns1:OnDecline>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&amp;event=OnDecline</ns1:OnDecline>
                    <ns1:OnSessionTimeout>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&amp;event=OnSessionTimeout</ns1:OnSessionTimeout>
                    <ns1:OnTTLExpired>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&amp;event=OnTTLExpired</ns1:OnTTLExpired>
                    <ns1:OnException>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&amp;event=OnException</ns1:OnException>
                    <ns1:OnAccessCodeFailed>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&amp;event=OnAccessCodeFailed</ns1:OnAccessCodeFailed>
                    <ns1:OnIdCheckFailed>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&amp;event=OnIdCheckFailed</ns1:OnIdCheckFailed>
                    <ns1:OnFaxPending>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&amp;event=OnFaxPending</ns1:OnFaxPending>
                </ns1:ClientURLs>
            </ns1:RequestRecipientToken>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
4

2 回答 2

3

该错误表明您在请求中提供的用于对 API 调用进行身份验证的 DocuSign 用户凭据无效。您在这篇文章中包含的代码实际上是无关紧要的,因为如果您提供的用于验证请求的用户名或密码无效,任何 API 调用都会导致此错误。

如果您还没有这样做,我建议您对完整的 XML 请求(即,包括标头)进行跟踪,以仔细检查您在请求中提供的身份验证凭据。解决此类问题的最佳方法是检查线路上发生了什么(而不是尝试解决产生线路上的问题的代码)——一旦确定了 XML 中的问题,它应该很容易在代码。

于 2013-09-17T14:36:50.113 回答
1

关于“用户名或密码无效”错误 - 这可能是由于您未在用户名中包含您的集成密钥。从 DocuSign SOAP API 指南的第 18 页 ( http://www.docusign.com/sites/default/files/DocuSignAPI_Guide.pdf ):

集成商密钥必须放在 UsernameToken 的 Username 节点中的用户 ID 前面。积分器密钥必须用方括号“[ 和 ]”括起来。示例格式:

<wsse:Username>[Integrator Key]2988541c-4ec7-4245-b520-f2d324062ca3</wsse:Username>

Integrator Key 必须包含在所有 API 请求中,因为 DocuSign 需要它来识别集成应用程序。

于 2013-09-18T16:00:39.580 回答