You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ng...@apache.org on 2008/04/01 19:57:36 UTC

svn commit: r643488 - in /webservices/axis2/trunk/java/modules/samples/jaxws-dynamic: ./ resources/ resources/wsdl/ src/ src/org/ src/org/apache/ src/org/apache/axis2/ src/org/apache/axis2/jaxws/ src/org/apache/axis2/jaxws/sample/ src/org/apache/axis2/...

Author: ngallardo
Date: Tue Apr  1 10:57:31 2008
New Revision: 643488

URL: http://svn.apache.org/viewvc?rev=643488&view=rev
Log:
Integrating dynamic Dispatch/Provider sample

Added:
    webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/
    webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/README.txt
    webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/resources/
    webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/resources/wsdl/
    webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/resources/wsdl/DynamicSample.wsdl
    webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/src/
    webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/src/org/
    webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/src/org/apache/
    webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/src/org/apache/axis2/
    webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/src/org/apache/axis2/jaxws/
    webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/src/org/apache/axis2/jaxws/sample/
    webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/src/org/apache/axis2/jaxws/sample/dynamic/
    webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/src/org/apache/axis2/jaxws/sample/dynamic/DynamicServiceProvider.java

Added: webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/README.txt
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/README.txt?rev=643488&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/README.txt (added)
+++ webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/README.txt Tue Apr  1 10:57:31 2008
@@ -0,0 +1 @@
+This sample will show how to create a dynamic client/service using JAX-WS.
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/resources/wsdl/DynamicSample.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/resources/wsdl/DynamicSample.wsdl?rev=643488&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/resources/wsdl/DynamicSample.wsdl (added)
+++ webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/resources/wsdl/DynamicSample.wsdl Tue Apr  1 10:57:31 2008
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" 
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
+	xmlns:tns="http://axis2.apache.com/jaxws/sample/dynamic" 
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
+    name="EchoService" 
+    targetNamespace="http://axis2.apache.com/jaxws/sample/dynamic">
+  <types>
+    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+        xmlns:tns="http://axis2.apache.com/jaxws/sample/dynamic" 
+        targetNamespace="http://axis2.apache.com/jaxws/sample/dynamic" version="1.0">
+      
+      <xs:element name="operation1" type="xsd:string"/>
+      <xs:element name="operation1Response" type="xsd:string"/>
+      
+      <xs:element name="operation2" type="xsd:int"/>
+      <xs:element name="operation2Response" type="xsd:int"/>
+
+      <xs:element name="operation3" type="xsd:boolean"/>
+      <xs:element name="operation3Response" type="xsd:boolean"/>
+
+    </xs:schema>
+  </types>
+  
+  <message name="operation1">
+    <part element="tns:operation1" name="parameters"/>
+  </message>
+  
+  <message name="operation1Response">
+    <part element="tns:operation1Response" name="parameters"/>
+  </message>
+  
+  <message name="operation2">
+    <part element="tns:operation2" name="parameters"/>
+  </message>
+  
+  <message name="operation2Response">
+    <part element="tns:operation2Response" name="parameters"/>
+  </message>
+  
+  <message name="operation3">
+    <part element="tns:operation3" name="parameters"/>
+  </message>
+  
+  <message name="operation3Response">
+    <part element="tns:operation3Response" name="parameters"/>
+  </message>
+  
+  <portType name="Generic">
+    <operation name="operation1">
+      <input message="tns:operation1"/>
+      <output message="tns:operation1Response"/>
+    </operation>
+    <operation name="operation2">
+      <input message="tns:operation2"/>
+      <output message="tns:operation2Response"/>
+    </operation>
+    <operation name="operation3">
+      <input message="tns:operation3"/>
+      <output message="tns:operation3Response"/>
+    </operation>
+  </portType>
+  
+  <binding name="GenericBinding" type="tns:Generic">
+    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+    <operation name="operation1">
+      <soap:operation soapAction=""/>
+      <input>
+        <soap:body use="literal"/>
+      </input>
+      <output>
+        <soap:body use="literal"/>
+      </output>
+    </operation>
+    <operation name="operation2">
+      <soap:operation soapAction=""/>
+      <input>
+        <soap:body use="literal"/>
+      </input>
+      <output>
+        <soap:body use="literal"/>
+      </output>
+    </operation>
+    <operation name="operation3">
+      <soap:operation soapAction=""/>
+      <input>
+        <soap:body use="literal"/>
+      </input>
+      <output>
+        <soap:body use="literal"/>
+      </output>
+    </operation>
+  </binding>
+  
+  <service name="GenericService">
+    <port binding="tns:GenericBinding" name="EchoPort">
+      <soap:address location="http://localhost:8080/services/GenericService"/>
+    </port>
+  </service>
+  
+</definitions>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/src/org/apache/axis2/jaxws/sample/dynamic/DynamicServiceProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/src/org/apache/axis2/jaxws/sample/dynamic/DynamicServiceProvider.java?rev=643488&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/src/org/apache/axis2/jaxws/sample/dynamic/DynamicServiceProvider.java (added)
+++ webservices/axis2/trunk/java/modules/samples/jaxws-dynamic/src/org/apache/axis2/jaxws/sample/dynamic/DynamicServiceProvider.java Tue Apr  1 10:57:31 2008
@@ -0,0 +1,98 @@
+/*
+ * 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.sample.dynamic;
+
+import javax.annotation.Resource;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.Provider;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.http.HTTPBinding;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.StringWriter;
+
+@WebServiceProvider(serviceName="GenericService", wsdlLocation="WEB-INF/wsdl/DynamicSample.wsdl")
+@BindingType(SOAPBinding.SOAP11HTTP_BINDING)
+public class DynamicServiceProvider implements Provider<Source> {
+    
+	@Resource(type=WebServiceContext.class)
+    public WebServiceContext context;
+	
+	public Source invoke(Source source) {
+		        
+		//TestLogger.logger.debug(">> SourceProvider: Request received.\n");
+    	if (source == null) {
+    	    return source;
+        }
+        
+    	if (context == null) {
+    		//TestLogger.logger.debug("[DynamicServiceProvider] the WebServiceContext was null.");
+    		throw new WebServiceException("A WebServiceException should have been injected.");
+    	}
+    	
+    	QName wsdlService = (QName) context.getMessageContext().get(MessageContext.WSDL_SERVICE);
+    	QName wsdlOperation = (QName) context.getMessageContext().get(MessageContext.WSDL_OPERATION);
+    	
+    	System.out.println("[DynamicServiceProvider]   service name: " + wsdlService);
+    	System.out.println("[DynamicServiceProvider] operation name: " + wsdlOperation);
+    	
+    	//TestLogger.logger.debug("[DynamicServiceProvider]   service name: " + wsdlService);
+    	//TestLogger.logger.debug("[DynamicServiceProvider] operation name: " + wsdlOperation);
+    	
+        StringWriter writer = new StringWriter();
+    	try {
+            Transformer t = TransformerFactory.newInstance().newTransformer();
+            Result result = new StreamResult(writer);
+            t.transform(source, result);
+        } catch (TransformerConfigurationException e) {
+            throw new WebServiceException(e);
+        } catch (TransformerFactoryConfigurationError e) {
+            throw new WebServiceException(e);
+        } catch (TransformerException e) {
+            throw new WebServiceException(e);
+        }
+    	
+        String text = writer.getBuffer().toString();
+        //TestLogger.logger.debug(">> Source Request on Server: \n" + text);
+    	
+    	if (text != null && text.contains("throwWebServiceException")) {
+    	    throw new WebServiceException("provider");
+    	}
+    	
+    	ByteArrayInputStream stream = new ByteArrayInputStream(text.getBytes());
+    	Source srcStream = new StreamSource((InputStream) stream);
+    	return srcStream;        
+    }    	
+
+}
+



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