1

If possible add some code snippet. I have used Java for coding.

DSS: I would like to add multiple graphical image signature using CoSign Signature Soap API, how can I achieve it? If possible add some code snippet.

Larry K
  • 47,808
  • 15
  • 87
  • 140
mushir2007
  • 25
  • 5

1 Answers1

2

Here is a code sample in Java that demonstrates how to add a graphical signature using 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();
    }
}
Almog G.
  • 817
  • 7
  • 11