2015-04-05 53 views
1

我嘗試使用SOAP API爲iPad應用程序簽名PDF文件,我使用特定的圖形簽名名稱來覆蓋每次並使用它來簽署文檔。錯誤覆蓋簽名圖像

對於一些圖片,我不能覆蓋它,我得到 「無法創建圖形簽名90030704」
我必須首先從Web應用程序中刪除。 這裏是我的代碼

String signDocumentSignatureType = "http://arx.com/SAPIWS/DSS/1.0/signature-field-create-sign"; // The 
 
\t \t String signatureType = "http://arx.com/SAPIWS/DSS/1.0/set-graphic-image"; 
 
\t \t String wsdlUrl = Settings.wsdlURL(); 
 
\t \t \t \t \t \t \t \t \t \t \t // // URL to the WSDL file 
 

 
\t \t try { 
 
\t \t \t // Read file contents 
 
\t \t \t FileInputStream docInputStream = new FileInputStream(filePath); 
 
\t \t \t byte[] fileBuffer = new byte[(int) docInputStream.getChannel().size()]; 
 
\t \t \t docInputStream.read(fileBuffer); 
 
\t \t \t docInputStream.close(); 
 

 
\t \t \t // Set file contents + MIME type (the SOAP library automatically 
 
\t \t \t // base64 encodes the data) 
 
\t \t \t DocumentType document = new DocumentType(); 
 
\t \t \t Base64Data base64Data = new Base64Data(); 
 
\t \t \t base64Data.setValue(fileBuffer); 
 
\t \t \t base64Data.setMimeType(fileMimeType); 
 
\t \t \t document.setBase64Data(base64Data); 
 

 
\t \t \t // Set user credentials. In case of Active Directory, the domain 
 
\t \t \t // name should be defined in the NameQualifier attribute 
 
\t \t \t ClaimedIdentity claimedIdentity = new ClaimedIdentity(); 
 
\t \t \t NameIdentifierType nameIdentifier = new NameIdentifierType(); 
 
\t \t \t nameIdentifier.setValue(username); 
 
\t \t \t nameIdentifier.setNameQualifier(domain); 
 
\t \t \t CoSignAuthDataType coSignAuthData = new CoSignAuthDataType(); 
 
\t \t \t coSignAuthData.setLogonPassword(password); 
 
\t \t \t claimedIdentity.setName(nameIdentifier); 
 
\t \t \t claimedIdentity.setSupportingInfo(coSignAuthData); 
 

 
\t \t \t // Define signature field settings 
 
\t \t \t SAPISigFieldSettingsType sigFieldSettings = new SAPISigFieldSettingsType(); 
 
\t \t \t sigFieldSettings.setInvisible(false); 
 
\t \t \t sigFieldSettings.setX(sigX); 
 
\t \t \t sigFieldSettings.setY(sigY); 
 
\t \t \t sigFieldSettings.setWidth(sigWidth); 
 
\t \t \t sigFieldSettings.setHeight(sigHeight); 
 
\t \t \t sigFieldSettings.setPage(sigPageNum); 
 
\t \t \t sigFieldSettings.setAppearanceMask(appearanceMask); 
 
\t \t \t 
 
\t \t \t 
 
\t \t \t 
 
\t \t \t TimeDateFormatType timeDateFormat = new TimeDateFormatType(); 
 
\t \t \t timeDateFormat.setTimeFormat(timeFormat); 
 
\t \t \t timeDateFormat.setDateFormat(dateFormat); 
 
\t \t \t timeDateFormat.setExtTimeFormat(ExtendedTimeFormatEnum.GMT); 
 
\t \t \t 
 
\t \t \t sigFieldSettings.setTimeFormat(timeDateFormat); 
 

 
\t \t \t // Set the Graphic Image 
 
\t \t \t GraphicImageType sigImage = new GraphicImageType(); 
 

 
\t \t \t sigImage.setDataFormat(Integer.valueOf(8).longValue()); 
 
\t \t \t sigImage.setGraphicImageName("iPadSignature"); 
 
\t \t \t sigImage.setImageType(GraphicImageTypeEnum.GRAPHIC_IMAGE); 
 
\t \t \t sigImage.setGraphicImage(signatureImage); 
 
\t \t \t 
 
\t \t \t // Specify the newly created image as the one to use 
 
\t \t \t 
 
\t \t \t ArrayOfConfValueType confValArray = new ArrayOfConfValueType(); 
 
\t \t \t ConfValueType confVal = new ConfValueType(); 
 
\t \t \t confVal.setConfValueID(ConfIDEnum.GR_SIG_PREF_NAME); 
 
\t \t \t confVal.setStringValue("iPadSignature"); 
 
\t \t \t confValArray.getConfValue().add(confVal); 
 
\t \t \t 
 
\t \t \t //optInputs.setConfigurationValues(confValArray); 
 

 
\t \t \t // Build complete request object 
 
\t \t \t SignRequest signRequest = new SignRequest(); 
 
\t \t \t RequestBaseType.InputDocuments inputDocuments = new RequestBaseType.InputDocuments(); 
 
\t \t \t inputDocuments.getTransformedDataOrDocumentHashOrOther().add(document); 
 
\t \t \t RequestBaseType.OptionalInputs optionalInputs = new RequestBaseType.OptionalInputs(); 
 
\t \t \t optionalInputs.setSignatureType(signatureType); 
 
\t \t \t optionalInputs.setClaimedIdentity(claimedIdentity); 
 
\t \t \t optionalInputs.setSAPISigFieldSettings(sigFieldSettings); 
 
\t \t \t optionalInputs.setReturnPDFTailOnly(true); 
 
\t \t \t optionalInputs.setGraphicImageToSet(sigImage); 
 
\t \t \t optionalInputs.setConfigurationValues(confValArray); 
 
\t \t \t 
 
\t \t \t 
 
\t \t \t 
 
\t \t \t signRequest.setOptionalInputs(optionalInputs); 
 
\t \t \t signRequest.setInputDocuments(inputDocuments); 
 

 
\t \t \t // Initiate service client 
 

 
\t \t \t DSS client = new DSS(new URL(wsdlUrl), new QName("http://arx.com/SAPIWS/DSS/1.0/", "DSS")); 
 
\t \t \t Common.logInfo("DSS client initiated"); 
 
\t \t \t // Send the create signature request 
 
\t \t \t DssSignResult response = client.getDSSSoap().dssSign(signRequest); 
 

 
\t \t \t // Check response output 
 
\t \t \t if ("urn:oasis:names:tc:dss:1.0:resultmajor:Success".equals(response.getResult().getResultMajor())) { 
 
\t \t \t \t // On success- Change the request type to sign Document. 
 
\t \t \t \t Common.logInfo("Signaure image created"); 
 
\t \t \t \t 
 
\t \t \t \t optionalInputs.setSignatureType(signDocumentSignatureType); 
 

 
\t \t \t \t // Send the signing request 
 
\t \t \t \t response = client.getDSSSoap().dssSign(signRequest); 
 
\t \t \t \t Common.logInfo("get response for signing the doc"); 
 
\t \t \t \t if ("urn:oasis:names:tc:dss:1.0:resultmajor:Success".equals(response.getResult().getResultMajor())) { 
 
\t \t \t \t \t // On success- append signature object to the source PDF 
 
\t \t \t \t \t // document (the SOAP library automatically decodes the 
 
\t \t \t \t \t // base64 encoded output) 
 
\t \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t Common.logInfo("doc signed successfully"); 
 
\t \t \t \t \t byte[] signatureObjectBuffer = response.getSignatureObject().getBase64Signature().getValue(); 
 
\t \t \t \t \t Common.logInfo("write to filepath-->" + filePath); 
 
\t \t \t \t \t FileOutputStream fos = new FileOutputStream(filePath, true); 
 
\t \t \t \t \t fos.write(signatureObjectBuffer); 
 
\t \t \t \t \t fos.close(); 
 
\t \t \t \t } 
 
\t \t \t } else { 
 
\t \t \t \t Common.logInfo("Error creating signature image"); 
 
\t \t \t \t Common.logInfo("Error-->" + response.getResult().getResultMessage().getValue()); 
 
\t \t \t \t Common.logInfo("Error to String-->" + response.getResult().getResultMinor()); 
 
\t \t \t \t return null; 
 
\t \t \t }

回答

2

SAPI docs

0x90030704 - 具有相同名稱的 已經存在的用戶帳戶,或與簽名域的圖形圖像同名文件中已存在 。

圖形簽名不應該被覆蓋。如果您希望爲該圖像使用相同的名稱,則必須先刪除舊圖像。

+0

在API中它說它可以被覆蓋。它確實如此。 但在某些情況下不是。 90%的覆蓋時間,其餘5%表示該名稱已經存在。 任何想法爲什麼? – 2015-04-08 07:02:50

+0

正確。只使用SOAP API,圖形簽名可以被覆蓋。你能否給我提供一個圖像的例子,給你這個錯誤? – 2015-04-12 08:19:58