#!/bin/sh

echo "Pull the latest wsdls before you run below script"

export CLASSPATH=${CLASSPATH}:$AXIS_HOME/lib/axis-ant.jar:$AXIS_HOME/lib/axis.jar:$AXIS_HOME/lib/commons-discovery-0.2.jar:$AXIS_HOME/lib/commons-logging-1.0.4.jar:$AXIS_HOME/lib/jaxrpc.jar:$AXIS_HOME/lib/log4j-1.2.8.jar:$AXIS_HOME/lib/saaj.jar:$AXIS_HOME/lib/wsdl4j-1.5.1.jar;

function gen_client () {
if [[ -d "../src/main/java/com/agilex/healthcare/schedulingmanager/mdws/generatedwsdl/$1" ]] ; then
rm -rf "../src/main/java/com/agilex/healthcare/schedulingmanager/mdws/generatedwsdl/$1"
fi

echo $2.wsdl
wsimport -extension -Xnocompile -XadditionalHeaders -B-XautoNameResolution -s ../src/main/java -p com.agilex.healthcare.schedulingmanager.mdws.generatedwsdl.$1 -keep -wsdllocation META-INF/$2.wsdl "../src/main/resources/META-INF/$2.wsdl"
rm -rf ./com
}

gen_client "emrservice" "EmrSvc"

gen_client "schedulingservice" "SchedulingSvc"

gen_client "queryservice" "QuerySvc"

echo "You must be connected to the MAE VPN in order for this to work."
echo
echo "Here's why we are using wsimport versus something else like wsdl2java"
echo "http://stackoverflow.com/questions/3588616/java-webservice-client-best-way/3590252#3590252"
echo "https://weblogs.java.net/blog/kohsuke/archive/2007/02/jaxws_ri_21_ben.html"

echo
echo
echo

read -p "Finished, press [ENTER] to Exit"
No newline at end of file
