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 wo...@apache.org on 2008/03/03 19:48:24 UTC
svn commit: r633234 [11/24] - in /webservices/axis2/trunk/java: ./
modules/jaxws-integration/ modules/jaxws-integration/test/
modules/jaxws-integration/test/client/ modules/jaxws-integration/test/org/
modules/jaxws-integration/test/org/apache/ modules/...
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/sei/EchoMessagePortType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/sei/EchoMessagePortType.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/sei/EchoMessagePortType.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/sei/EchoMessagePortType.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,54 @@
+
+/*
+ * 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 org.apache.axis2.jaxws.nonanonymous.complextype.sei;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+
+/**
+ * This class was generated by the JAXWS SI.
+ * JAX-WS RI 2.0_01-b15-fcs
+ * Generated source version: 2.0
+ *
+ */
+@WebService(name = "EchoMessagePortType", targetNamespace = "http://nonanonymous.complextype.test.org")
+public interface EchoMessagePortType {
+
+
+ /**
+ *
+ * @param request
+ * @return
+ * returns java.lang.String
+ */
+ @WebMethod
+ @WebResult(name = "response", targetNamespace = "http://nonanonymous.complextype.test.org")
+ @RequestWrapper(localName = "echoMessage", targetNamespace = "http://nonanonymous.complextype.test.org", className = "org.test.complextype.nonanonymous.EchoMessage")
+ @ResponseWrapper(localName = "echoMessageResponse", targetNamespace = "http://nonanonymous.complextype.test.org", className = "org.test.complextype.nonanonymous.EchoMessageResponse")
+ public String echoMessage(
+ @WebParam(name = "request", targetNamespace = "http://nonanonymous.complextype.test.org")
+ String request);
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/sei/EchoMessageService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/sei/EchoMessageService.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/sei/EchoMessageService.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/nonanonymous/complextype/sei/EchoMessageService.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,80 @@
+
+/*
+ * 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 org.apache.axis2.jaxws.nonanonymous.complextype.sei;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceClient;
+
+/**
+ * This class was generated by the JAXWS SI.
+ * JAX-WS RI 2.0_01-b15-fcs
+ * Generated source version: 2.0
+ *
+ */
+@WebServiceClient(name = "EchoMessageService", targetNamespace = "http://nonanonymous.complextype.test.org", wsdlLocation = "EchoMessage.wsdl")
+public class EchoMessageService
+ extends Service
+{
+
+ private final static URL ECHOMESSAGESERVICE_WSDL_LOCATION;
+
+ private static String wsdlLocation="/test/org/apache/axis2/jaxws/nonanonymous/complextype/META-INF/EchoMessage.wsdl";
+ static {
+ URL url = null;
+ try {
+ try{
+ String baseDir = new File(System.getProperty("basedir",".")).getCanonicalPath();
+ wsdlLocation = new File(baseDir + wsdlLocation).getAbsolutePath();
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ File file = new File(wsdlLocation);
+ url = file.toURL();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ ECHOMESSAGESERVICE_WSDL_LOCATION = url;
+ }
+
+ public EchoMessageService(URL wsdlLocation, QName serviceName) {
+ super(wsdlLocation, serviceName);
+ }
+
+ public EchoMessageService() {
+ super(ECHOMESSAGESERVICE_WSDL_LOCATION, new QName("http://nonanonymous.complextype.test.org", "EchoMessageService"));
+ }
+
+ /**
+ *
+ * @return
+ * returns EchoMessagePortType
+ */
+ @WebEndpoint(name = "EchoMessagePort")
+ public EchoMessagePortType getEchoMessagePort() {
+ return (EchoMessagePortType)super.getPort(new QName("http://nonanonymous.complextype.test.org", "EchoMessagePort"), EchoMessagePortType.class);
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/PolymorphicShapePortTypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/PolymorphicShapePortTypeImpl.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/PolymorphicShapePortTypeImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/PolymorphicShapePortTypeImpl.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,63 @@
+/*
+ * 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 org.apache.axis2.jaxws.polymorphic.shape;
+
+import javax.jws.WebService;
+
+import org.apache.axis2.jaxws.polymorphic.shape.sei.PolymorphicShapePortType;
+import org.apache.axis2.jaxws.TestLogger;
+import org.test.shape.Circle;
+import org.test.shape.Shape;
+import org.test.shape.Square;
+import org.test.shape.threed.ThreeDSquare;
+
+@WebService(serviceName="PolymorphicShapeService",
+ portName="PolymorphicShapePort",
+ targetNamespace="http://sei.shape.polymorphic.jaxws.axis2.apache.org",
+ endpointInterface="org.apache.axis2.jaxws.polymorphic.shape.sei.PolymorphicShapePortType",
+ wsdlLocation="test/org/apache/axis2/jaxws/polymorphic/shape/META-INF/shapes.wsdl")
+public class PolymorphicShapePortTypeImpl implements PolymorphicShapePortType {
+
+ public Shape draw(Shape request) {
+ if(request instanceof Circle){
+ Circle circle =(Circle) request;
+ TestLogger.logger.debug("Drawing Circle on x =" + request.getXAxis() + " y=" +
+ request.getYAxis() + " With Radius =" + circle.getRadius());
+ return request;
+ }
+ if(request instanceof Square){
+ Square square =(Square) request;
+ TestLogger.logger.debug("Drawing Square on x =" + request.getXAxis() + " y=" +
+ request.getYAxis() + " With Sides =" + square.getLength());
+ return request;
+ }
+ return null;
+ }
+
+ public Shape draw3D(Shape request) {
+ if(request instanceof ThreeDSquare){
+ ThreeDSquare threeDsquare =(ThreeDSquare) request;
+ TestLogger.logger.debug("Drawing 3DSquare on x =" + request.getXAxis() + " y=" +
+ request.getYAxis() + " With Bredth =" + threeDsquare.getBredth());
+ return request;
+ }
+ return null;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/sei/PolymorphicShapePortType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/sei/PolymorphicShapePortType.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/sei/PolymorphicShapePortType.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/sei/PolymorphicShapePortType.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,69 @@
+
+/*
+ * 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 org.apache.axis2.jaxws.polymorphic.shape.sei;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+import org.test.shape.Shape;
+
+/**
+ * This class was generated by the JAXWS SI.
+ * JAX-WS RI 2.0_01-b15-fcs
+ * Generated source version: 2.0
+ *
+ */
+@WebService(name = "PolymorphicShapePortType", targetNamespace = "http://sei.shape.polymorphic.jaxws.axis2.apache.org")
+public interface PolymorphicShapePortType {
+
+
+ /**
+ *
+ * @param request
+ * @return
+ * returns org.test.shape.Shape
+ */
+ @WebMethod(action = "http://sei.polymorphicshape.jaxws.axis2.apache.org/typesExtension")
+ @WebResult(name = "response", targetNamespace = "")
+ @RequestWrapper(localName = "draw", targetNamespace = "http://wrapper.shape.test.org", className = "org.test.shape.wrapper.Draw")
+ @ResponseWrapper(localName = "drawResponse", targetNamespace = "http://wrapper.shape.test.org", className = "org.test.shape.wrapper.DrawResponse")
+ public Shape draw(
+ @WebParam(name = "request", targetNamespace = "")
+ Shape request);
+
+ /**
+ *
+ * @param request
+ * @return
+ * returns org.test.shape.Shape
+ */
+ @WebMethod(action = "http://sei.polymorphicshape.jaxws.axis2.apache.org/typesExtension")
+ @WebResult(name = "response", targetNamespace = "")
+ @RequestWrapper(localName = "draw3D", targetNamespace = "http://wrapper.shape.test.org", className = "org.test.shape.wrapper.Draw3D")
+ @ResponseWrapper(localName = "drawResponse", targetNamespace = "http://wrapper.shape.test.org", className = "org.test.shape.wrapper.DrawResponse")
+ public Shape draw3D(
+ @WebParam(name = "request", targetNamespace = "")
+ Shape request);
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/sei/PolymorphicShapeService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/sei/PolymorphicShapeService.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/sei/PolymorphicShapeService.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/sei/PolymorphicShapeService.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,80 @@
+
+/*
+ * 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 org.apache.axis2.jaxws.polymorphic.shape.sei;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceClient;
+
+/**
+ * This class was generated by the JAXWS SI.
+ * JAX-WS RI 2.0_01-b15-fcs
+ * Generated source version: 2.0
+ *
+ */
+@WebServiceClient(name = "PolymorphicShapeService", targetNamespace = "http://sei.shape.polymorphic.jaxws.axis2.apache.org", wsdlLocation = "shapes.wsdl")
+public class PolymorphicShapeService
+ extends Service
+{
+
+ private final static URL POLYMORPHICSHAPESERVICE_WSDL_LOCATION;
+
+ private static String wsdlLocation="/test/org/apache/axis2/jaxws/polymorphic/shape/META-INF/shapes.wsdl";
+ static {
+ URL url = null;
+ try {
+ try{
+ String baseDir = new File(System.getProperty("basedir",".")).getCanonicalPath();
+ wsdlLocation = new File(baseDir + wsdlLocation).getAbsolutePath();
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ File file = new File(wsdlLocation);
+ url = file.toURL();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ POLYMORPHICSHAPESERVICE_WSDL_LOCATION = url;
+ }
+
+ public PolymorphicShapeService(URL wsdlLocation, QName serviceName) {
+ super(wsdlLocation, serviceName);
+ }
+
+ public PolymorphicShapeService() {
+ super(POLYMORPHICSHAPESERVICE_WSDL_LOCATION, new QName("http://sei.shape.polymorphic.jaxws.axis2.apache.org", "PolymorphicShapeService"));
+ }
+
+ /**
+ *
+ * @return
+ * returns PolymorphicShapePortType
+ */
+ @WebEndpoint(name = "PolymorphicShapePort")
+ public PolymorphicShapePortType getPolymorphicShapePort() {
+ return (PolymorphicShapePortType)super.getPort(new QName("http://sei.shape.polymorphic.jaxws.axis2.apache.org", "PolymorphicShapePort"), PolymorphicShapePortType.class);
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/tests/PolymorphicTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/tests/PolymorphicTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/tests/PolymorphicTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/polymorphic/shape/tests/PolymorphicTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,182 @@
+/*
+ * 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 org.apache.axis2.jaxws.polymorphic.shape.tests;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.ConnectException;
+import java.net.UnknownHostException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.wsdl.WSDLException;
+import javax.xml.ws.BindingProvider;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.polymorphic.shape.sei.PolymorphicShapePortType;
+import org.apache.axis2.jaxws.polymorphic.shape.sei.PolymorphicShapeService;
+import org.apache.axis2.jaxws.util.WSDL4JWrapper;
+import org.apache.axis2.jaxws.util.WSDLWrapper;
+import org.apache.axis2.jaxws.wsdl.SchemaReaderException;
+import org.apache.axis2.jaxws.wsdl.impl.SchemaReaderImpl;
+import org.apache.axis2.jaxws.TestLogger;
+import org.test.shape.Shape;
+import org.test.shape.Square;
+import org.test.shape.threed.ThreeDSquare;
+
+public class PolymorphicTests extends TestCase {
+ String axisEndpoint = "http://localhost:6060/axis2/services/PolymorphicShapeService.PolymorphicShapePort";
+
+ public void testFormalAndActualTypeInDifferentPackages(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+ PolymorphicShapeService service = new PolymorphicShapeService();
+ PolymorphicShapePortType port = service.getPolymorphicShapePort();
+ BindingProvider p = (BindingProvider) port;
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+
+ Shape shapeType;
+
+ TestLogger.logger.debug("Sending Request to draw Square");
+ Square shape = new Square();
+ shape.setXAxis(1);
+ shape.setYAxis(1);
+ shape.setLength(10);
+ shapeType = port.draw(shape);
+ assertTrue(shapeType instanceof Square);
+ TestLogger.logger.debug("Square was drawn");
+
+ TestLogger.logger.debug("Sending Request to draw 3D Square");
+ ThreeDSquare threeDshape = new ThreeDSquare();
+ threeDshape.setXAxis(1);
+ threeDshape.setYAxis(1);
+ threeDshape.setLength(10);
+ threeDshape.setWidth(10);
+ threeDshape.setBredth(10);
+ shapeType = port.draw3D(threeDshape);
+ assertTrue(shapeType instanceof ThreeDSquare);
+ TestLogger.logger.debug("3D Square was drawn");
+ TestLogger.logger.debug("-------------------------------");
+ }
+
+ public void testInlineUseOfJAXBBinding(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+ String schemaBindingPkgName = "org.test.echomessage";
+ String standardPkgName= "org.test.complextype.nonanonymous";
+ String wsdlLocation="test-resources/wsdl/JAXB_Customization_Sample.wsdl";
+ URL url = null;
+ try{
+ try{
+ String baseDir = new File(System.getProperty("basedir",".")).getCanonicalPath();
+ wsdlLocation = new File(baseDir +File.separator+ wsdlLocation).getAbsolutePath();
+ }catch(Exception e){
+ e.printStackTrace();
+ fail();
+ }
+ File file = new File(wsdlLocation);
+ url = file.toURL();
+ WSDLWrapper wsdlWrapper = new WSDL4JWrapper(url);
+ org.apache.axis2.jaxws.wsdl.SchemaReader sr= new SchemaReaderImpl();
+ Set<String> set= sr.readPackagesFromSchema(wsdlWrapper.getDefinition());
+ assertNotNull(set);
+ Iterator<String> iter = set.iterator();
+ while(iter.hasNext()){
+ String pkg = iter.next();
+ TestLogger.logger.debug("Package = " + pkg);
+ }
+ TestLogger.logger.debug("------------------------------");
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ fail();
+ }catch(FileNotFoundException e) {
+ e.printStackTrace();
+ fail();
+ }catch(UnknownHostException e) {
+ e.printStackTrace();
+ fail();
+ }catch(ConnectException e) {
+ e.printStackTrace();
+ fail();
+ }catch(IOException e) {
+ e.printStackTrace();
+ fail();
+ }catch(WSDLException e){
+ e.printStackTrace();
+ fail();
+ }catch(SchemaReaderException e){
+ e.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testSchemaReader(){
+ TestLogger.logger.debug("------------------------------");
+ TestLogger.logger.debug("Test : " + getName());
+ String wsdlLocation="test-resources/wsdl/shapes.wsdl";
+ URL url = null;
+ try{
+ try{
+ String baseDir = new File(System.getProperty("basedir",".")).getCanonicalPath();
+ wsdlLocation = new File(baseDir +File.separator+ wsdlLocation).getAbsolutePath();
+ }catch(Exception e){
+ e.printStackTrace();
+ fail();
+ }
+ File file = new File(wsdlLocation);
+ url = file.toURL();
+ WSDLWrapper wsdlWrapper = new WSDL4JWrapper(url);
+ org.apache.axis2.jaxws.wsdl.SchemaReader sr= new SchemaReaderImpl();
+ Set<String> set= sr.readPackagesFromSchema(wsdlWrapper.getDefinition());
+ assertNotNull(set);
+ Iterator<String> iter = set.iterator();
+ while(iter.hasNext()){
+ TestLogger.logger.debug("Package =" + iter.next());
+ }
+ TestLogger.logger.debug("------------------------------");
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ fail();
+ }catch(FileNotFoundException e) {
+ e.printStackTrace();
+ fail();
+ }catch(UnknownHostException e) {
+ e.printStackTrace();
+ fail();
+ }catch(ConnectException e) {
+ e.printStackTrace();
+ fail();
+ }catch(IOException e) {
+ e.printStackTrace();
+ fail();
+ }catch(WSDLException e){
+ e.printStackTrace();
+ fail();
+ }catch(SchemaReaderException e){
+ e.printStackTrace();
+ fail();
+ }
+
+
+
+ }
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/AttachmentUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/AttachmentUtil.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/AttachmentUtil.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/AttachmentUtil.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,222 @@
+/*
+ * 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 org.apache.axis2.jaxws.provider;
+
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.OutputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Iterator;
+
+import javax.imageio.IIOImage;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageOutputStream;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+/**
+ * This will serve as a helper class for attachments utility methods. All methods
+ * are intended to be referenced staticly.
+ *
+ */
+public class AttachmentUtil {
+ public static final String SOAP11_NAMESPACE = "http://schemas.xmlsoap.org/soap/envelope";
+ public static final String SOAP12_NAMESPACE = "http://www.w3.org/2003/05/soap-envelope";
+
+ public static final String MU_TEXT = "soap message mustUnderstand header request";
+ public static final String UNDERSTOOD_MU_TEXT = "understood headers soap message mustUnderstand header request";
+ public static final String TEXT = "soap message request";
+ public static final String VALUE = "value";
+ public static final String VALUE_NODE = "<"+VALUE+">";
+ public static final String VALUE_NODE_SLASH = "</"+VALUE+">";
+ public static final String XML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+ public static final String MUHEADER_CLIENT = "ns1:muclient";
+ public static final String MUHEADER_SERVER = "ns1:muserver";
+ public static final String MUHEADER_CLIENT_UNDERSTOOD = "ns1:muclientunderstood";
+ public static final String MUHEADER_SERVER_UNDERSTOOD = "ns1:muserverunderstood";
+ public static final String msgEnvMU =
+ "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
+ "<soapenv:Header>" +
+ "<"+MUHEADER_CLIENT+" xmlns:ns1=\"http://ws.apache.org/axis2\" soapenv:mustUnderstand=\"1\">MUinfo</"+MUHEADER_CLIENT+">" +
+ "</soapenv:Header>" +
+ "<soapenv:Body>" +
+ "<ns1:invoke xmlns:ns1=\"http://ws.apache.org/axis2\">" +
+ VALUE_NODE +
+ MU_TEXT +
+ VALUE_NODE_SLASH +
+ "</ns1:invoke>" +
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public static final String msgEnv =
+ "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
+ "<soapenv:Body>" +
+ "<ns1:invoke xmlns:ns1=\"http://ws.apache.org/axis2\">" +
+ VALUE_NODE +
+ MU_TEXT +
+ VALUE_NODE_SLASH +
+ "</ns1:invoke>" +
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public static final String msgEnvPlain =
+ "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
+ "<soapenv:Body>" +
+ "<ns1:invoke xmlns:ns1=\"http://ws.apache.org/axis2\">" +
+ VALUE_NODE +
+ TEXT +
+ VALUE_NODE_SLASH +
+ "</ns1:invoke>" +
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public static final String msgEnvMU_understood =
+ "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
+ "<soapenv:Header>" +
+ "<"+MUHEADER_CLIENT_UNDERSTOOD+" xmlns:ns1=\"http://ws.apache.org/axis2\" soapenv:mustUnderstand=\"1\">MUinfo</"+MUHEADER_CLIENT_UNDERSTOOD+">" +
+ "</soapenv:Header>" +
+ "<soapenv:Body>" +
+ "<ns1:invoke xmlns:ns1=\"http://ws.apache.org/axis2\">" +
+ VALUE_NODE +
+ UNDERSTOOD_MU_TEXT +
+ VALUE_NODE_SLASH +
+ "</ns1:invoke>" +
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public static final String msgEnv_understood =
+ "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
+ "<soapenv:Body>" +
+ "<ns1:invoke xmlns:ns1=\"http://ws.apache.org/axis2\">" +
+ VALUE_NODE +
+ UNDERSTOOD_MU_TEXT +
+ VALUE_NODE_SLASH +
+ "</ns1:invoke>" +
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ /**
+ * Store a given image to an Image output stream
+ * @param mimeType
+ * @param image
+ * @param os
+ * @throws Exception
+ */
+ public static void storeImage(String mimeType, Image image, OutputStream os) throws Exception {
+ ImageWriter imageWriter = null;
+ BufferedImage bufferedImage = (BufferedImage) image;
+
+ Iterator iterator = javax.imageio.ImageIO.getImageWritersByMIMEType(mimeType);
+ if (iterator.hasNext()) {
+ imageWriter = (ImageWriter) iterator.next();
+ }
+ ImageOutputStream ios = javax.imageio.ImageIO.createImageOutputStream(os);
+ imageWriter.setOutput(ios);
+
+ imageWriter.write(new IIOImage(bufferedImage, null, null));
+ ios.flush();
+ imageWriter.dispose();
+ }
+
+ /**
+ * Adapter method used to convert any type of Source to a String
+ *
+ * @param input
+ * @return
+ */
+ public static String toString(Source input) {
+
+ if (input == null)
+ return null;
+
+ StringWriter writer = new StringWriter();
+ Transformer trasformer;
+ try {
+ trasformer = TransformerFactory.newInstance().newTransformer();
+ Result result = new StreamResult(writer);
+ trasformer.transform(input, result);
+ } catch (Exception e) {
+ return null;
+ }
+
+ return writer.getBuffer().toString();
+ }
+
+ /**
+ * Adapter method used to convert any type of SOAPMessage to a String
+ *
+ * @param input
+ * @return
+ */
+ public static String toString(SOAPMessage input) {
+
+ if (input == null)
+ return null;
+
+ Source result = null;
+ try {
+ result = input.getSOAPPart().getContent();
+ } catch (SOAPException e) {
+ e.printStackTrace();
+ }
+
+ return toString(result);
+ }
+
+ /**
+ * Method used to convert Strings to SOAPMessages
+ *
+ * @param msgString
+ * @return
+ */
+ public static SOAPMessage toSOAPMessage(String msgString) {
+
+ if (msgString == null) return null;
+
+ SOAPMessage message = null;
+ try {
+ MessageFactory factory = null;
+
+ // Force the usage of specific MesasgeFactories
+ if (msgString.indexOf(SOAP11_NAMESPACE) >= 0) {
+ factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
+ } else {
+ factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+ }
+ message = factory.createMessage();
+ message.getSOAPPart().setContent((Source) new StreamSource(new StringReader(msgString)));
+ message.saveChanges();
+ } catch (SOAPException e) {
+ System.out.println("toSOAPMessage Exception encountered: " + e);
+ e.printStackTrace();
+ }
+ return message;
+ }
+
+}
+
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/DataSourceImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/DataSourceImpl.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/DataSourceImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/DataSourceImpl.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,116 @@
+/*
+ * 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 org.apache.axis2.jaxws.provider;
+
+import java.awt.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.activation.DataSource;
+
+/**
+ * An impl class for javax.activation.DataSource interface.
+ *
+ */
+public class DataSourceImpl implements DataSource {
+
+ private final String fileName;
+
+ private final String contentType;
+
+ private byte[] byteArray;
+
+ private ByteArrayOutputStream byteArrayOS;
+
+ /**
+ * Constructor
+ *
+ * @param _contentType
+ * @param _fileName
+ * @param image
+ * @throws Exception
+ */
+ public DataSourceImpl(String _contentType, String _fileName, Image image) throws Exception{
+ super();
+
+ try {
+ if((_contentType == null) || (_contentType == "")){
+ throw new NullPointerException("Type is NULL: Must provide content type");
+ }
+ if((_fileName == null) || (_contentType == "")){
+ throw new NullPointerException("File name is NULL: Must provide content file name");
+ }
+
+ this.fileName = _fileName;
+ this.contentType = _contentType;
+
+ if (image != null) {
+ byteArrayOS = new ByteArrayOutputStream();
+ AttachmentUtil.storeImage(this.contentType, image, byteArrayOS);
+ }
+ } catch (Exception e) {
+ throw e;
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.activation.DataSource#getContentType()
+ */
+ public String getContentType() {
+ return this.contentType;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.activation.DataSource#getInputStream()
+ */
+ public InputStream getInputStream() throws IOException {
+ if (this.byteArrayOS.size() != 0) {
+ this.byteArray = this.byteArrayOS.toByteArray();
+ this.byteArrayOS.reset();
+ }
+
+ if(this.byteArray == null){
+ return new ByteArrayInputStream(new byte[0]);
+
+ }
+ return new ByteArrayInputStream(this.byteArray);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.activation.DataSource#getName()
+ */
+ public String getName() {
+ return this.fileName;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.activation.DataSource#getOutputStream()
+ */
+ public OutputStream getOutputStream() throws IOException {
+ if (this.byteArrayOS.size() != 0) {
+ this.byteArray = this.byteArrayOS.toByteArray();
+ this.byteArrayOS.reset();
+ }
+ return this.byteArrayOS;
+ }
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/GenericOperationProviderTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/GenericOperationProviderTest.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/GenericOperationProviderTest.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/GenericOperationProviderTest.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,168 @@
+/*
+ * 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 org.apache.axis2.jaxws.provider;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.jaxws.description.DescriptionFactory;
+import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.axis2.jaxws.description.EndpointInterfaceDescription;
+import org.apache.axis2.jaxws.description.OperationDescription;
+import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.axis2.jaxws.dispatchers.GenericProviderDispatcher;
+
+import javax.jws.WebService;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.Provider;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.http.HTTPBinding;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class GenericOperationProviderTest extends TestCase {
+
+ public void testGenericHTTPBindingOperation() {
+ // The HTTP binding supports a generic operation for WSDL-less endpoints.
+ ServiceDescription serviceDesc = DescriptionFactory.createServiceDescription(HTTPBindingProviderImpl.class);
+ assertNotNull(serviceDesc);
+ EndpointDescription endpointDesc = serviceDesc.getEndpointDescriptions_AsCollection().iterator().next();
+ assertNotNull(endpointDesc);
+ AxisService axisSvc = endpointDesc.getAxisService();
+ assertNotNull(axisSvc);
+
+ EndpointInterfaceDescription interfaceDesc = endpointDesc.getEndpointInterfaceDescription();
+ assertNotNull(interfaceDesc);
+
+ // There should be a single OpDesc with a single AxisOperation with a specific name
+ OperationDescription opDescs[] = interfaceDesc.getOperations();
+ assertNotNull(opDescs);
+ assertEquals(1, opDescs.length);
+ AxisOperation axisOperation = opDescs[0].getAxisOperation();
+ assertNotNull(axisOperation);
+ assertEquals(EndpointInterfaceDescription.JAXWS_NOWSDL_PROVIDER_OPERATION_NAME, axisOperation.getName().getLocalPart());
+
+ // Now verify that the special dispather can find this operation
+ GenericProviderDispatcher dispatcher = new GenericProviderDispatcher();
+ MessageContext messageContext = new MessageContext();
+ messageContext.setAxisService(axisSvc);
+
+ try {
+ // The dispatcher will not try to resolve an AxisService
+ assertNull(dispatcher.findService(messageContext));
+
+ // The dispatcher should find the special AxisOperation
+ assertEquals(axisOperation, dispatcher.findOperation(axisSvc, messageContext));
+ } catch (AxisFault e) {
+ fail("Unexpected exception" + e);
+ }
+ }
+
+ public void testGenericSOAPBindingOperation() {
+ // REVIEW: Currently generic operations are not supported for SOAP Bindings
+
+ ServiceDescription serviceDesc = DescriptionFactory.createServiceDescription(SOAPBindingProviderImpl.class);
+ assertNotNull(serviceDesc);
+ EndpointDescription endpointDesc = serviceDesc.getEndpointDescriptions_AsCollection().iterator().next();
+ assertNotNull(endpointDesc);
+ AxisService axisSvc = endpointDesc.getAxisService();
+ assertNotNull(axisSvc);
+
+ // Since there's no WSDL, there will be no operations and no EndpointInterfaceDescription
+ // because this is a SOAPBinding.
+ EndpointInterfaceDescription interfaceDesc = endpointDesc.getEndpointInterfaceDescription();
+ assertNull(interfaceDesc);
+ }
+
+ public void testSEIBasedEndpoint() {
+ ServiceDescription serviceDesc = DescriptionFactory.createServiceDescription(SEIBasedEndpoint.class);
+ assertNotNull(serviceDesc);
+ EndpointDescription endpointDesc = serviceDesc.getEndpointDescriptions_AsCollection().iterator().next();
+ assertNotNull(endpointDesc);
+ AxisService axisSvc = endpointDesc.getAxisService();
+ assertNotNull(axisSvc);
+
+ EndpointInterfaceDescription interfaceDesc = endpointDesc.getEndpointInterfaceDescription();
+ assertNotNull(interfaceDesc);
+
+ // There should be a single OpDesc with a single AxisOperation based on the SEI below
+ // But it should not be the special named operation and the special dispatcher should not
+ // return null for operation dispatch
+ OperationDescription opDescs[] = interfaceDesc.getOperations();
+ assertNotNull(opDescs);
+ assertEquals(1, opDescs.length);
+ AxisOperation axisOperation = opDescs[0].getAxisOperation();
+ assertNotNull(axisOperation);
+ if (EndpointInterfaceDescription.JAXWS_NOWSDL_PROVIDER_OPERATION_NAME.equals(axisOperation.getName().getLocalPart())) {
+ fail("Operation has the generic provider name");
+ }
+
+ // Now verify that the special dispather doesn't find the special operation
+ GenericProviderDispatcher dispatcher = new GenericProviderDispatcher();
+ MessageContext messageContext = new MessageContext();
+ messageContext.setAxisService(axisSvc);
+
+ try {
+ // The dispatcher will not try to resolve an AxisService
+ assertNull(dispatcher.findService(messageContext));
+
+ // The dispatcher should find the special AxisOperation
+ assertNull(dispatcher.findOperation(axisSvc, messageContext));
+ } catch (AxisFault e) {
+ fail("Unexpected exception" + e);
+ }
+
+ }
+}
+
+
+// Notice no WSDL is specified
+@WebServiceProvider()
+@BindingType(value=HTTPBinding.HTTP_BINDING)
+@ServiceMode(value=javax.xml.ws.Service.Mode.MESSAGE)
+class HTTPBindingProviderImpl implements Provider<String> {
+
+ public String invoke(String obj) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
+//Notice no WSDL is specified
+@WebServiceProvider()
+class SOAPBindingProviderImpl implements Provider<String> {
+
+ public String invoke(String obj) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
+
+// SEI based endpoint to make sure it doesn't get get the special generic provider operation added
+@WebService()
+class SEIBasedEndpoint {
+ public String echo() {
+ return null;
+ }
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/JAXBProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/JAXBProviderTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/JAXBProviderTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/JAXBProviderTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,160 @@
+/*
+ * 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 org.apache.axis2.jaxws.provider;
+
+import java.awt.*;
+import java.io.File;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.imageio.ImageIO;
+import javax.imageio.stream.FileImageInputStream;
+import javax.imageio.stream.ImageInputStream;
+import javax.xml.bind.JAXBContext;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+
+import org.apache.axiom.attachments.ByteArrayDataSource;
+import org.apache.axis2.jaxws.TestLogger;
+import org.test.mtom.ImageDepot;
+import org.test.mtom.ObjectFactory;
+import org.test.mtom.SendImage;
+import org.test.mtom.SendImageResponse;
+
+/**
+ * The intended purpose of this testcase is to test the MTOM functions in Axis2.
+ * It demostrate an alternative way of sending an attachment using DataHandler.
+ *
+ * This testcase uses a JAXWS Dispatch invocation with JAXB generated request object
+ * as parameter. The endpoint for these testcase is a JAXWS Source Provider.
+ *
+ * These JAXB generated artifacts is based on jaxws\test-resources\xsd\samplemtom.xsd
+ * schema.
+ *
+ * Available Content types are:
+ * "image/gif"
+ * "image/jpeg"
+ * "text/plain"
+ * "multipart/*"
+ * "text/xml"
+ * "application/xml"
+ * This initial testcase only covers the "multipart/*" and "text/plain" mime types.
+ * The ultimate goal is to provide testcases for the remaining mime types.
+ *
+ */
+public class JAXBProviderTests extends ProviderTestCase {
+
+ String endpointUrl = "http://localhost:6060/axis2/services/JAXBProviderService.JAXBProviderPort";
+ private QName serviceName = new QName("http://ws.apache.org/axis2", "JAXBProviderService");
+ DataSource stringDS, imageDS;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ //Create a DataSource from a String
+ String string = "Sending a JAXB generated string object to Source Provider endpoint";
+ stringDS = new ByteArrayDataSource(string.getBytes(),"text/plain");
+
+ //Create a DataSource from an image
+ File file = new File(imageResourceDir+File.separator+"test.jpg");
+ ImageInputStream fiis = new FileImageInputStream(file);
+ Image image = ImageIO.read(fiis);
+ imageDS = new DataSourceImpl("image/jpeg","test.jpg",image);
+
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public JAXBProviderTests(String name) {
+ super(name);
+ }
+
+ /**
+ * test String
+ * @throws Exception
+ */
+ public void testMTOMAttachmentString() throws Exception {
+ TestLogger.logger.debug("---------------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ //Create a DataHandler with the String DataSource object
+ DataHandler dataHandler = new DataHandler(stringDS);
+
+ //Store the data handler in ImageDepot bean
+ ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+ imageDepot.setImageData(dataHandler);
+
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName, null, endpointUrl);
+
+ JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+
+ Dispatch<Object> dispatch = svc
+ .createDispatch(portName, jbc, Service.Mode.PAYLOAD);
+
+ //Create a request bean with imagedepot bean as value
+ ObjectFactory factory = new ObjectFactory();
+ SendImage request = factory.createSendImage();
+ request.setInput(imageDepot);
+
+ TestLogger.logger.debug(">> Invoking Dispatch<Object> JAXBProviderService");
+
+ SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
+
+ TestLogger.logger.debug(">> Response [" + response.toString() + "]");
+ }
+
+ /**
+ * test Image
+ * @throws Exception
+ */
+ public void testMTOMAttachmentImage() throws Exception {
+ TestLogger.logger.debug("---------------------------------------");
+ TestLogger.logger.debug("test: " + getName());
+
+ //Create a DataHandler with the String DataSource object
+ DataHandler dataHandler = new DataHandler(imageDS);
+
+ //Store the data handler in ImageDepot bean
+ ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+ imageDepot.setImageData(dataHandler);
+
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName, null, endpointUrl);
+
+ JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+
+ Dispatch<Object> dispatch = svc
+ .createDispatch(portName, jbc, Service.Mode.PAYLOAD);
+
+ //Create a request bean with imagedepot bean as value
+ ObjectFactory factory = new ObjectFactory();
+ SendImage request = factory.createSendImage();
+ request.setInput(imageDepot);
+
+ TestLogger.logger.debug(">> Invoking Dispatch<Object> JAXBProviderService");
+
+ SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
+
+ TestLogger.logger.debug(">> Response [" + response.toString() + "]");
+ }
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/ProviderTestCase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/ProviderTestCase.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/ProviderTestCase.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/ProviderTestCase.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,55 @@
+/*
+ * 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 org.apache.axis2.jaxws.provider;
+
+import java.io.File;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+public abstract class ProviderTestCase extends TestCase {
+
+ public QName portName = new QName("http://ws.apache.org/axis2", "SimpleProviderServiceSOAP11port0");
+ public String providerResourceDir = "test-resources"+File.separator+"provider";
+ public String imageResourceDir = "test-resources"+File.separator+"image";
+ public String basedir = null;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ //StartServer startServer = new StartServer("server1");
+ //startServer.testStartServer();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ //StopServer stopServer = new StopServer("server1");
+ //stopServer.testStopServer();
+ }
+
+ public ProviderTestCase(String name) {
+ super(name);
+ if(basedir == null){
+ basedir = new File(System.getProperty("basedir",".")).getAbsolutePath();
+ }
+ providerResourceDir = new File(basedir, providerResourceDir).getAbsolutePath();
+ imageResourceDir = new File(basedir, imageResourceDir).getAbsolutePath();
+ }
+
+}
\ No newline at end of file
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/SOAPFaultProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/SOAPFaultProviderTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/SOAPFaultProviderTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/SOAPFaultProviderTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,86 @@
+/*
+ * 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 org.apache.axis2.jaxws.provider;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class SOAPFaultProviderTests extends TestCase {
+ public QName portName =
+ new QName("http://ws.apache.org/axis2", "SimpleProviderServiceSOAP11port0");
+ private QName serviceName = new QName("http://ws.apache.org/axis2", "StringProviderService");
+
+ String endpointUrl = "http://localhost:6060/axis2/services/StringProviderService.StringProviderPort";
+
+ private static final String sampleSoapEnvelopeHeader =
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ + "<soap:Body>";
+
+ private static final String sampleSoapEnvelopeFooter = "</soap:Body>" + "</soap:Envelope>";
+
+ private static final String soapFaultBodyContent =
+ "<soap:Fault>"
+ + "<faultcode>soap:SOAPFaultProviderTests</faultcode>"
+ + "<faultstring>WSA-CP2-GENERATED-FAULT: FAULT01</faultstring>"
+ + "</soap:Fault>";
+
+
+ public SOAPFaultProviderTests(String name) {
+ super(name);
+ }
+
+ private Dispatch<String> getDispatch() {
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
+
+ // Use Message mode so we can build up the entire SOAP envelope containing the fault
+ Dispatch<String> dispatch =
+ svc.createDispatch(portName, String.class, Service.Mode.MESSAGE);
+
+ // Force soap action because we are passing junk over the wire
+ dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
+ dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "http://stringprovider.sample.test.org/echoString");
+
+ return dispatch;
+ }
+
+ public void testFault() {
+ System.out.println("---------------------------------------");
+ System.out.println("test: " + getName());
+
+ Dispatch<String> dispatch = getDispatch();
+ String request = sampleSoapEnvelopeHeader + soapFaultBodyContent + sampleSoapEnvelopeFooter;
+ // Test that a Provider receives the full fault. If not, it will throw an exception
+ try {
+ String response = dispatch.invoke(request);
+ }
+ catch (Exception e) {
+ fail("Caught unexpected exception " + e.toString());
+ }
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/SoapMessageMUProviderChecker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/SoapMessageMUProviderChecker.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/SoapMessageMUProviderChecker.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/SoapMessageMUProviderChecker.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,67 @@
+/*
+ * 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 org.apache.axis2.jaxws.provider;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+
+import javax.xml.namespace.QName;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * Plugin to remove "understood" headers for the SoapMessageMUProviderTests. This class must
+ * be configured in the axis2.xml file on both the client and the server.
+ */
+public class SoapMessageMUProviderChecker extends org.apache.axis2.handlers.AbstractHandler {
+
+ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+ // Get the list of headers for the roles we're acting in, then mark any we understand
+ // as processed.
+ SOAPEnvelope envelope = msgContext.getEnvelope();
+ if (envelope.getHeader() == null) {
+ return InvocationResponse.CONTINUE;
+ }
+ // These are the headers the test expects to be understood
+ String ns1 = "http://ws.apache.org/axis2";
+ String clientLocalName = "muclientunderstood";
+ String serverLocalName = "muserverunderstood";
+
+ QName clientQN = new QName(ns1, clientLocalName);
+ QName serverQN = new QName(ns1, serverLocalName);
+
+ Iterator headerBlocks = envelope.getHeader().getHeadersToProcess(null);
+ while (headerBlocks.hasNext()) {
+ SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) headerBlocks.next();
+ QName headerQN = headerBlock.getQName();
+ if (clientQN.equals(headerQN)) {
+// System.out.println("Marking as processed CLIENT QN: " + clientQN);
+ headerBlock.setProcessed();
+ } else if (serverQN.equals(headerQN)) {
+// System.out.println("Marking as processed SERVER QN: " + serverQN);
+ headerBlock.setProcessed();
+ }
+ }
+
+ return InvocationResponse.CONTINUE;
+ }
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/SoapMessageMUProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/SoapMessageMUProviderTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/SoapMessageMUProviderTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/SoapMessageMUProviderTests.java Mon Mar 3 10:47:38 2008
@@ -0,0 +1,201 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2007 International Business Machines Corp.
+ *
+ * Licensed 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 org.apache.axis2.jaxws.provider;
+
+
+import javax.xml.ws.Service;
+import javax.xml.namespace.QName;
+import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.BindingProvider;
+import javax.xml.soap.SOAPMessage;
+import junit.framework.TestCase;
+
+/**
+ * Tests Dispatch<SOAPMessage> client and a Provider<SOAPMessage> service
+ * with mustUnderstand attribute header.
+ */
+public class SoapMessageMUProviderTests extends TestCase {
+ public static final QName serviceName =
+ new QName("http://ws.apache.org/axis2", "SoapMessageMUProviderService");
+ public static final QName portName =
+ new QName("http://ws.apache.org/axis2", "SimpleProviderServiceSOAP11port0");
+ public static final String endpointUrl =
+ "http://localhost:6060/axis2/services/SoapMessageMUProviderService.SimpleProviderServiceSOAP11port0";
+
+ public static final String bindingID = SOAPBinding.SOAP11HTTP_BINDING;
+ public static final Service.Mode mode = Service.Mode.MESSAGE;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public SoapMessageMUProviderTests(String name) {
+ super(name);
+ }
+
+ /**
+ * Test soap message with no MU headers
+ */
+ public void testNoMustUnderstandHeaders() {
+ System.out.println("testNoMustUnderstandHeaders");
+ // create a service
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName, bindingID, endpointUrl);
+
+ javax.xml.ws.Dispatch<SOAPMessage> dispatch = null;
+ dispatch = svc.createDispatch(portName, SOAPMessage.class, mode);
+
+ ((BindingProvider) dispatch).getRequestContext()
+ .put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
+ ((BindingProvider) dispatch).getRequestContext()
+ .put(BindingProvider.SOAPACTION_URI_PROPERTY, "echoString");
+
+ SOAPMessage message = AttachmentUtil.toSOAPMessage(AttachmentUtil.msgEnvPlain);
+
+ try {
+ SOAPMessage response = dispatch.invoke(message);
+
+ String string = AttachmentUtil.toString(response);
+ assertTrue(string.equalsIgnoreCase(AttachmentUtil.XML_HEADER
+ + AttachmentUtil.msgEnvPlain));
+ } catch (Exception e) {
+ fail("Unexpected Exception: " + e.getMessage());
+ }
+ }
+
+ /**
+ * Test the mustUnderstand soap header attribute on the client's
+ * outbound soap message for headers that are not understood. Should cause an
+ * exception.
+ */
+ public void testClientRequestNotUnderstoodHeaders() {
+ System.out.println("testClientRequestNotUnderstoodHeaders");
+ // create a service
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName, bindingID, endpointUrl);
+
+ javax.xml.ws.Dispatch<SOAPMessage> dispatch = null;
+ dispatch = svc.createDispatch(portName, SOAPMessage.class, mode);
+
+ //force SOAPAction to match with wsdl action
+ ((BindingProvider) dispatch).getRequestContext()
+ .put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
+ ((BindingProvider) dispatch).getRequestContext()
+ .put(BindingProvider.SOAPACTION_URI_PROPERTY, "echoString");
+
+ SOAPMessage message = AttachmentUtil.toSOAPMessage(AttachmentUtil.msgEnvMU);
+
+ try {
+ dispatch.invoke(message);
+ fail("Should have received fault for not understood headers on request");
+ } catch (Exception e) {
+ // Expected path
+ }
+ }
+
+ /**
+ * Test the mustUnderstand soap header attribute on the server's
+ * outbound soap message (i.e. the inbound response to the client) for headers that
+ * are not understood. Should cause an exception.
+ */
+ public void testClientResponseNotUnderstoodHeaders() {
+ System.out.println("testClientResponseNotUnderstoodHeaders");
+ // create a service
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName, bindingID, endpointUrl);
+
+ javax.xml.ws.Dispatch<SOAPMessage> dispatch = null;
+ dispatch = svc.createDispatch(portName, SOAPMessage.class, mode);
+
+ //force SOAPAction to match with wsdl action
+ ((BindingProvider) dispatch).getRequestContext()
+ .put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
+ ((BindingProvider) dispatch).getRequestContext()
+ .put(BindingProvider.SOAPACTION_URI_PROPERTY, "echoString");
+
+ SOAPMessage message = AttachmentUtil.toSOAPMessage(AttachmentUtil.msgEnv);
+
+ try {
+ dispatch.invoke(message);
+ fail("Should have received fault for not understood headers on response");
+ } catch (Exception e) {
+ // Expected path
+ }
+ }
+
+ /**
+ * Test the mustUnderstand soap header attribute on the client's
+ * outbound soap message for headers that should be understood. Should not cause an
+ * exception.
+ */
+ public void testClientRequestUnderstoodHeaders() {
+ System.out.println("testClientRequestUnderstoodHeaders");
+ // create a service
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName, bindingID, endpointUrl);
+
+ javax.xml.ws.Dispatch<SOAPMessage> dispatch = null;
+ dispatch = svc.createDispatch(portName, SOAPMessage.class, mode);
+
+ //force SOAPAction to match with wsdl action
+ ((BindingProvider) dispatch).getRequestContext()
+ .put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
+ ((BindingProvider) dispatch).getRequestContext()
+ .put(BindingProvider.SOAPACTION_URI_PROPERTY, "echoString");
+
+ SOAPMessage message = AttachmentUtil.toSOAPMessage(AttachmentUtil.msgEnvMU_understood);
+
+ try {
+ dispatch.invoke(message);
+ } catch (Exception e) {
+ fail("Should not have received fault for headers that were understood. " + e.getMessage());
+ }
+ }
+
+ /**
+ * Test the mustUnderstand soap header attribute on the server's
+ * outbound soap message (i.e. the inbound response to the client) for headers that
+ * are understood. Should not cause an exception.
+ */
+ public void testClientResponseUnderstoodHeaders() {
+ System.out.println("testClientResponseUnderstoodHeaders");
+ // create a service
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName, bindingID, endpointUrl);
+
+ javax.xml.ws.Dispatch<SOAPMessage> dispatch = null;
+ dispatch = svc.createDispatch(portName, SOAPMessage.class, mode);
+
+ //force SOAPAction to match with wsdl action
+ ((BindingProvider) dispatch).getRequestContext()
+ .put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
+ ((BindingProvider) dispatch).getRequestContext()
+ .put(BindingProvider.SOAPACTION_URI_PROPERTY, "echoString");
+
+ SOAPMessage message = AttachmentUtil.toSOAPMessage(AttachmentUtil.msgEnv_understood);
+
+ try {
+ dispatch.invoke(message);
+ } catch (Exception e) {
+ fail("Should not have received fault for headers that were understood. " + e.getMessage());
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org