<?xml version="1.0" encoding="UTF-8"?>

<!-- ======================================================================= -->
<!-- eXist build file : Axis SOAP                                            -->
<!-- ======================================================================= -->

<project basedir="../.." name="Axis SOAP">

    <description>Build Axis SOAP interface</description>

    <target name="wsdl2java">
        <mkdir dir="${build.soap}"/>
        <delete failonerror="no" file="${build.soap}/org/exist/soap/AdminSoapBindingImpl.java"/>
        <delete failonerror="no" file="${build.soap}/org/exist/soap/QuerySoapBindingImpl.java"/>
        <wsdl2java url="${src}/org/exist/soap/query.wsdl"
                output="${build.soap}"
                deployscope="session"
                serverSide="yes"
                skeletonDeploy="yes"
                verbose="no"
                wrapArrays="yes">
            <mapping namespace="urn:exist" package="org.exist.soap"/>
        </wsdl2java>
        <copy todir="${src}/org/exist/soap">
            <fileset dir="${build.soap}/org/exist/soap">
                <include name="QueryService.java"/>
                <include name="QueryServiceLocator.java"/>
                <include name="QuerySoapBindingSkeleton.java"/>
                <include name="QuerySoapBindingStub.java"/>
                <include name="Collection.java"/>
                <include name="QueryResponse.java"/>
                <include name="QueryResponseCollection.java"/>
                <include name="QueryResponseDocument.java"/>
                <include name="QueryResponseCollections.java"/>
                <include name="QueryResponseDocuments.java"/>
                <include name="StringArray.java"/>
                <include name="Base64BinaryArray.java"/>
            </fileset>
        </copy>
        <copy file="${build.soap}/org/exist/soap/deploy.wsdd" tofile="${src}/org/exist/soap/deployQuery.wsdd"/>
        <copy file="${build.soap}/org/exist/soap/undeploy.wsdd" tofile="${src}/org/exist/soap/undeployQuery.wsdd"/>
        <wsdl2java url="${src}/org/exist/soap/admin.wsdl"
                output="${build.soap}"
                deployscope="session"
                serverSide="yes"
                skeletonDeploy="yes"
                verbose="no"
                wrapArrays="yes">
            <mapping namespace="urn:exist" package="org.exist.soap"/>
        </wsdl2java>
        <copy todir="${src}/org/exist/soap">
            <fileset dir="${build.soap}/org/exist/soap">
                <include name="AdminService.java"/>
                <include name="AdminServiceLocator.java"/>
                <include name="AdminSoapBindingSkeleton.java"/>
                <include name="AdminSoapBindingStub.java"/>
                <include name="CollectionDesc.java"/>
                <include name="DocumentDesc.java"/>
                <include name="DocumentDescs.java"/>
                <include name="DocumentType.java"/>
                <include name="EntityPermissions.java"/>
                <include name="EntityPermissionsList.java"/>
                <include name="IndexedElement.java"/>
                <include name="IndexedElements.java"/>
                <include name="Strings.java"/>
                <include name="Permissions.java"/>
                <include name="UserDesc.java"/>
                <include name="UserDescs.java"/>
            </fileset>
        </copy>
        <copy file="${build.soap}/org/exist/soap/deploy.wsdd" tofile="${src}/org/exist/soap/deployAdmin.wsdd"/>
        <copy file="${build.soap}/org/exist/soap/undeploy.wsdd" tofile="${src}/org/exist/soap/undeployAdmin.wsdd"/>
    </target>

    <target depends="jar" name="java2wsdl">
        <java2wsdl classname="org.exist.soap.Query"
                location="http://localhost:8080/exist/services/Query"
                output="${src}/org/exist/soap/query.wsdl"
                namespace="urn:exist">
            <mapping namespace="urn:exist" package="org.exist.soap"/>
        </java2wsdl>
        <java2wsdl classname="org.exist.soap.Admin"
                location="http://localhost:8080/exist/services/Admin"
                output="${src}/org/exist/soap/admin.wsdl"
                namespace="urn:exist">
            <mapping namespace="urn:exist" package="org.exist.soap"/>
        </java2wsdl>
    </target>

    <target depends="compile" name="deploy">
        <java classname="org.apache.axis.client.AdminClient" fork="false">
            <arg value="-lhttp://localhost:8080/exist/services/QueryService"/>
            <arg value="${src}/org/exist/soap/deployQuery.wsdd"/>
            <classpath refid="classpath.core"/>
        </java>
        <java classname="org.apache.axis.client.AdminClient" fork="false">
            <arg value="-lhttp://localhost:8080/exist/services/AdminService"/>
            <arg value="${src}/org/exist/soap/deployAdmin.wsdd"/>
            <classpath refid="classpath.core"/>
        </java>
    </target>

    <target depends="compile" name="undeploy">
        <java classname="org.apache.axis.client.AdminClient" fork="false">
            <arg value="-lhttp://localhost:8080/exist/services/QueryService"/>
            <arg value="${src}/org/exist/soap/undeployQuery.wsdd"/>
            <classpath refid="classpath.core"/>
        </java>
    </target>

</project>