You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ga...@apache.org on 2004/11/16 06:18:29 UTC
cvs commit: ws-axis/java/test/wsdl/qnameser PlanService.java QNameSerTestCase.java build.xml extension.wsdl server-deploy.wsdd
gawor 2004/11/15 21:18:29
Added: java/test/wsdl/qnameser PlanService.java
QNameSerTestCase.java build.xml extension.wsdl
server-deploy.wsdd
Log:
qname serialization tests
Revision Changes Path
1.1 ws-axis/java/test/wsdl/qnameser/PlanService.java
Index: PlanService.java
===================================================================
package test.wsdl.qnameser;
import javax.xml.namespace.QName;
import java.rmi.RemoteException;
public class PlanService {
public static final QName Q_1 = new QName("http://foo", "1");
public static final QName Q_2 = new QName("http://tempuri.org/", "2");
public static final QName Q_3 = new QName("", "3");
public GetPlanResponse getPlan(QName parameters)
throws RemoteException {
String localName = parameters.getLocalPart();
String namespace = null;
if (localName.equals(Q_1.getLocalPart())) {
namespace = Q_1.getNamespaceURI();
} else if (localName.equals(Q_2.getLocalPart())) {
namespace = Q_2.getNamespaceURI();
} else if (localName.equals(Q_3.getLocalPart())) {
namespace = Q_3.getNamespaceURI();
} else {
throw new RemoteException("invalid localname:" + localName);
}
if (!parameters.getNamespaceURI().equals(namespace)) {
throw new RemoteException("Expected: " + namespace + " but got: " +
parameters.getNamespaceURI());
}
return new GetPlanResponse();
}
public GetMPlanResponse getMPlan(GetMPlan in)
throws RemoteException {
QName [] list = in.getList();
for (int i=0;i<list.length;i++) {
getPlan(list[i]);
}
return new GetMPlanResponse();
}
}
1.1 ws-axis/java/test/wsdl/qnameser/QNameSerTestCase.java
Index: QNameSerTestCase.java
===================================================================
package test.wsdl.qnameser;
import org.apache.axis.client.AdminClient;
import org.apache.axis.components.logger.LogFactory;
import org.apache.axis.message.MessageElement;
import org.apache.axis.message.Text;
import org.apache.axis.utils.Options;
import org.apache.commons.logging.Log;
import org.apache.log4j.Logger;
import javax.xml.namespace.QName;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Calendar;
public class QNameSerTestCase extends junit.framework.TestCase {
public QNameSerTestCase(String name) {
super(name);
}
public void testQName() throws Exception {
PlanWSSoap binding;
try {
PlanWSLocator locator = new PlanWSLocator();
binding = locator.getPlanWSSoap();
deployServer();
}
catch (javax.xml.rpc.ServiceException jre) {
throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
}
catch (Exception e) {
throw new junit.framework.AssertionFailedError("Binding initialization Exception caught: " + e);
}
assertTrue("binding is null", binding != null);
binding.getPlan(PlanService.Q_1);
binding.getPlan(PlanService.Q_2);
binding.getPlan(PlanService.Q_3);
}
public void testQNameList() throws Exception {
PlanWSSoap binding;
try {
PlanWSLocator locator = new PlanWSLocator();
binding = locator.getPlanWSSoap();
deployServer();
}
catch (javax.xml.rpc.ServiceException jre) {
throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
}
catch (Exception e) {
throw new junit.framework.AssertionFailedError("Binding initialization Exception caught: " + e);
}
assertTrue("binding is null", binding != null);
QName [] list =
new QName[] {PlanService.Q_1, PlanService.Q_2, PlanService.Q_3};
GetMPlan in = new GetMPlan(list);
binding.getMPlan(in);
}
private void deployServer() {
final String INPUT_FILE = "server-deploy.wsdd";
InputStream is = getClass().getResourceAsStream(INPUT_FILE);
if (is == null) {
// try current directory
try {
is = new FileInputStream(INPUT_FILE);
} catch (FileNotFoundException e) {
is = null;
}
}
assertNotNull("Unable to find " + INPUT_FILE + ". Make sure it is on the classpath or in the current directory.", is);
AdminClient admin = new AdminClient();
try {
Options opts = new Options( null );
opts.setDefaultURL("http://localhost:8080/axis/services/AdminService");
admin.process(opts, is);
} catch (Exception e) {
assertTrue("Unable to deploy " + INPUT_FILE + ". ERROR: " + e, false);
}
}
}
1.1 ws-axis/java/test/wsdl/qnameser/build.xml
Index: build.xml
===================================================================
<?xml version="1.0" ?>
<!DOCTYPE project [
<!ENTITY properties SYSTEM "file:../../../xmls/properties.xml">
<!ENTITY paths SYSTEM "file:../../../xmls/path_refs.xml">
<!ENTITY taskdefs SYSTEM "file:../../../xmls/taskdefs.xml">
<!ENTITY taskdefs_post_compile SYSTEM "file:../../../xmls/taskdefs_post_compile.xml">
<!ENTITY targets SYSTEM "file:../../../xmls/targets.xml">
]>
<!-- ===================================================================
<description>
Test/Sample Component file for Axis
Notes:
This is a build file for use with the Jakarta Ant build tool.
Prerequisites:
jakarta-ant from http://jakarta.apache.org
Build Instructions:
To compile
ant compile
To execute
ant run
Author:
Matt Seibert mseibert@us.ibm.com
Copyright:
Copyright (c) 2002-2003 Apache Software Foundation.
</description>
==================================================================== -->
<project default="compile">
<property name="axis.home" location="../../.." />
<property name="componentName" value="test/wsdl/qnameser" />
&properties;
&paths;
&taskdefs;
&taskdefs_post_compile;
&targets;
<target name="clean">
<echo message="Removing ${build.dir}/classes/${componentName} and ${build.dir}/work/${componentName}" />
<delete dir="${build.dir}/classes/${componentName}"/>
<delete dir="${build.dir}/work/${componentName}"/>
</target>
<target name="copy" depends="setenv"/>
<target name="compile" depends="copy">
<echo message="Compiling test.wsdl.qnameser"/>
<!-- extension Sample Test -->
<wsdl2java url="${axis.home}/test/wsdl/qnameser/extension.wsdl"
output="${axis.home}/build/work"
serverSide="no"
skeletonDeploy="yes"
noWrapped="true"
testcase="no">
<mapping namespace="http://tempuri.org/" package="test.wsdl.qnameser"/>
</wsdl2java>
<copy todir="${build.dir}/work/test/wsdl/qnameser" overwrite="yes">
<fileset dir="${axis.home}/test/wsdl/qnameser">
<include name="*TestCase.java"/>
<include name="*Service.java"/>
</fileset>
</copy>
<javac srcdir="${build.dir}/work" destdir="${build.dest}" nowarn="${nowarn}" source="${source}" fork="${javac.fork}"
debug="${debug}">
<classpath refid="classpath" />
<include name="test/wsdl/qnameser/*.java" />
</javac>
<copy todir="${build.dir}/classes/test/wsdl/qnameser" overwrite="yes">
<fileset dir="${axis.home}/test/wsdl/qnameser">
<include name="server-deploy.wsdd"/>
</fileset>
</copy>
</target>
<target name="run" >
<antcall target="execute-Component" />
</target>
</project>
1.1 ws-axis/java/test/wsdl/qnameser/extension.wsdl
Index: extension.wsdl
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://tempuri.org/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
targetNamespace="http://tempuri.org/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<s:schema elementFormDefault="qualified"
xmlns:tns="http://tempuri.org/"
targetNamespace="http://tempuri.org/">
<s:simpleType name="QNameList">
<s:list itemType="s:QName" />
</s:simpleType>
<s:element name="GetPlan" type="s:QName"/>
<s:element name="GetPlanResponse">
<s:complexType/>
</s:element>
<s:element name="GetMPlan">
<s:complexType>
<s:sequence>
<s:element name="list" type="tns:QNameList"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetMPlanResponse">
<s:complexType/>
</s:element>
</s:schema>
</types>
<message name="GetPlanSoapIn">
<part name="parameters" element="s0:GetPlan" />
</message>
<message name="GetPlanSoapOut">
<part name="parameters" element="s0:GetPlanResponse" />
</message>
<message name="GetMPlanSoapIn">
<part name="parameters" element="s0:GetMPlan" />
</message>
<message name="GetMPlanSoapOut">
<part name="parameters" element="s0:GetMPlanResponse" />
</message>
<portType name="PlanWSSoap">
<operation name="GetPlan">
<input message="s0:GetPlanSoapIn" />
<output message="s0:GetPlanSoapOut" />
</operation>
<operation name="GetMPlan">
<input message="s0:GetMPlanSoapIn" />
<output message="s0:GetMPlanSoapOut" />
</operation>
</portType>
<binding name="PlanWSSoap" type="s0:PlanWSSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
<operation name="GetPlan">
<soap:operation soapAction="http://tempuri.org/GetPlan"
style="document" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
<operation name="GetMPlan">
<soap:operation soapAction="http://tempuri.org/GetMPlan"
style="document" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="PlanWS">
<port name="PlanWSSoap" binding="s0:PlanWSSoap">
<soap:address location="http://localhost:8080/axis/services/PlanWSSoap" />
</port>
</service>
</definitions>
1.1 ws-axis/java/test/wsdl/qnameser/server-deploy.wsdd
Index: server-deploy.wsdd
===================================================================
<!-- Use this file to deploy some handlers/chains and services -->
<!-- Two ways to do this: -->
<!-- java org.apache.axis.client.AdminClient deploy.wsdd -->
<!-- after the axis server is running -->
<!-- or -->
<!-- java org.apache.axis.utils.Admin client|server deploy.wsdd -->
<!-- from the same directory that the Axis engine runs -->
<deployment
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<!-- Services from PlanWS WSDL service -->
<service name="PlanWSSoap" provider="java:RPC" style="document" use="literal">
<parameter name="wsdlTargetNamespace" value="http://tempuri.org/"/>
<parameter name="wsdlServiceElement" value="PlanWS"/>
<parameter name="wsdlServicePort" value="PlanWSSoap"/>
<parameter name="className" value="test.wsdl.qnameser.PlanService"/>
<parameter name="wsdlPortType" value="PlanWSSoap"/>
<parameter name="allowedMethods" value="*"/>
<typeMapping
xmlns:ns="http://tempuri.org/"
qname="ns:>GetMPlanResponse"
type="java:test.wsdl.qnameser.GetMPlanResponse"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://tempuri.org/"
qname="ns:>GetPlanResponse"
type="java:test.wsdl.qnameser.GetPlanResponse"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://tempuri.org/"
qname="ns:QNameList"
type="java:javax.xml.namespace.QName[]"
serializer="org.apache.axis.encoding.ser.SimpleListSerializerFactory"
deserializer="org.apache.axis.encoding.ser.SimpleListDeserializerFactory"
encodingStyle=""
/>
</service>
</deployment>