1

如果可能的话,添加一些代码片段。我使用 Java 进行编码。

DSS:我想使用 CoSign Signature Soap API 添加多个图形图像签名,我该如何实现?如果可能的话,添加一些代码片段。

4

1 回答 1

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();
    }
}
于 2014-10-21T09:15:50.033 回答