Java Web services API examples

I all, I am new to SDL LiveContent and am trying to get some examples for JAVA web services API, the docs site lists a few docx and zip files which should be available on the install box tor samples, like SdlTrisoftClient_JavaWcfClient.docx. I am unable to find these, could someone point me in the right direction to get started.

Appreciate any assistance you may provide.

Parents Reply
  • Hi Alex,
    During Step C. Initialize Project, I receive the following error
    [ERROR] Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-4:download-single (download-wcf-wsdl) on project cxfclient: Error handling resource: peer not authenticated
    The errors explained in the guide asks me to refer to section A for resolution.
    Troubleshooting section A, asks me to install a CA certificate. Step 2 in section A, asks me to run the keytool, and perform the following step
     Copy paste the value of this tag in a new file (filename: x509.cer) and save it in “<DIR_CLIENT>/src/main/resources”:
    -----BEGIN CERTIFICATE-----
    <VALUE_OF_THE_ X509CERTIFICATE _TAG>
    -----END CERTIFICATE-----
    While running the keytool, I don't see anything in the command prompt as the tags listed above, begin certification x509.
Children
  • I'm not also sure what the <VALUE_OF_THE_ X509CERTIFICATE _TAG> is.

    What i would try is to use the .cer file you already have from step 1.

    I always work with .cer files with keytool -import

  • Hi Alex,
    I did give that a try, and I continue to get the same peer not authorized error during Initialization.
  • Hi Akheil,

    Lets validate a couple of things.

    Download SSLPoke.class and run this

    java SSLPoke <host> <port>

    This checks if your java environment can validate the certificate supporting an https url on that host. This typically happens when the certificate was issued by a not known issuer such as active directory certificate services or it was a self issued certificate.

    If it doesn't then try to import as word document suggests

    keytool -importcert -trustcacerts -alias <host> -keystore cacerts -file <host>.cer -storepass <password>

    I repeated this steps to try to understand what the document means with

    Copy paste the value of this tag in a new file (filename: x509.cer) and save it in “<DIR_CLIENT>/src/main/resources”:

    But I also can't understand it what is tag

    While reading the rest of the document, I understand that it does exactly the same but for a different keystore. Instead of targeting the java default cacerts, it targets the keystore <DIR_CLIENT>/src/main/resources/encryption.jks 


    As far as I'm concerned you should be able to use the same file. It worked for me and got the encryption.jks

  • Hi Alex,
    After running the keytool command and running SSLPoke, I get the following error.
    sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid
    certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
    at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
    at sun.security.validator.Validator.validate(Unknown Source)
    at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
    at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
    at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
    at sun.security.ssl.Handshaker.processLoop(Unknown Source)
    at sun.security.ssl.Handshaker.process_record(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
    at sun.security.ssl.AppOutputStream.write(Unknown Source)
    at sun.security.ssl.AppOutputStream.write(Unknown Source)
    at SSLPoke.main(SSLPoke.java:31)
    Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
    at java.security.cert.CertPathBuilder.build(Unknown Source)
    ... 16 more
  • Most probably you have multiple java runtime environments. You always have to make sure that you are modifying the correct cacerts file.
    There is even an option to run java with a custom keystore attached.

    As i said, you need to make sure that your java (specific one or all jre) can connect to that https endpoint.
    This is a generic java problem.
  • Hi Alex,
    Thank you, that was the issue, I specified one version of java and now I can compile the Maven Project. Running the TestClient.java now yields the following error:
    WARNING: Interceptor for {docs.oasis-open.org/.../wsdl}SecurityTokenService has thrown exception, unwinding now
    org.apache.cxf.interceptor.Fault: Response was of unexpected text/html ContentType. Incoming portion of HTML stream: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>307 Temporary Redirect</title>
    </head><body>
    <h1>Temporary Redirect</h1>
    <p>The document has moved <a href="www.w3.org/.../p>
    </body></html>