我尝试使用SOAP API为iPad应用程序签署PDF文件,我使用特定的图形签名名称每次都覆盖并使用它来签署文档。
对于某些图像,我无法覆盖它,我得到了
“无法创建图形签名90030704”
我必须先从Web应用程序中删除它。
这是我的代码
String signDocumentSignatureType = "http://arx.com/SAPIWS/DSS/1.0/signature-field-create-sign"; // The
String signatureType = "http://arx.com/SAPIWS/DSS/1.0/set-graphic-image";
String wsdlUrl = Settings.wsdlURL();
// // URL to the WSDL file
try {
// Read file contents
FileInputStream docInputStream = new FileInputStream(filePath);
byte[] fileBuffer = new byte[(int) docInputStream.getChannel().size()];
docInputStream.read(fileBuffer);
docInputStream.close();
// Set file contents + MIME type (the SOAP library automatically
// base64 encodes the data)
DocumentType document = new DocumentType();
Base64Data base64Data = new Base64Data();
base64Data.setValue(fileBuffer);
base64Data.setMimeType(fileMimeType);
document.setBase64Data(base64Data);
// Set user credentials. In case of Active Directory, the domain
// name should be defined in the NameQualifier attribute
ClaimedIdentity claimedIdentity = new ClaimedIdentity();
NameIdentifierType nameIdentifier = new NameIdentifierType();
nameIdentifier.setValue(username);
nameIdentifier.setNameQualifier(domain);
CoSignAuthDataType coSignAuthData = new CoSignAuthDataType();
coSignAuthData.setLogonPassword(password);
claimedIdentity.setName(nameIdentifier);
claimedIdentity.setSupportingInfo(coSignAuthData);
// Define signature field settings
SAPISigFieldSettingsType sigFieldSettings = new SAPISigFieldSettingsType();
sigFieldSettings.setInvisible(false);
sigFieldSettings.setX(sigX);
sigFieldSettings.setY(sigY);
sigFieldSettings.setWidth(sigWidth);
sigFieldSettings.setHeight(sigHeight);
sigFieldSettings.setPage(sigPageNum);
sigFieldSettings.setAppearanceMask(appearanceMask);
TimeDateFormatType timeDateFormat = new TimeDateFormatType();
timeDateFormat.setTimeFormat(timeFormat);
timeDateFormat.setDateFormat(dateFormat);
timeDateFormat.setExtTimeFormat(ExtendedTimeFormatEnum.GMT);
sigFieldSettings.setTimeFormat(timeDateFormat);
// Set the Graphic Image
GraphicImageType sigImage = new GraphicImageType();
sigImage.setDataFormat(Integer.valueOf(8).longValue());
sigImage.setGraphicImageName("iPadSignature");
sigImage.setImageType(GraphicImageTypeEnum.GRAPHIC_IMAGE);
sigImage.setGraphicImage(signatureImage);
// Specify the newly created image as the one to use
ArrayOfConfValueType confValArray = new ArrayOfConfValueType();
ConfValueType confVal = new ConfValueType();
confVal.setConfValueID(ConfIDEnum.GR_SIG_PREF_NAME);
confVal.setStringValue("iPadSignature");
confValArray.getConfValue().add(confVal);
//optInputs.setConfigurationValues(confValArray);
// Build complete request object
SignRequest signRequest = new SignRequest();
RequestBaseType.InputDocuments inputDocuments = new RequestBaseType.InputDocuments();
inputDocuments.getTransformedDataOrDocumentHashOrOther().add(document);
RequestBaseType.OptionalInputs optionalInputs = new RequestBaseType.OptionalInputs();
optionalInputs.setSignatureType(signatureType);
optionalInputs.setClaimedIdentity(claimedIdentity);
optionalInputs.setSAPISigFieldSettings(sigFieldSettings);
optionalInputs.setReturnPDFTailOnly(true);
optionalInputs.setGraphicImageToSet(sigImage);
optionalInputs.setConfigurationValues(confValArray);
signRequest.setOptionalInputs(optionalInputs);
signRequest.setInputDocuments(inputDocuments);
// Initiate service client
DSS client = new DSS(new URL(wsdlUrl), new QName("http://arx.com/SAPIWS/DSS/1.0/", "DSS"));
Common.logInfo("DSS client initiated");
// Send the create signature request
DssSignResult response = client.getDSSSoap().dssSign(signRequest);
// Check response output
if ("urn:oasis:names:tc:dss:1.0:resultmajor:Success".equals(response.getResult().getResultMajor())) {
// On success- Change the request type to sign Document.
Common.logInfo("Signaure image created");
optionalInputs.setSignatureType(signDocumentSignatureType);
// Send the signing request
response = client.getDSSSoap().dssSign(signRequest);
Common.logInfo("get response for signing the doc");
if ("urn:oasis:names:tc:dss:1.0:resultmajor:Success".equals(response.getResult().getResultMajor())) {
// On success- append signature object to the source PDF
// document (the SOAP library automatically decodes the
// base64 encoded output)
Common.logInfo("doc signed successfully");
byte[] signatureObjectBuffer = response.getSignatureObject().getBase64Signature().getValue();
Common.logInfo("write to filepath-->" + filePath);
FileOutputStream fos = new FileOutputStream(filePath, true);
fos.write(signatureObjectBuffer);
fos.close();
}
} else {
Common.logInfo("Error creating signature image");
Common.logInfo("Error-->" + response.getResult().getResultMessage().getValue());
Common.logInfo("Error to String-->" + response.getResult().getResultMinor());
return null;
}
答案 0 :(得分:2)
来自SAPI docs:
0x90030704 - 已存在具有相同名称的图形图像 用户帐户或具有相同名称的签名字段 存在于文件中。
不应覆盖图形签名。如果您希望为该图像使用相同的名称,则必须先删除旧图像。