axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ngalla...@apache.org
Subject svn commit: r442249 - in /webservices/axis2/trunk/java/modules/jaxws: ./ src/org/apache/axis2/jaxws/server/dispatcher/ test/org/apache/axis2/jaxws/framework/ test/org/apache/axis2/jaxws/provider/ test/org/apache/axis2/jaxws/provider/soapmsg/ test/org/a...
Date Mon, 11 Sep 2006 16:31:07 GMT
Author: ngallardo
Date: Mon Sep 11 09:31:05 2006
New Revision: 442249

URL: http://svn.apache.org/viewvc?view=rev&rev=442249
Log:
AXIS2-1119
Contributor: Jeff Barrett

Jeff's patch for adding MESSAGE mode support for the JAX-WS Provider.

Added:
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SoapMessageProviderTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SourceMessageProviderTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringMessageProviderTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/META-INF/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/META-INF/MANIFEST.MF
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/META-INF/services.xml
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/SoapMessageProvider.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/META-INF/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/META-INF/MANIFEST.MF
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/META-INF/services.xml
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/SourceMessageProvider.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/META-INF/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/META-INF/MANIFEST.MF
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/META-INF/services.xml
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/StringMessageProvider.java
Removed:
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SimpleProvider.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringProvider.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws/maven.xml
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SourceProviderTests.java

Modified: webservices/axis2/trunk/java/modules/jaxws/maven.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/maven.xml?view=diff&rev=442249&r1=442248&r2=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/maven.xml (original)
+++ webservices/axis2/trunk/java/modules/jaxws/maven.xml Mon Sep 11 09:31:05 2006
@@ -128,11 +128,44 @@
                 <ant:include name="org/apache/axis2/jaxws/server/**"/>
 			</ant:fileset>
 		</ant:copy>
+		<ant:copy toDir="target/test-classes/services/StringMessageProviderService/">
+			<ant:fileset dir="target/test-classes">
+				<ant:include name="org/apache/axis2/jaxws/provider/stringmsg/**"/>
+			</ant:fileset>
+			<ant:fileset dir="test/org/apache/axis2/jaxws/provider/stringmsg">
+                <ant:include name="META-INF/**"/>
+			</ant:fileset>
+			<ant:fileset dir="target/classes">
+                <ant:include name="org/apache/axis2/jaxws/server/**"/>
+			</ant:fileset>
+		</ant:copy>
 		<ant:copy toDir="target/test-classes/services/SourceProviderService/">
 			<ant:fileset dir="target/test-classes">
 				<ant:include name="org/apache/axis2/jaxws/provider/source/**"/>
 			</ant:fileset>
 			<ant:fileset dir="test/org/apache/axis2/jaxws/provider/source">
+                <ant:include name="META-INF/**"/>
+			</ant:fileset>
+			<ant:fileset dir="target/classes">
+                <ant:include name="org/apache/axis2/jaxws/server/**"/>
+			</ant:fileset>
+		</ant:copy>
+		<ant:copy toDir="target/test-classes/services/SourceMessageProviderService/">
+			<ant:fileset dir="target/test-classes">
+				<ant:include name="org/apache/axis2/jaxws/provider/sourcemsg/**"/>
+			</ant:fileset>
+			<ant:fileset dir="test/org/apache/axis2/jaxws/provider/sourcemsg">
+                <ant:include name="META-INF/**"/>
+			</ant:fileset>
+			<ant:fileset dir="target/classes">
+                <ant:include name="org/apache/axis2/jaxws/server/**"/>
+			</ant:fileset>
+		</ant:copy>
+		<ant:copy toDir="target/test-classes/services/SoapMessageProviderService/">
+			<ant:fileset dir="target/test-classes">
+				<ant:include name="org/apache/axis2/jaxws/provider/soapmsg/**"/>
+			</ant:fileset>
+			<ant:fileset dir="test/org/apache/axis2/jaxws/provider/soapmsg">
                 <ant:include name="META-INF/**"/>
 			</ant:fileset>
 			<ant:fileset dir="target/classes">

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java?view=diff&rev=442249&r1=442248&r2=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
Mon Sep 11 09:31:05 2006
@@ -22,19 +22,24 @@
 
 import javax.activation.DataSource;
 import javax.xml.bind.JAXBContext;
