This exercice is to call a web service with the X509 certificate.

The web service is PlatformIntegrationConsumerTest. The documentation is available on http://soa.smals.be/registry/uddi/bsc/web/browse/serviceDetail?serviceKey=uddi:be:fgov:rsz:platformintegrationconsumertest:v1.

Add dependency

The SOA team provide a client jar for each web service.

<dependency>

  <groupId>be.smals.serviceclient</groupId>

  <artifactId>serviceclient-platformintegrationconsumertest</artifactId>

  <version>1.1.0</version>

</dependency>


And I add the API jboss for the web service.


<dependency>

  <groupId>org.jboss.ws</groupId>

  <artifactId>jbossws-api</artifactId>

  <version>1.0.3.Final</version>

  <scope>provided</scope>

</dependency>

URL management

For an application, you have the different values for test, acceptation and production.

You can put this value in .openshift/config/hellostco-system-dev.properties.

The URL of the web service is http://soa.smals.be/registry/uddi/bsc/web/browse/serviceDetail?serviceKey=uddi:be:fgov:rsz:platformintegrationconsumertest:v1.

Add in properties file :

url.platformintegrationconsumertest = https://professionalservices-int.socialsecurity.be/PlatformIntegrationConsumerTest/v1

properties

This variable is loaded by jboss when the server start.properties jboss

And you can use this key in your  web.xml.

<env-entry>

  <env-entry-name>ws.platformintegrationconsumertest.endpointaddress</env-entry-name>

  <env-entry-type>java.lang.String</env-entry-type>

  <env-entry-value>${url.platformintegrationconsumertest}</env-entry-value>

</env-entry>


Security

You must use a p12 certificate. This certificate is different per environment.

For local and test, you must use this \\port-stco\share\OpenshiftAdvanced. 

p12

Add the configuration in the resources-dev.yaml.

keyStores:

  - type: PKCS12

    filename: trainings-hellostpih-app-dev.p12

    keystorepassword: password

    alias: security:hellopih

    privatekeypassword: password

    description:

    client-config-name: hellopih-Client-Config

Call web service

Add a call of the web service in SayingBean.

@Resource(name= "ws.platformintegrationconsumertest.endpointaddress")

String endpointAddressPlatformIntegrationConsumerTest;

 

...

private PlatformIntegrationConsumerTestPortType getPort() {

        if (platformIntegrationConsumerTestPortType == null) {

            try {

 

                URL wsdlUrl = getClass().getResource("/META-INF/be/socialsecurity/platformintegrationconsumertest/v1/PlatformIntegrationConsumerTest-v1.wsdl");

                QName serviceQname = new QName("http://socialsecurity.be/platformintegrationconsumertest/v1", "PlatformIntegrationConsumerTestService");

                PlatformIntegrationConsumerTestService service = new PlatformIntegrationConsumerTestService(wsdlUrl, serviceQname);

                PlatformIntegrationConsumerTestPortType port = service.getPlatformIntegrationConsumerTestSOAP11(new ClientConfigFeature(null, "hellopih-Client-Config", true));

                ((BindingProvider) port).getRequestContext().put(ENDPOINT_ADDRESS_PROPERTY, endpointAddressPlatformIntegrationConsumerTest);

                platformIntegrationConsumerTestPortType = port;

 

            } catch (Exception e) {

                this.logger.error("Exception while initializing PlatformIntegrationConsumerTestPortType", e);

                throw new RuntimeException("Exception while initializing PlatformIntegrationConsumerTestPortType", e);

            }

 

        }

 

        return platformIntegrationConsumerTestPortType;

 

    }

 

    public String saying() {

 

        IntegrationTestMessage integrationMessage = new IntegrationTestMessage();;

        integrationMessage.setMessage("trainings openshfift X609 call test");

        XMLGregorianCalendar now = getCurrentTimestamp();

 

        integrationMessage.setTimestamp(now);

        IntegrationTestMessage response = null;

 

        try {

            response = getPort().checkAccessControl(integrationMessage);

 

        } catch (SystemError e) {

            this.logger.error("Exception while calling PlatformIntegrationConsumerTestPortType", e);

            throw new RuntimeException("Exception while calling PlatformIntegrationConsumerTestPortType", e);

        }

 

        return "message from soa integration test ws: " + response.getMessage();

 

    }

 

    /**

     * @return

     */

    private XMLGregorianCalendar getCurrentTimestamp() {

        GregorianCalendar gregorianCalendar = new GregorianCalendar();

        DatatypeFactory datatypeFactory;

        XMLGregorianCalendar now = null;

 

        try {

            datatypeFactory = DatatypeFactory.newInstance();

            now = datatypeFactory.newXMLGregorianCalendar(gregorianCalendar);

 

        } catch (DatatypeConfigurationException e) {

            this.logger.error("Exception while getCurrentTimestamp", e);

            throw new RuntimeException("Exception while getCurrentTimestamp", e);

        }

        return now;

    }




Local setup Jboss

In local JBoss, you must use the mavenplugins-dockerrun to copy the file (p12, properties and yaml).





Last modified: Monday, 4 September 2017, 2:47 PM