Thursday, October 10, 2019

[JAVA-SOAP] Customize date type to string in client code


  1. Create a binding file with name common-binding.xjb or whatever with the content bellow
  2. <?xml version='1.0' encoding='UTF-8'?>
      <jaxb:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"
      xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
      jaxb:extensionBindingPrefixes="xjc">
          <jaxb:globalBindings>
              <jaxb:serializable uid="1" />
              <jaxb:javaType name="String" xmlType="xsd:dateTime" />
              <jaxb:javaType name="String" xmlType="xsd:date" />
              <jaxb:javaType name="String" xmlType="xsd:time" />
          </jaxb:globalBindings>
      </jaxb:bindings>
  3. In the pom.xml file, adding a plugin like:
  4.  <plugin>
          <groupId>org.apache.cxf</groupId>
          <artifactId>cxf-codegen-plugin</artifactId>
          <version>${cxf.version}</version>
          <executions>
              <execution>
                  <id>generate-sources</id>
                  <phase>generate-sources</phase>
                  <configuration>
                      <sourceRoot>${basedir}/src/main/java</sourceRoot>
                      <wsdlOptions>
                          <wsdlOption>
                              <wsdl>${basedir}/src/main/resources/wsdl/DynamicsGP.wsdl</wsdl>
                              <wsdlLocation>classpath:wsdl/DynamicsGP.wsdl</wsdlLocation>
                          </wsdlOption>
                      </wsdlOptions>
                      <defaultOptions>
                          <bindingFiles>
                              <bindingFile>${basedir}/src/main/resources/wsdl/common-binding.xjb</bindingFile>
                          </bindingFiles>
                      </defaultOptions>
                  </configuration>
                  <goals>
                      <goal>wsdl2java</goal>
                  </goals>
              </execution>
          </executions>
      </plugin>

[JAVA-SOAP] How to build a client for Microsoft SOAP web service

Microsoft build the SOAP-based web service usually support two types of authentication:

  • NTLM - support both http and https
  • Basic - support https only
So before the web service is published(use https) we have to use NTLM(Windows Kerberos and NT LAN Manager), and this is not supported by any JAVA related SOAP service by default, to do so you have to customize, the below is the code snippet:

Wednesday, May 22, 2019

Jenkins - Installation


  1. Download the war
    wget http://ftp-chi.osuosl.org/pub/jenkins/war/2.161/jenkins.war
  2. Start it
    nohup java -Duser.home=/opt/jenkins/jenkins_home -Duser.timezone=America/Chicago -jar lib/jenkins.war --httpsPort=8080 &
  3. Configure it
    http://localhost:8080
  4. Blue Ocean & Create pipeline
    http://localhost:8080/blue
  5. Create slaves/agents
    Dashboard > Manage Jenkins > Mange Nodes > ....
    The nodes:
    1. can be any type of machine
    2. can be manually activate/inactivate

Tuesday, May 21, 2019

Jenkins - Pipeline Syntax

The Jenkins Pipeline Syntax page (https://jenkins.io/doc/book/pipeline/syntax/)

Agent - specifies where the entire Pipeline, or a specific stage, will execute in the Jenkins environment depending on where the agent section is placed. It support docker and dockerfile in it.

Postdefines one or more additional steps that are run upon the completion of a Pipeline’s or stage’s run (depending on the location of the post section within the Pipeline). post can support any of of the following post-condition blocks: alwayschangedfixedregressionabortedfailuresuccessunstableunsuccessful, and cleanup

Stags - containing a sequence of one or more stage directives.

Steps - the steps section defines a series of one or more steps to be executed in a given stage directive.

Environment - specifies a sequence of key-value pairs which will be defined as environment variables for the all steps, or stage-specific steps, depending on where the environment directive is located within the Pipeline.
environment {
       SERVICE_CREDS = credentials('my-prefined-username-password')
}
Options/Parameters

Triggers - support cron, pollSCM and upstream 
When Pipeline to determine whether the stage should be executed depending on the given condition.

Sequential/Parallel 
pipeline {
    agent any
    options {
        parallelsAlwaysFailFast()
    }
    stages {
        stage('Non-Parallel Stage') {
            steps {
                echo 'This stage will be executed first.'
            }
        }
        stage('Parallel Stage') {
            when {
                branch 'master'
            }
            parallel {
                stage('Branch A') {
                    agent {
                        label "for-branch-a"
                    }
                    steps {
                        echo "On Branch A"
                    }
                }
                stage('Branch B') {
                    agent {
                        label "for-branch-b"
                    }
                    steps {
                        echo "On Branch B"
                    }
                }
            }
        }
    }



Monday, April 29, 2019

Dynamic programming


  • Order/Validate data frame overlaps [Solve problems like plane/airport traffic ]
    1. Order data frame according some rule
    2. Create data points for each start/end of data frame
    3. Order data points
    4. Check with stack, push to stack when it's a start point, pop from stack when it's end point, you can check the number of points in the stack to do your business.

Saturday, April 27, 2019

Stack

The cases we usually need to consider to use stack:

  • We need to compare successive data items, use the peek method to get previous one to compare with current one, then pop up the peek or insert current one the the stack.
  • Usually need to return a consequence which the length is different from the one passed.

  1. Math
    • iterate the array
      • push to stack when it's a number
      • otherwise pop two items to calculate
        ["4", "13", "5", "/", "+"] -> (4 + (13 / 5)) -> 6
  2. dfd

String


  1. Isomorphic String - use a map to mapping each letters in the strings
    Given "egg", "add", return true.
    Given "foo", "bar", return false.
    Given "paper", "title", return true.
  2. Todo...