+import javax.xml.namespace.QName;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.transform.Source;
 import javax.xml.ws.Provider;
+import javax.xml.ws.Service;
 
+import org.apache.axiom.om.OMElement;
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.core.util.MessageContextUtils;
+import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.message.Block;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.Protocol;
 import org.apache.axis2.jaxws.message.factory.BlockFactory;
 import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.message.factory.SOAPEnvelopeBlockFactory;
 import org.apache.axis2.jaxws.message.factory.SourceBlockFactory;
 import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory;
 import org.apache.axis2.jaxws.registry.FactoryRegistry;
@@ -61,6 +66,7 @@
     private BlockFactory blockFactory = null;
 	private Class providerType = null;
     private Provider providerInstance = null;
+    private Service.Mode providerServiceMode = null;
     private Message message = null;
     private Protocol messageProtocol;
 
@@ -92,22 +98,53 @@
         Object requestParamValue = null;
         Message message = mc.getMessage();
         if (message != null) {
-            // Save off the protocol info so we can use it when creating
-            // the response message.
+            // Save off the protocol info so we can use it when creating the response message.
             messageProtocol = message.getProtocol();
-            
+            // Determine what type blocks we want to create (String, Source, etc) based on
Provider Type
             BlockFactory factory = createBlockFactory(providerType);
-            Block block = message.getBodyBlock(0, null, factory);
-            requestParamValue = block.getBusinessObject(true);
+            
+            // REVIEW: This assumes there is only one endpoint description on the service.
 Is that always the case?
+            EndpointDescription endpointDesc = mc.getServiceDescription().getEndpointDescriptions()[0];
+            providerServiceMode = endpointDesc.getServiceModeValue();
+            
+            if (providerServiceMode != null && providerServiceMode == Service.Mode.MESSAGE)
{
+                // For MESSAGE mode, work with the entire message, Headers and Body
+                // This is based on logic in org.apache.axis2.jaxws.client.XMLDispatch.getValueFromMessage()
+                if (providerType.equals(SOAPMessage.class)) {
+                    // We can get the SOAPMessage directly from the message itself
+                    requestParamValue = message.getAsSOAPMessage();
+                }
+                else {
+                    // For Source and String, we have to do some conversions using the block
factories
+                    // This is similar to the PAYLOAD logic, except it gets the entire message
as a block
+                    // rather than just the body block (which is what PAYLOAD mode does).
+                    // TODO: This doesn't seem right to me. We should not have an intermediate
StringBlock. This is not performant. Scheu 
+                    OMElement messageOM = message.getAsOMElement();
+                    String stringValue = messageOM.toString();  
+                    QName soapEnvQname = new QName("http://schemas.xmlsoap.org/soap/envelope/",
"Envelope");
+                    XMLStringBlockFactory stringFactory = (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+                    Block stringBlock = stringFactory.createFrom(stringValue, null, soapEnvQname);
  
+                    Block messageBlock = factory.createFrom(stringBlock, null);
+                    requestParamValue = messageBlock.getBusinessObject(true);
+                }
+            }
+            else {
+                // If it is not MESSAGE, then it is PAYLOAD (which is the default); only
work with the body 
+                Block block = message.getBodyBlock(0, null, factory);
+                requestParamValue = block.getBusinessObject(true);
+            }
         }
 
+        if (log.isDebugEnabled())
+            log.debug("Provider Type = " + providerType + "; parameter type = " + requestParamValue);
+        
         Object input = providerType.cast(requestParamValue);
-
         if (log.isDebugEnabled()) {
             log.debug("Invoking Provider<" + providerType.getName() + "> with " +
                     "parameter of type " + input.getClass().getName());
         }
 
+
         // Invoke the actual Provider.invoke() method
         Object responseParamValue = null;
         try {
@@ -171,20 +208,34 @@
      * Create a Message object out of the value object that was returned.
      */
     private Message createMessageFromValue(Object value) throws Exception {
-        if (log.isDebugEnabled()) {
-            log.debug("Creating response Message from value of type " + 
-                    value.getClass().getName());
-        }
-        
-        MessageFactory msgFactory = (MessageFactory) FactoryRegistry.getFactory(
-                MessageFactory.class);
-        Message message = msgFactory.create(messageProtocol);
+        MessageFactory msgFactory = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
+        Message message = null;
         
         if (value != null) {
             BlockFactory factory = createBlockFactory(providerType);
-            Block block = factory.createFrom(value, null, null);
-            message.setBodyBlock(0, block);
+            if (providerServiceMode != null && providerServiceMode == Service.Mode.MESSAGE)
{
+                // For MESSAGE mode, work with the entire message, Headers and Body
+                // This is based on logic in org.apache.axis2.jaxws.client.XMLDispatch.createMessageFromBundle()
+                if (value instanceof SOAPMessage) {
+                    message = msgFactory.createFrom((SOAPMessage) value);
+                }
+                else {
+                    Block block = factory.createFrom(value, null, null);
+                    message = msgFactory.createFrom(block, null);
+                }
+            }
+            else {
+                // PAYLOAD mode deals only with the body of the message.
+                Block block = factory.createFrom(value, null, null);
+                message = msgFactory.create(messageProtocol);
+                message.setBodyBlock(0, block);
+            }
         }
+        
+        if (message == null)
+            // If we didn't create a message above (because there was no value), create one
here
+            message = msgFactory.create(messageProtocol);
+            
 
         return message;
     }
@@ -288,6 +339,10 @@
         else if (type.equals(Source.class)) {
             blockFactory = (SourceBlockFactory) FactoryRegistry.getFactory(
                     SourceBlockFactory.class);
+        }
+        else if (type.equals(SOAPMessage.class)) {
+            blockFactory = (SOAPEnvelopeBlockFactory) FactoryRegistry.getFactory(
+                    SOAPEnvelopeBlockFactory.class);
         }
         else {
             ExceptionFactory.makeWebServiceException("Unable to find BlockFactory " +

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?view=diff&rev=442249&r1=442248&r2=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
Mon Sep 11 09:31:05 2006
@@ -72,7 +72,10 @@
         suite.addTestSuite(JaxwsMessageBundleTests.class);
         
         suite.addTestSuite(StringProviderTests.class);
+        suite.addTestSuite(StringMessageProviderTests.class);
         suite.addTestSuite(SourceProviderTests.class);
+        suite.addTestSuite(SourceMessageProviderTests.class);
+        suite.addTestSuite(SoapMessageProviderTests.class);
         suite.addTestSuite(JAXBProviderTests.class);
         suite.addTestSuite(ProxyTests.class);
         suite.addTestSuite(ProxyNonWrappedTests.class);

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SoapMessageProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SoapMessageProviderTests.java?view=auto&rev=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SoapMessageProviderTests.java
(added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SoapMessageProviderTests.java
Mon Sep 11 09:31:05 2006
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 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 java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Map;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+public class SoapMessageProviderTests extends ProviderTestCase {
+
+    private String endpointUrl = "http://localhost:8080/axis2/services/SoapMessageProviderService";
+    private QName serviceName = new QName("http://ws.apache.org/axis2", "SoapMessageProviderService");
+    private String xmlDir = "xml";
+    private String reqMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><ns2:invoke
xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>some request</invoke_str></ns2:invoke></soap:Body></soap:Envelope>";
+
+
+    protected void setUp() throws Exception {
+            super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+            super.tearDown();
+    }
+
+    public SoapMessageProviderTests(String name) {
+        super(name);
+    }
+    
+    public void testProviderSource(){
+        try{
+//        	String resourceDir = new File(providerResourceDir, xmlDir).getAbsolutePath();
+//        	String fileName = resourceDir+File.separator+"web.xml";
+//        	
+//        	File file = new File(fileName);
+//        	InputStream inputStream = new FileInputStream(file);
+//        	StreamSource xmlStreamSource = new StreamSource(inputStream);
+//        	
+        	Service svc = Service.create(serviceName);
+        	svc.addPort(portName,null, endpointUrl);
+        	Dispatch<SOAPMessage> dispatch = svc.createDispatch(portName, SOAPMessage.class,
Service.Mode.MESSAGE);
+        	System.out.println(">> Invoking SourceMessageProviderDispatch");
+            MessageFactory factory = MessageFactory.newInstance();
+            SOAPMessage outboundMessage = factory.createMessage(null, 
+                    new ByteArrayInputStream(reqMsg.getBytes()));
+        	SOAPMessage response = dispatch.invoke(outboundMessage);
+
+        	System.out.println(">> Response [" + response.toString() + "]");
+            response.writeTo(System.out);
+        	
+        }catch(Exception e){
+        	e.printStackTrace();
+            fail("Caught exception " + e);
+        }
+        
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SourceMessageProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SourceMessageProviderTests.java?view=auto&rev=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SourceMessageProviderTests.java
(added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SourceMessageProviderTests.java
Mon Sep 11 09:31:05 2006
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 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 java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Map;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+public class SourceMessageProviderTests extends ProviderTestCase {
+
+    private String endpointUrl = "http://localhost:8080/axis2/services/SourceMessageProviderService";
+    private QName serviceName = new QName("http://ws.apache.org/axis2", "SourceMessageProviderService");
+    private String xmlDir = "xml";
+
+
+    protected void setUp() throws Exception {
+            super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+            super.tearDown();
+    }
+
+    public SourceMessageProviderTests(String name) {
+        super(name);
+    }
+    
+    public void testProviderSource(){
+        try{
+        	String resourceDir = new File(providerResourceDir, xmlDir).getAbsolutePath();
+        	String fileName = resourceDir+File.separator+"web.xml";
+        	
+        	File file = new File(fileName);
+        	InputStream inputStream = new FileInputStream(file);
+        	StreamSource xmlStreamSource = new StreamSource(inputStream);
+        	
+        	Service svc = Service.create(serviceName);
+        	svc.addPort(portName,null, endpointUrl);
+        	Dispatch<Source> dispatch = svc.createDispatch(portName, Source.class, null);
+        	System.out.println(">> Invoking SourceMessageProviderDispatch");
+        	Source response = dispatch.invoke(xmlStreamSource);
+
+        	System.out.println(">> Response [" + response.toString() + "]");
+        	
+        }catch(Exception e){
+        	e.printStackTrace();
+            fail("Caught exception " + e);
+        }
+        
+    }
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SourceProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SourceProviderTests.java?view=diff&rev=442249&r1=442248&r2=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SourceProviderTests.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SourceProviderTests.java
Mon Sep 11 09:31:05 2006
@@ -66,6 +66,7 @@
         	
         }catch(Exception e){
         	e.printStackTrace();
+            fail("Caught exception " + e);
         }
         
     }

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringMessageProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringMessageProviderTests.java?view=auto&rev=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringMessageProviderTests.java
(added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/StringMessageProviderTests.java
Mon Sep 11 09:31:05 2006
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 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 java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+
+public class StringMessageProviderTests extends ProviderTestCase {
+
+    String endpointUrl = "http://localhost:8080/axis2/services/StringMessageProviderService";
+    String xmlString = "<invoke>test input</invoke>";
+    private QName serviceName = new QName("http://ws.apache.org/axis2", "StringMessageProviderService");
+
+    protected void setUp() throws Exception {
+            super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+            super.tearDown();
+    }
+
+    public StringMessageProviderTests(String name) {
+        super(name);
+    }
+    
+    public void testProviderString() throws Exception {
+        System.out.println("---------------------------------------");
+        System.out.println("test: " + getName());
+        
+        Service svc = Service.create(serviceName);
+        svc.addPort(portName, null, endpointUrl);
+        
+        Dispatch<String> dispatch = svc
+                .createDispatch(portName, String.class, Service.Mode.PAYLOAD);
+        
+        System.out.println(">> Invoking Dispatch<String> StringMessageProviderService");
+        String retVal = dispatch.invoke(xmlString);
+        System.out.println(">> Response [" + retVal + "]");
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/META-INF/MANIFEST.MF?view=auto&rev=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/META-INF/MANIFEST.MF
(added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/META-INF/MANIFEST.MF
Mon Sep 11 09:31:05 2006
@@ -0,0 +1 @@
+Manifest-Version: 1.0

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/META-INF/services.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/META-INF/services.xml?view=auto&rev=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/META-INF/services.xml
(added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/META-INF/services.xml
Mon Sep 11 09:31:05 2006
@@ -0,0 +1,12 @@
+<serviceGroup>
+ <service name="SoapMessageProviderService">
+  <messageReceivers>
+   <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.jaxws.server.JAXWSMessageReceiver"/>
+  </messageReceivers>
+  <parameter locked="false" name="ServiceClass">org.apache.axis2.jaxws.provider.soapmsg.SoapMessageProvider</parameter>
+  <operation name="invoke" mep="http://www.w3.org/2004/08/wsdl/in-out">
+    <actionMapping/>
+  </operation>
+ </service>
+</serviceGroup>
+

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/SoapMessageProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/SoapMessageProvider.java?view=auto&rev=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/SoapMessageProvider.java
(added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/SoapMessageProvider.java
Mon Sep 11 09:31:05 2006
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 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.soapmsg;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPMessage;
+
+@WebServiceProvider()
+@ServiceMode(value=Service.Mode.MESSAGE)
+public class SoapMessageProvider implements Provider<SOAPMessage> {
+    String responseAsString = new String("<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header/><soapenv:Body><ns2:ReturnType
xmlns:ns2=\"http://test\"><return_str>some response</return_str></ns2:ReturnType></soapenv:Body></soapenv:Envelope>");
+    public SOAPMessage invoke(SOAPMessage soapMessage) {
+    	System.out.println(">> SoapMessageProvider: Request received.");
+    	
+    	try{
+    	    // Look at the incoming request message
+            System.out.println(">> Request on Server:");
+            soapMessage.writeTo(System.out);
+            System.out.println("\n");
+            
+            // Build the outgoing response message
+            SOAPMessage message = null;
+            MessageFactory factory = MessageFactory.newInstance();
+            message = factory.createMessage(null, new ByteArrayInputStream(responseAsString.getBytes()));
+
+            System.out.println(">> Response being sent by Server:");
+            message.writeTo(System.out);
+            System.out.println("\n");
+            return message;
+    	}catch(Exception e){
+            System.out.println("***ERROR: In SoapMessageProvider.invoke: Caught exception
" + e);
+    		e.printStackTrace();
+    	}
+    	return null;
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/META-INF/MANIFEST.MF?view=auto&rev=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/META-INF/MANIFEST.MF
(added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/META-INF/MANIFEST.MF
Mon Sep 11 09:31:05 2006
@@ -0,0 +1 @@
+Manifest-Version: 1.0

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/META-INF/services.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/META-INF/services.xml?view=auto&rev=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/META-INF/services.xml
(added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/META-INF/services.xml
Mon Sep 11 09:31:05 2006
@@ -0,0 +1,12 @@
+<serviceGroup>
+ <service name="SourceMessageProviderService">
+  <messageReceivers>
+   <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.jaxws.server.JAXWSMessageReceiver"/>
+  </messageReceivers>
+  <parameter locked="false" name="ServiceClass">org.apache.axis2.jaxws.provider.sourcemsg.SourceMessageProvider</parameter>
+  <operation name="invoke" mep="http://www.w3.org/2004/08/wsdl/in-out">
+    <actionMapping/>
+  </operation>
+ </service>
+</serviceGroup>
+

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/SourceMessageProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/SourceMessageProvider.java?view=auto&rev=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/SourceMessageProvider.java
(added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/SourceMessageProvider.java
Mon Sep 11 09:31:05 2006
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 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.sourcemsg;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.StringWriter;
+
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+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;
+
+import org.apache.axis2.jaxws.DispatchTestConstants;
+
+@WebServiceProvider()
+@ServiceMode(value=Service.Mode.MESSAGE)
+public class SourceMessageProvider implements Provider<Source> {
+    String responseAsString = new String("<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header/><soapenv:Body><ns2:ReturnType
xmlns:ns2=\"http://test\"><return_str>some response</return_str></ns2:ReturnType></soapenv:Body></soapenv:Envelope>");
+    public Source invoke(Source source) {
+    	System.out.println(">> SourceMessageProvider: Request received.");
+    	//System.out.println(">> Source toString: \n"+source.toString());
+    	
+    	try{
+    		StringWriter writer = new StringWriter();
+	        Transformer t = TransformerFactory.newInstance().newTransformer();
+	        Result result = new StreamResult(writer);
+	        t.transform(source, result);
+	        System.out.println(">> Source Request on Server: \n"+writer.getBuffer().toString());
+	        
+	    	byte[] bytes = responseAsString.getBytes();
+	        ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
+	        Source srcStream = new StreamSource((InputStream) stream);
+	        return srcStream;
+    	}catch(Exception e){
+    		e.printStackTrace();
+    	}
+    	return null;
+    }
+    	
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/META-INF/MANIFEST.MF?view=auto&rev=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/META-INF/MANIFEST.MF
(added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/META-INF/MANIFEST.MF
Mon Sep 11 09:31:05 2006
@@ -0,0 +1 @@
+Manifest-Version: 1.0

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/META-INF/services.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/META-INF/services.xml?view=auto&rev=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/META-INF/services.xml
(added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/META-INF/services.xml
Mon Sep 11 09:31:05 2006
@@ -0,0 +1,12 @@
+<serviceGroup>
+ <service name="StringMessageProviderService">
+  <messageReceivers>
+   <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.jaxws.server.JAXWSMessageReceiver"/>
+  </messageReceivers>
+  <parameter locked="false" name="ServiceClass">org.apache.axis2.jaxws.provider.stringmsg.StringMessageProvider</parameter>
+  <operation name="invoke" mep="http://www.w3.org/2004/08/wsdl/in-out">
+    <actionMapping/>
+  </operation>
+ </service>
+</serviceGroup>
+

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/StringMessageProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/StringMessageProvider.java?view=auto&rev=442249
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/StringMessageProvider.java
(added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/stringmsg/StringMessageProvider.java
Mon Sep 11 09:31:05 2006
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 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.stringmsg;
+
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+
+@WebServiceProvider()
+@ServiceMode(value=Service.Mode.MESSAGE)
+public class StringMessageProvider implements Provider<String> {
+    private static String responseGood = "<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header /><soapenv:Body><provider><message>request
processed</message></provider></soapenv:Body></soapenv:Envelope>";
+    private static String responseBad  = "<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header /><soapenv:Body><provider><message>ERROR:null
request received</message><provider></soapenv:Body></soapenv:Envelope>";
+    
+    public String invoke(String obj) {
+        if (obj != null) {
+            String str = (String) obj;
+            System.out.println(">> StringMessageProvider received a new request");
+            System.out.println(">> request [" + str + "]");
+            
+            return responseGood;
+        }
+        System.out.println(">> ERROR:null request received");
+        return responseBad;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message