This is an automated email from the ASF dual-hosted git repository. robertlazarski pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git
commit a94e1c5d192464a43176983b12a00230e6018f82 Author: Robert Lazarski <[email protected]> AuthorDate: Tue Apr 21 14:09:18 2026 -1000 Remove Castor databinding sample and dependencies Castor XML binding library (org.codehaus.castor 1.4.1) has been unmaintained since 2016 and its code generation fails silently on modern JDKs, causing the distribution integration test to fail with "package samples.databinding.data does not exist". This was the root cause of the GHA CI build failure — the Castor CastorSourceGenerator Ant task produced no output, then the javac step failed because the generated data classes were missing. Removed: - modules/samples/databinding (10 files: sample source, build.xml, WSDL, XSD, Castor config) - Castor dependency-copy from distribution POM (castor-core, castor-codegen, castor-xml, castor-xml-schema) - Castor version property from distribution POM - Databinding Ant test step from distribution integration test - Databinding sample description from userguide-samples.xml The remaining sample tests (mtom, faulthandling, webapp) are unaffected. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> --- modules/distribution/pom.xml | 50 +----- modules/samples/databinding/README.txt | 72 -------- modules/samples/databinding/StockQuote.xsd | 70 -------- modules/samples/databinding/StockQuoteService.wsdl | 64 ------- modules/samples/databinding/build.xml | 192 --------------------- .../samples/databinding/castorbuilder.properties | 66 ------- modules/samples/databinding/client/build.xml | 62 ------- .../src/samples/databinding/StockClient.java | 74 -------- .../src/samples/databinding/StockClient2.java | 94 ---------- modules/samples/databinding/service/build.xml | 59 ------- .../databinding/StockQuoteServiceSkeleton.java | 99 ----------- src/site/xdoc/docs/userguide-samples.xml | 3 +- 12 files changed, 5 insertions(+), 900 deletions(-) diff --git a/modules/distribution/pom.xml b/modules/distribution/pom.xml index 727102a64c..eb4fa331ba 100644 --- a/modules/distribution/pom.xml +++ b/modules/distribution/pom.xml @@ -43,10 +43,7 @@ <tag>HEAD</tag> </scm> - <properties> - <castor.version>1.4.1</castor.version> - </properties> - + <!-- Castor removed: obsolete XML binding library, unmaintained since 2016 --> <dependencies> <dependency> <groupId>org.apache.axis2</groupId> @@ -460,44 +457,8 @@ ant scripts, but this may cause issues with HTTP proxies and has the disadvantage that the JARs are downloaded every time instead of being copied from the local Maven repository. --> - <plugin> - <artifactId>maven-dependency-plugin</artifactId> - <executions> - <execution> - <id>test-dependencies</id> - <phase>integration-test</phase> - <goals> - <goal>copy</goal> - </goals> - <configuration> - <artifactItems> - <artifactItem> - <groupId>org.codehaus.castor</groupId> - <artifactId>castor-core</artifactId> - <version>${castor.version}</version> - </artifactItem> - <artifactItem> - <groupId>org.codehaus.castor</groupId> - <artifactId>castor-codegen</artifactId> - <version>${castor.version}</version> - </artifactItem> - <artifactItem> - <groupId>org.codehaus.castor</groupId> - <artifactId>castor-xml</artifactId> - <version>${castor.version}</version> - </artifactItem> - <artifactItem> - <groupId>org.codehaus.castor</groupId> - <artifactId>castor-xml-schema</artifactId> - <version>${castor.version}</version> - </artifactItem> - </artifactItems> - <outputDirectory>${project.build.directory}/axis2-${project.version}/modules/samples/databinding/lib</outputDirectory> - <overWriteReleases>false</overWriteReleases> - </configuration> - </execution> - </executions> - </plugin> + <!-- Castor dependency-copy removed: Castor is obsolete and the + databinding sample using it no longer compiles on modern JDKs --> <!-- Now unpack the distribution and run some automated tests on the samples --> <plugin> <artifactId>maven-antrun-plugin</artifactId> @@ -511,12 +472,9 @@ <configuration> <target> <unzip src="${project.build.directory}/axis2-${project.version}-bin.zip" dest="${project.build.directory}" /> - + <!-- Build the web app --> <ant dir="${project.build.directory}/axis2-${project.version}/webapp" useNativeBasedir="true" /> - - <!-- Test of the databinding sample --> - <ant dir="${project.build.directory}/axis2-${project.version}/modules/samples/databinding" /> <!-- Test of the mtom sample --> <ant dir="${project.build.directory}/axis2-${project.version}/modules/samples/mtom" target="generate.service" /> diff --git a/modules/samples/databinding/README.txt b/modules/samples/databinding/README.txt deleted file mode 100644 index 395efb6683..0000000000 --- a/modules/samples/databinding/README.txt +++ /dev/null @@ -1,72 +0,0 @@ -3Sample: Data Binding -==================== - -Introduction -============ - -This sample demonstrates how to use WSDL2Java generated code with Castor. - -Running of this sample assumes that you are running this within the extracted release folder (Axis2_HOME/samples/databinding). - - -Pre-Requisites -============== - * Install Apache Ant 1.6.2 or later. - * Please create a directory named lib under the directory that contains this file. - * Download the following libraries and drop them into the new lib directory: - * Version 1.0.4 of Castor jar from http://dist.codehaus.org/castor/1.0.4/castor-1.0.4.jar. - (The latest releases of castor are available at http://www.castor.org/download.html, but this example may not run - with versions later than 1.0.4) - * A recent Xerces version from http://xerces.apache.org/. - -You can achieve all three of the above steps by running "ant download.jars", but it will take some -time to download those two jars, using ant. - - -Deploying the Service -===================== - -You need to create the stock service Web service and deploy it. Typing ant generate.service or -simply ant in the command prompt, will build the service against StockQuoteService.wsdl listed -inside Axis2_HOME/samples/databinding and put it under Axis2_HOME/repository/services. - -You need to then startup the server to deploy the service. Go to Axis2_HOME/bin folder and execute either -axis2server.bat (in Windows) or axis2server.sh(in Linux), depending on your platform. - - -Running the Client -================== - -Typing the command "ant run.client" inside Axis2_HOME/samples/databinding runs the Axis2_HOME/samples/databinding/client/src/samples/databinding/StockClient.java class. You may use -the command scripts (as specified above) to do so. You need to supply 2 parameters to the command- url and symbol. - - * ant run.client -Durl=http://localhost:8080/axis2/services/StockQuoteService -Dsymbol=IBM - Succeeds with a Price of 99.0. You will see "Price = 99.0" - -When you call ant run.client with parameters, before running -client/src/samples/databinding/StockClient.java class, it does the following as well: - - * Generate the stubs (for the client) from the WSDL - * Compile the client classes - * Create a Jar of the client classes and copy it to build/client/StockService-test-client.jar - -How It Works -============== - -- Generate code giving -d none to get all the Axis2 APIs with OMElements. -- Create Castor objects for the schema given in the StockQuoteService.wsdl. -- Client API and the service uses those castor objects to get/set data. -- Get StAX events from the castor objects and construct OMElements from them. Those StAX events - are fed into StAXOMBuilder which can create OM tree from it. -- Feed those OMElement in to generated code. - -Note -============== -Sometimes, if you're having trouble running the client successfully, -It may be necessary to clean the services repository before you generate the service, deploy it -and run the client. (i.e. delete services created from previous samples.) - -Help -==== -Please contact axis-user list ([email protected]) if you have any trouble running the sample. - diff --git a/modules/samples/databinding/StockQuote.xsd b/modules/samples/databinding/StockQuote.xsd deleted file mode 100644 index 34963cd008..0000000000 --- a/modules/samples/databinding/StockQuote.xsd +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --> - -<xsd:schema - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - targetNamespace="http://w3.ibm.com/schemas/services/2002/11/15/stockquote" - xmlns="http://w3.ibm.com/schemas/services/2002/11/15/stockquote" -> - - <xsd:element name="quote"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="symbol" type="xsd:string"/> - <xsd:element name="volume" type="xsd:integer"/> - <xsd:element name="lastTrade" type="lastTradeType"/> - <xsd:element name="change" type="changeType"/> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - - <xsd:complexType name="changeType"> - <xsd:sequence> - <xsd:element name="dollar" type="xsd:float"/> - <xsd:element name="percent" type="xsd:float"/> - <xsd:element name="positive" type="xsd:boolean"/> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="lastTradeType"> - <xsd:sequence> - <xsd:element name="price" type="xsd:float"/> - <xsd:element name="date" type="xsd:long"/> - </xsd:sequence> - </xsd:complexType> - - <!-- Methods signatures --> - <xsd:element name="getStockQuote"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="symbol" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - <xsd:element name="getStockQuoteResponse"> - <xsd:complexType> - <xsd:sequence> - <xsd:element ref="quote" /> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - -</xsd:schema> diff --git a/modules/samples/databinding/StockQuoteService.wsdl b/modules/samples/databinding/StockQuoteService.wsdl deleted file mode 100644 index 884072b366..0000000000 --- a/modules/samples/databinding/StockQuoteService.wsdl +++ /dev/null @@ -1,64 +0,0 @@ -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --> - -<definitions targetNamespace="http://w3.ibm.com/schemas/services/2002/11/15/stockquote/wsdl" - xmlns="http://schemas.xmlsoap.org/wsdl/" - xmlns:tns="http://w3.ibm.com/schemas/services/2002/11/15/stockquote/wsdl" - xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" - xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" - xmlns:types="http://w3.ibm.com/schemas/services/2002/11/15/stockquote" - > - - <import namespace="http://w3.ibm.com/schemas/services/2002/11/15/stockquote" location="StockQuote.xsd" /> - - <message name="getStockQuoteReq"> - <part name="parameters" element="types:getStockQuote" /> - </message> - - <message name="getStockQuoteResp"> - <part name="parameters" element="types:getStockQuoteResponse" /> - </message> - - <portType name="StockQuotePortType"> - <operation name="getStockQuote"> - <input message="tns:getStockQuoteReq" /> - <output message="tns:getStockQuoteResp" /> - </operation> - </portType> - - <binding name="StockQuoteSOAPBinding" type="tns:StockQuotePortType"> - <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> - <operation name="getStockQuote"> - <soap:operation style="document" soapAction="getStockQuote" /> - <input> - <soap:body use="literal" /> - </input> - <output> - <soap:body use="literal" /> - </output> - </operation> - </binding> - - <service name="StockQuoteService"> - <port name="StockQuoteSOAPPort" binding="tns:StockQuoteSOAPBinding"> - <soap:address location="http://localhost:8080/axis2/services/StockQuoteService" /> - </port> - </service> - -</definitions> \ No newline at end of file diff --git a/modules/samples/databinding/build.xml b/modules/samples/databinding/build.xml deleted file mode 100644 index adac00733a..0000000000 --- a/modules/samples/databinding/build.xml +++ /dev/null @@ -1,192 +0,0 @@ -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --> - -<project name="databinding" basedir="." default="generate.service"> - - <property environment="env"/> - - <property name="wsdl.uri" value="StockQuoteService.wsdl"/> - <property name="service.target" value="build/service"/> - <property name="client.target" value="build/client"/> - - <path id="axis2.classpath"> - <fileset dir="../../../lib"> - <include name="*.jar"/> - </fileset> - <fileset dir="lib"> - <include name="*.jar"/> - </fileset> - </path> - - <macrodef name="CastorSourceGenerator"> - <attribute name="schema" default="NOT SET"/> - <attribute name="package" default="NOT SET"/> - <attribute name="output" default="NOT SET"/> - <sequential> - <echo/> - <java classname="org.exolab.castor.builder.SourceGeneratorMain" fork="true"> - <classpath refid="axis2.classpath"/> - <arg line="-i @{schema} -package @{package} -dest @{output}" /> - </java> - </sequential> - </macrodef> - - <!-- Build the service, then the client. --> - <target name="jar"> - <ant dir="service" target="jar.server"/> - <ant dir="client"/> - </target> - - <target name="run.client" depends="generate.stub"> - - <condition property="params.ok"> - <and> - <isset property="url"/> - <isset property="symbol"/> - </and> - </condition> - - <fail message="One of the parameters are not set. Usage: StockClient -Durl=<url> -Dsymbol=<symbol>" - unless="params.ok"/> - - <java classname="samples.databinding.StockClient" fork="true"> - <arg line="${url} ${symbol}"/> - <classpath> - <pathelement location="${client.target}/StockService-test-client.jar"/> - <path refid="axis2.classpath"/> - </classpath> - </java> - </target> - - <target name="generate.all" depends="generate.service,generate.stub"/> - - <target name="generate.service"> - - <delete dir="${service.target}"/> - <mkdir dir="${service.target}"/> - <mkdir dir="${service.target}/classes"/> - - <CastorSourceGenerator output="${service.target}/src" - package="samples.databinding.data" - schema="StockQuote.xsd"/> - <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true" classpathref="axis2.classpath"> - <arg line="-uri ${wsdl.uri}"/> - <arg line="-ss"/> - <arg line="-sd"/> - <arg line="-ap"/> - <arg line="-p samples.databinding"/> - <arg line="-d none"/> - <arg line="-o ${service.target}"/> - </java> - - <!--copy the already written skeleton class--> - <copy todir="${service.target}/src/" - overwrite="yes"> - <fileset dir="service/src"> - <include name="**/*.java"/> - </fileset> - </copy> - - <!--First let's compile the classes--> - <javac debug="on" memoryMaximumSize="256m" memoryInitialSize="256m" fork="true" - destdir="${service.target}/classes" srcdir="${service.target}/src" - classpathref="axis2.classpath" includeantruntime="false"> - </javac> - - <!--aar them up --> - <copy toDir="${service.target}/classes/META-INF" failonerror="false"> - <fileset dir="${service.target}/resources"> - <include name="*.xml"/> - <include name="*.wsdl"/> - <include name="*.xsd"/> - </fileset> - </copy> - <jar destfile="${service.target}/StockService.aar"> - <fileset excludes="**/Test.class" dir="${service.target}/classes"/> - <fileset dir="${basedir}"> - <include name="lib/*.jar"/> - </fileset> - </jar> - - <copy file="${service.target}/StockService.aar" tofile="../../../repository/services/StockService.aar" - overwrite="true"/> - - </target> - - <target name="generate.stub" unless="skip.generate"> - <delete dir="${client.target}"/> - <mkdir dir="${client.target}"/> - <mkdir dir="${client.target}/classes"/> - - - <CastorSourceGenerator output="${client.target}/src" - package="samples.databinding.data" - schema="StockQuote.xsd"/> - <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true" classpathref="axis2.classpath"> - <arg line="-uri ${wsdl.uri}"/> - <arg line="-u"/> - <arg line="-ap"/> - <arg line="-p samples.databinding"/> - <arg line="-d none"/> - <arg line="-t"/> - <arg line="-o ${client.target}"/> - </java> - - <copy todir="${client.target}/src/" - overwrite="yes"> - <fileset dir="client/src"> - <include name="**/*.java"/> - </fileset> - </copy> - - <!--now compile the stub classes--> - <javac debug="on" memoryMaximumSize="256m" memoryInitialSize="256m" fork="true" - srcdir="${client.target}/src" - excludes="**/StockClient2*.*" - destdir="${client.target}/classes" - classpathref="axis2.classpath" - includeantruntime="false"> - </javac> - - <!--jar the compiled stuff--> - <jar destfile="${client.target}/StockService-test-client.jar"> - <fileset dir="${client.target}/classes"> - <exclude name="**/META-INF/*.*"/> - <exclude name="**/*MessageReceiver.class"/> - <exclude name="**/*Skeleton.class"/> - </fileset> - </jar> - </target> - - <!--We are not shipping castor and Xerces jars with the release. This target can be used to - download those jars that are required to run this sample.--> - <target name="download.jars"> - <mkdir dir="lib"/> - - <get src="http://dist.codehaus.org/castor/1.0.4/castor-1.0.4.jar" dest="lib/castor-1.0.4.jar" - verbose="true"/> - <get src="http://repo2.maven.org/maven2/xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar" - dest="lib/xercesImpl-2.9.1.jar" verbose="true"/> - </target> - - <target name="clean"> - <delete dir="build"/> - </target> - -</project> diff --git a/modules/samples/databinding/castorbuilder.properties b/modules/samples/databinding/castorbuilder.properties deleted file mode 100644 index bb08f21f7c..0000000000 --- a/modules/samples/databinding/castorbuilder.properties +++ /dev/null @@ -1,66 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - - -# Java class mapping of <xsd:element>'s and <xsd:complexType>'s -# -org.exolab.castor.builder.javaclassmapping=element - -# This property allows one to specify the super class of *all* -# generated classes -# -#org.exolab.castor.builder.superclass=com.xyz.BaseObject - -# XML namespace mapping to Java packages -# -#org.exolab.castor.builder.nspackages=\ - http://www.xyz.com/schemas/project=com.xyz.schemas.project,\ - http://www.xyz.com/schemas/person=com.xyz.schemas.person - -# Set to true if you want to generate the equals method -# for each generated class -# false by default -# -#org.exolab.castor.builder.equalsmethod=true - -# Set to true if you want to use Object Wrappers instead -# of primitives (e.g Float instead of float). -# false by default. -# -#org.exolab.castor.builder.primitivetowrapper=false - -# Set to true if you want the generated class descriptors to -# expose the element and attribute names they contain. -# false by default. -# -#org.exolab.castor.builder.classdescfieldnames=false - -# Set to true if you want the generated source code to contain -# Extra methods for the collection fields, such as get/set using -# the collection type in addition to the type-safe array. -# Set this to true if you want your code to be more compatible -# with Castor JDO. This is false by default. -# -#org.exolab.castor.builder.extraCollectionMethods=true - -# Use old-style (Castor 0.9.3.9) of naming that uppercases -# names after an underscore -# -#org.exolab.castor.xml.JavaNaming.upperCaseAfterUnderscore=true - diff --git a/modules/samples/databinding/client/build.xml b/modules/samples/databinding/client/build.xml deleted file mode 100644 index ade82725ef..0000000000 --- a/modules/samples/databinding/client/build.xml +++ /dev/null @@ -1,62 +0,0 @@ -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --> - -<project basedir="." default="jar.client"> - - <property environment="env"/> - - <property name="project.base.dir" value="."/> - <property name="parent.dir" value=".."/> - - <property name="wsdl.uri" value="${parent.dir}/bank.wsdl"/> - - <property name="src" value="${project.base.dir}/src"/> - <property name="target" value="${project.base.dir}/target"/> - <property name="target.java" value="${target}/src"/> - <property name="target.classes" value="${target}/classes"/> - - <target name="check.dependency" unless="env.AXIS2_HOME"> - <echo message="AXIS2_HOME must be set"/> - </target> - - <target name="gen.stub" if="env.AXIS2_HOME" depends="check.dependency"> - <delete dir="${target}"/> - <mkdir dir="${target}"/> - <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"> - <arg line="-uri ${wsdl.uri}"/> - <arg line="-u"/> - <arg line="-o ${target}"/> - <classpath> - <fileset dir="${env.AXIS2_HOME}\lib"> - <include name="*.jar"/> - </fileset> - </classpath> - </java> - </target> - - <!-- Create the service archive by executing target\build.xml (jar.server) --> - <target name="jar.client" if="env.AXIS2_HOME" depends="gen.stub"> - <copy todir="${target.java}"> - <fileset dir="${src}"/> - </copy> - <ant dir="${target}"/> - <copy file="${target}\build\lib\BankService-test-client.jar" todir=".."/> - </target> - -</project> \ No newline at end of file diff --git a/modules/samples/databinding/client/src/samples/databinding/StockClient.java b/modules/samples/databinding/client/src/samples/databinding/StockClient.java deleted file mode 100644 index 6a396e472f..0000000000 --- a/modules/samples/databinding/client/src/samples/databinding/StockClient.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package samples.databinding; - -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMDocument; -import org.apache.axiom.om.OMElement; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.UnmarshalHandler; -import org.exolab.castor.xml.Unmarshaller; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; - -import samples.databinding.data.GetStockQuote; -import samples.databinding.data.GetStockQuoteResponse; - -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; - -public final class StockClient { - public static void main(String[] args) throws Exception { - if (args.length != 2) { - System.err.println("Usage: StockClient <url> <symbol>"); - return; - } - final String url = args[0]; - final String symbol = args[1]; - - System.out.println(); - System.out.println("Getting Stock Quote for " + symbol); - - StockQuoteServiceStub stub = - new StockQuoteServiceStub(url); - stub._getServiceClient().getOptions().setAction("getStockQuote"); - GetStockQuote stockQuote = new GetStockQuote(); - stockQuote.setSymbol(symbol); - OMDocument document = OMAbstractFactory.getOMFactory().createOMDocument(); - Marshaller.marshal(stockQuote, document.getSAXResult().getHandler()); - OMElement response = stub.getStockQuote( - document.getOMDocumentElement()); - - - Unmarshaller unmarshaller = new Unmarshaller(GetStockQuoteResponse.class); - UnmarshalHandler unmarshalHandler = unmarshaller.createHandler(); - GetStockQuoteResponse stockQuoteResponse; - try { - ContentHandler contentHandler = Unmarshaller.getContentHandler(unmarshalHandler); - TransformerFactory.newInstance().newTransformer().transform(response.getSAXSource(false), new SAXResult(contentHandler)); - stockQuoteResponse = (GetStockQuoteResponse) unmarshalHandler.getObject(); - } catch (SAXException e) { - throw new RuntimeException(e); - } catch (TransformerException e) { - throw new RuntimeException(e); - } - System.out.println("Price = " + stockQuoteResponse.getQuote().getLastTrade().getPrice()); - } -} diff --git a/modules/samples/databinding/client/src/samples/databinding/StockClient2.java b/modules/samples/databinding/client/src/samples/databinding/StockClient2.java deleted file mode 100644 index 267196ec81..0000000000 --- a/modules/samples/databinding/client/src/samples/databinding/StockClient2.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package samples.databinding; - -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMDataSource; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.OMOutputFormat; -import org.apache.axiom.om.ds.AbstractPushOMDataSource; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.JDOMException; -import org.jdom.input.StAXBuilder; -import org.jdom.output.StAXOutputter; -import org.jdom.xpath.XPath; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.Writer; - -public final class StockClient2 { - public static void main(String[] args) throws Exception { - if (args.length != 2) { - System.err.println("Usage: StockClient <url> <symbol>"); - return; - } - final String url = args[0]; - final String symbol = args[1]; - - System.out.println(); - System.out.println("Getting Stock Quote for " + symbol); - - StockQuoteServiceStub stub = - new StockQuoteServiceStub(url); - stub._getServiceClient().getOptions().setAction("getStockQuote"); - - Element element1 = new Element( - "getStockQuote", "nsl", "http://w3.ibm.com/schemas/services/2002/11/15/stockquote"); - Element element2 = new Element("symbol"); - element2.addContent(symbol); - element1.addContent(element2); - - OMFactory factory = OMAbstractFactory.getOMFactory(); - org.apache.axiom.om.OMDataSource src = new JDOMDataSource(element1); - org.apache.axiom.om.OMNamespace appns = factory.createOMNamespace("http://w3.ibm.com/schemas/services/2002/11/15/stockquote", "ns1"); - OMElement child = factory.createOMElement(src, "getStockQuote", appns); - - OMElement response = stub.getStockQuote(child); - - StAXBuilder builder = new StAXBuilder(); - Document doc = builder.build(response.getXMLStreamReader()); - XPath path = XPath.newInstance("//price"); - Element price = (Element) path.selectSingleNode(doc.getRootElement()); - System.out.println("Price = " + price.getText()); - } - - private static class JDOMDataSource extends AbstractPushOMDataSource { - private final Element data; - - private JDOMDataSource(Element data) { - this.data = data; - } - - public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException { - StAXOutputter outputter = new StAXOutputter(xmlWriter); - try { - outputter.outputFragment(data); - } catch (JDOMException e) { - throw new XMLStreamException(e); - } - } - } -} diff --git a/modules/samples/databinding/service/build.xml b/modules/samples/databinding/service/build.xml deleted file mode 100644 index dfac9441d8..0000000000 --- a/modules/samples/databinding/service/build.xml +++ /dev/null @@ -1,59 +0,0 @@ -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --> - -<project basedir="." default="gen.skeleton"> - - <property environment="env"/> - - <property name="project.base.dir" value="."/> - <property name="parent.dir" value=".."/> - - <property name="wsdl.uri" value="${parent.dir}/bank.wsdl"/> - - <property name="src" value="${project.base.dir}/src"/> - <property name="target" value="${project.base.dir}/target"/> - - <target name="check.dependency" unless="env.AXIS2_HOME"> - <echo message="AXIS2_HOME must be set"/> - </target> - - <target name="gen.skeleton" if="env.AXIS2_HOME" depends="check.dependency"> - - - <delete dir="${target}"/> - <mkdir dir="${target}"/> - <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"> - <arg line="-uri ${wsdl.uri}"/> - <arg line="-ss"/> - <arg line="-sd"/> - <arg line="-o ${target}"/> <!-- Output directory in which to generate files --> <!-- NB it generates to the src folder under this directory!! --> - <classpath> - <fileset dir="..\..\lib"> - <include name="*.jar"/> - </fileset> - </classpath> - </java> - </target> - - <!-- Create the service archive by executing target\build.xml (jar.server) --> - <target name="jar.server" if="env.AXIS2_HOME"> - <ant dir="${target}"/> - <copy file="${target}\build\lib\BankService.aar" todir=".."/> - </target> -</project> \ No newline at end of file diff --git a/modules/samples/databinding/service/src/samples/databinding/StockQuoteServiceSkeleton.java b/modules/samples/databinding/service/src/samples/databinding/StockQuoteServiceSkeleton.java deleted file mode 100644 index 037cd17f25..0000000000 --- a/modules/samples/databinding/service/src/samples/databinding/StockQuoteServiceSkeleton.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package samples.databinding; - -import org.apache.axiom.om.OMDocument; -import org.apache.axiom.om.OMElement; -import org.apache.axis2.AxisFault; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.UnmarshalHandler; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; - -import samples.databinding.data.Change; -import samples.databinding.data.GetStockQuote; -import samples.databinding.data.GetStockQuoteResponse; -import samples.databinding.data.LastTrade; -import samples.databinding.data.Quote; - -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXResult; - -import java.io.IOException; -import java.util.Calendar; -/** - * StockQuoteServiceSkeleton java skeleton for the axisService - */ -public class StockQuoteServiceSkeleton { - /** - * Auto generated method signature - * - * @param param0 - */ - public OMElement getStockQuote(OMElement param0) throws AxisFault { - Unmarshaller unmarshaller = new Unmarshaller(GetStockQuote.class); - UnmarshalHandler unmarshalHandler = unmarshaller.createHandler(); - GetStockQuote stockQuote; - try { - ContentHandler contentHandler = Unmarshaller.getContentHandler(unmarshalHandler); - TransformerFactory.newInstance().newTransformer().transform(param0.getSAXSource(false), new SAXResult(contentHandler)); - stockQuote = (GetStockQuote) unmarshalHandler.getObject(); - } catch (SAXException e) { - throw new RuntimeException(e); - } catch (TransformerException e) { - throw new RuntimeException(e); - } - - if (!stockQuote.getSymbol().equals("IBM")) { - throw new AxisFault("StockQuote details for the symbol '"+ stockQuote.getSymbol() + "' are not available."); - } - GetStockQuoteResponse stockQuoteResponse = new GetStockQuoteResponse(); - Quote quote = new Quote(); - quote.setSymbol(stockQuote.getSymbol()); - quote.setVolume(5000); - - LastTrade lastTrade = new LastTrade(); - lastTrade.setPrice(99); - lastTrade.setDate(Calendar.getInstance().getTimeInMillis()); - quote.setLastTrade(lastTrade); - - Change change = new Change(); - change.setDollar(1); - change.setPercent(10); - change.setPositive(true); - quote.setChange(change); - - stockQuoteResponse.setQuote(quote); - - OMDocument document = param0.getOMFactory().createOMDocument(); - try { - Marshaller.marshal(stockQuoteResponse, document.getSAXResult().getHandler()); - } catch (MarshalException e) { - throw new RuntimeException(e); - } catch (ValidationException e) { - throw new RuntimeException(e); - } - return document.getOMDocumentElement(); - } -} - diff --git a/src/site/xdoc/docs/userguide-samples.xml b/src/site/xdoc/docs/userguide-samples.xml index fb3b9bf580..9100cfcb37 100644 --- a/src/site/xdoc/docs/userguide-samples.xml +++ b/src/site/xdoc/docs/userguide-samples.xml @@ -188,8 +188,7 @@ is to show where and how to use the service life cycle interface and session related methods.</p> <!--<p><strong>sgccalculator</strong>: A simple calculator that demonstrates the use of Service Groups.</p>--> -<p><strong>databinding</strong>: Demonstrates how to use WSDL2Java -generated code with Castor.</p> +<!-- databinding sample removed: depended on Castor (obsolete, unmaintained since 2016) --> <p><strong>version</strong>: A very simple service that simply outputs the Apache Axis2 version.</p> <p><strong>yahoorestearch</strong>: A complete example of the use
