2013-07-10 8 views
0

DocuSign을 사용하여 요청에 전자 서명을 추가하면 모든 것이 잘 작동합니다. 지금은 포함 된 방법을 사용하여 서명 요청을 보내 URL로 이동하여 즉시 워크 플로를 시작합니다. ,임베디드 서명 api docusign

( http://www.docusign.com/?event=Send&envelopeId=168bc155-e013-4ffd-abb4-7608b56647f8),하지만 난 탐색 문서에 서명하려고 URL을 붙여하지만 다른 URL로 저를 리디렉션합니다 whene은 다음과 같습니다

로그인 후

하고 울부 짖는 코드를 실행, 나는 (https://demo.docusign.net/Member/StartInSession.aspx?StartConsole=1&t=32598057-5a59-4d0b-bad8-a8ff8f2407f6&DocuEnvelope=168bc155-e013-4ffd-abb4-7608b56647f8&send=1 임베디드보기)를 얻을

내 enveloppe에 서명하기 위해 어떻게 wotkflow 프로세스를 시작할 수 있습니까 ?? 나는 서명하기위한 나의 엔벨로프를 볼 수 없다.

// 2 단계 - 보낼받는 사람, 문서, 및 탭과 함께 봉투를 만들기 //

String jsonBody = "{\"emailBlurb\":\"partail\"," + 
      "\"emailSubject\":\"API Call for adding signature request to document and sending\"," + 
      "\"documents\":[{" + 
      "\"documentId\":\"1\"," + 
      "\"name\":\"test.pdf\"}]," + 
      "\"recipients\":{" + 
      "\"signers\":[{" + 
      "\"email\":\"" + EmailRecipients + "\"," + 
      "\"name\":\"name\"," + 
      "\"recipientId\":\"1\"," + 
      "\"routingOrder\":\"1\","+ 
      "\"clientUserId\":\"1000\","+    
      "\"tabs\":{" + 
      "\"signHereTabs\":[{" + 
      "\"xPosition\":\"300\"," + 
      "\"yPosition\":\"600\"," + 
      "\"documentId\":\"1\"," + 
      "\"pageNumber\":\"1\"" + "}]}}]}," + 
      "\"status\":\"sent\"}"; 
      //DemandeSign.getenvelope(); 


    File file = new File("D:/test.pdf"); 
    InputStream inputStream = new FileInputStream(file); 
    byte[] bytes = new byte[(int) file.length()]; 
    inputStream.read(bytes); 
    inputStream.close(); 

    String requestBody = "\r\n\r\n--BOUNDARY\r\n" + 
      "Content-Type: application/json\r\n" + 
      "Content-Disposition: form-data\r\n" + 
      "\r\n" + 
      jsonBody + "\r\n\r\n--BOUNDARY\r\n" + // our json formatted request body 
      "Content-Type: application/pdf\r\n" + 
      "Content-Disposition: file; filename=\"test.pdf\"; documentId=1\r\n" + 
      "\r\n"; 
     // we break this up into two string since the PDF doc bytes go here and are not in string format. 
     // see further below where we write to the outputstream... 
    String reqBody2 = "\r\n" + "--BOUNDARY--\r\n\r\n"; 

    // append "/envelopes" to the baseUrl and use in the request 
    conn = (HttpURLConnection)new URL(baseURL + "/envelopes").openConnection(); 
    conn.setRequestMethod("POST"); 
    conn.setDoOutput(true); 
    conn.setRequestProperty("X-DocuSign-Authentication", authenticateStr); 
    conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=BOUNDARY"); 
    conn.setRequestProperty("Content-Length", Integer.toString(requestBody.toString().length())); 
    conn.setRequestProperty("Accept", "application/xml"); 

    // write the body of the request... 
    DataOutputStream dos = new DataOutputStream(conn.getOutputStream()); 
    dos.writeBytes(requestBody.toString()); 
    dos.write(bytes); 
    dos.writeBytes(reqBody2.toString()); 
    dos.flush(); dos.close(); 
    status = conn.getResponseCode(); // triggers the request 
    if(status != 201) // 201 = Created 
    { 
     System.out.println("Error calling webservice, status is: " + status); 
     InputStreamReader isr = new InputStreamReader(conn.getErrorStream()); 
     br = new BufferedReader(isr); 
     StringBuilder error_response = new StringBuilder(); 
     while ((line = br.readLine()) != null) 
      error_response.append(line); 
     System.out.println("Error response is " + error_response.toString()); 
     System.exit(-1); 
    } 
    // Read the response 
    InputStreamReader isr = new InputStreamReader(conn.getInputStream()); 
    br = new BufferedReader(isr); 
    StringBuilder response2 = new StringBuilder(); 
    while ((line = br.readLine()) != null) 
     response2.append(line); 
    //token1 = "//*[1]/*[local-name()='envelopeId']"; 
    //String envelopeId = xPath.evaluate(token1, new InputSource(new StringReader(response2.toString()))); 

    //--- display results 
    //System.out.println("Document sent! envelopeId is " + envelopeId);//envelopeId is e4c0659a-9d01-4ac3-a45f-02a80fd6bd96 at 04/07/2013 17:24 


    token1 = "//*[1]/*[local-name()='uri']"; 
    String uri = xPath.evaluate(token1, new InputSource(new StringReader(response2.toString()))); 
    //--- display results 
    System.out.println("uri = " + uri); 


/// Step3 
// construct another outgoing XML request body 
String reqBody = "<returnUrlRequest xmlns=\"http://www.docusign.com/restapi\">" + 
"<authenticationMethod>email</authenticationMethod>" + 
"<email>***[email protected]***</email>" + 
"<returnUrl>http://www.docusign.com</returnUrl>" + 
"<userName>name</userName>" + 
"<clientUserId>1000</clientUserId>" + 
"</returnUrlRequest>"; 

// append uri + "/views/sender" to the baseUrl and use in the request 
conn = (HttpURLConnection)new URL(baseURL + uri + "/views/sender").openConnection(); 
conn.setRequestMethod("POST"); 
conn.setDoOutput(true); 
conn.setRequestProperty("X-DocuSign-Authentication", authenticateStr); 
conn.setRequestProperty("Content-Type", "application/xml"); 
conn.setRequestProperty("Content-Length", Integer.toString(reqBody.length())); 
conn.setRequestProperty("Accept", "application/xml"); 
// write the body of the request... 
dos = new DataOutputStream(conn.getOutputStream()); 
dos.writeBytes(reqBody); dos.flush(); dos.close(); 
status = conn.getResponseCode(); // triggers the request 
if(status != 201) // 201 = Created 
{ 
System.out.println("Error calling webservice, status is: " + status); 
System.exit(-1); 
} 
// Read the response 
isr = new InputStreamReader(conn.getInputStream()); 
br = new BufferedReader(isr); 
StringBuilder response3 = new StringBuilder(); 
while ((line = br.readLine()) != null) 
response3.append(line); 
token1 = "//*[1]/*[local-name()='url']"; 
//--- display results 
System.out.println("Embedded View: " + xPath.evaluate(token1, new InputSource(new StringReader(response3.toString()))));` 

답변

0

즉시 URL에 액세스하려고하거나 전혀 기다리고 있습니까? 주어진 토큰에 액세스하기 위해 URL 토큰을 생성하면 TTL (수명 시간)이 5 분으로 5 분 후에 만료되고 새로운 것을 생성해야합니다.

그렇지 않은 경우 수신자를 식별하는 방법과 관련된 문제 일 수 있습니다. DocuSign의 수신자는 name, email, recipientId 및 embedding의 경우 clientUserId의 고유 한 조합으로 식별됩니다. 모든 것을 설정 한 것처럼 보이지만 처음 엔 봉투를 만들 때 어떤 조합이든간에 포함 된 URL 토큰을 요청할 때 동일한 조합을 참조해야합니다.

봉투를 만들 때 문자 그대로 "이름"으로 설정하고 "EmailRecipients"라는 변수를 통해 이메일을 설정한다는 것을 알았습니다. 하지만 "[email protected]"이메일을 사용중인 URL 토큰을 요청하면 문제가 발생할 수도 있습니다.

관련 문제