如果可能,请添加一些代码段。我使用Java进行编码。
DSS:我想使用CoSign Signature Soap API添加多个图形图像签名,我该如何实现?如果可能,请添加一些代码段。
答案 0 :(得分:2)
以下是Java中的代码示例,演示了如何使用CoSign Signature SOAP API添加图形签名:
public static void AddGraphicalImage(String username, String domain, String password, byte[] imageBuffer, String imageName) throws Exception {
try {
SignRequest request = new SignRequest();
RequestBaseType.OptionalInputs optInputs = new RequestBaseType.OptionalInputs();
// Set signature type
optInputs.setSignatureType("http://arx.com/SAPIWS/DSS/1.0/set-graphic-image");
// Set user credentials
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);
optInputs.setClaimedIdentity(claimedIdentity);
// Set graphical image data
GraphicImageType graphicImage = new GraphicImageType();
graphicImage.setGraphicImage(imageBuffer);
graphicImage.setDataFormat(Long.valueOf(6)); //JPG
graphicImage.setGraphicImageName(imageName);
optInputs.setGraphicImageToSet(graphicImage);
request.setOptionalInputs(optInputs);
// Initiate service client
DSS client = new DSS(new URL("https://prime.cosigntrial.com:8080/sapiws/dss.asmx"));
// Send the request
DssSignResult response = client.getDSSSoap().dssSign(request);
// Check result
String errmsg = "" + response.getResult().getResultMajor();
if (errmsg.compareTo("urn:oasis:names:tc:dss:1.0:resultmajor:Success") == 0) {
System.out.println("Graphical image was added successfully!");
return;
}
else {
throw new Exception(response.getResult().getResultMessage().toString());
}
}
catch (Exception e) {
System.out.println("Error: " + e.getMessage());
e.printStackTrace();
}
}