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 ro...@apache.org on 2008/10/27 21:53:31 UTC
svn commit: r708309 - in /webservices/axis2/trunk/java/modules: ./
jaxws-integration/ jaxws-integration/test/org/apache/axis2/jaxws/dispatch/
jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/
jaxws-integration/test/org/apache/axis2/jaxws/d...
Author: rott
Date: Mon Oct 27 13:53:31 2008
New Revision: 708309
URL: http://svn.apache.org/viewvc?rev=708309&view=rev
Log:
AXIS2-4100: add OMElement support to jaxws Provider/Dispatch
Added:
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/OMElementDispatchTest.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/META-INF/OMElementProviderService.wsdl
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/OMElementProvider.java
Modified:
webservices/axis2/trunk/java/modules/ (props changed)
webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatch.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
Propchange: webservices/axis2/trunk/java/modules/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Oct 27 13:53:31 2008
@@ -0,0 +1 @@
+mex-mar
Modified: webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml?rev=708309&r1=708308&r2=708309&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml Mon Oct 27 13:53:31 2008
@@ -1292,6 +1292,7 @@
<include>**/InvocationControllerTest.java</include>
<include>**/ProxyMTOMFeatureTest.java</include>
<include>**/SOAP12DispatchTest.java</include>
+ <include>**/OMElementDispatchTest.java</include>
<include>**/JAXBContextTest.java</include>
<include>**/StringProviderTests.java</include>
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/OMElementDispatchTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/OMElementDispatchTest.java?rev=708309&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/OMElementDispatchTest.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/OMElementDispatchTest.java Mon Oct 27 13:53:31 2008
@@ -0,0 +1,318 @@
+/*
+ * 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.dispatch;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+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 javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.soap.SOAPBinding;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axis2.jaxws.framework.AbstractTestCase;
+
+/**
+ * This class uses the JAX-WS Dispatch API to test sending and receiving
+ * messages using SOAP 1.2.
+ */
+public class OMElementDispatchTest extends AbstractTestCase {
+
+ private static final QName QNAME_SERVICE = new QName(
+ "http://org/apache/axis2/jaxws/test/OMELEMENT", "OMElementService");
+ private static final QName QNAME_PORT = new QName(
+ "http://org/apache/axis2/jaxws/test/OMELEMENT", "OMElementPort");
+ private static final String URL_ENDPOINT = "http://localhost:6060/axis2/services/OMElementProviderService.OMElementProviderPort";
+
+ private static final String sampleRequest =
+ "<test:echoOMElement xmlns:test=\"http://org/apache/axis2/jaxws/test/OMELEMENT\">" +
+ "<test:input>SAMPLE REQUEST MESSAGE</test:input>" +
+ "</test:echoOMElement>";
+ private static final String sampleEnvelopeHead =
+ "<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">" +
+ "<soapenv:Header /><soapenv:Body>";
+ private static final String sampleEnvelopeTail =
+ "</soapenv:Body></soapenv:Envelope>";
+ private static final String sampleEnvelope =
+ sampleEnvelopeHead +
+ sampleRequest +
+ sampleEnvelopeTail;
+
+ private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+ public static Test suite() {
+ return getTestSetup(new TestSuite(OMElementDispatchTest.class));
+ }
+
+ /**
+ * Test sending a SOAP 1.2 request in PAYLOAD mode
+ */
+ public void testSourceDispatchPayloadMode() throws Exception {
+ // Create the JAX-WS client needed to send the request
+ Service service = Service.create(QNAME_SERVICE);
+ service.addPort(QNAME_PORT, SOAPBinding.SOAP12HTTP_BINDING, URL_ENDPOINT);
+ Dispatch<Source> dispatch = service.createDispatch(
+ QNAME_PORT, Source.class, Mode.PAYLOAD);
+
+ // Create the Source object with the payload contents. Since
+ // we're in PAYLOAD mode, we don't have to worry about the envelope.
+ byte[] bytes = sampleRequest.getBytes();
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ StreamSource request = new StreamSource(bais);
+
+ // Send the SOAP 1.2 request
+ Source response = dispatch.invoke(request);
+
+ assertTrue("The response was null. We expected content to be returned.", response != null);
+
+ // Convert the response to a more consumable format
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ StreamResult result = new StreamResult(baos);
+
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer trans = factory.newTransformer();
+ trans.transform(response, result);
+
+ // Check to make sure the contents are correct. Again, since we're
+ // in PAYLOAD mode, we shouldn't have anything related to the envelope
+ // in the return, just the contents of the Body.
+ String responseText = baos.toString();
+ assertTrue(!responseText.contains("soap"));
+ assertTrue(!responseText.contains("Envelope"));
+ assertTrue(!responseText.contains("Body"));
+ assertTrue(responseText.contains("SAMPLE RESPONSE MESSAGE"));
+
+ // Invoke a second time to verify
+ bais = new ByteArrayInputStream(bytes);
+ request = new StreamSource(bais);
+
+ // Send the SOAP 1.2 request
+ response = dispatch.invoke(request);
+
+ assertTrue("The response was null. We expected content to be returned.", response != null);
+
+ // Convert the response to a more consumable format
+ baos = new ByteArrayOutputStream();
+ result = new StreamResult(baos);
+
+ factory = TransformerFactory.newInstance();
+ trans = factory.newTransformer();
+ trans.transform(response, result);
+
+ // Check to make sure the contents are correct. Again, since we're
+ // in PAYLOAD mode, we shouldn't have anything related to the envelope
+ // in the return, just the contents of the Body.
+ responseText = baos.toString();
+ assertTrue(!responseText.contains("soap"));
+ assertTrue(!responseText.contains("Envelope"));
+ assertTrue(!responseText.contains("Body"));
+ assertTrue(responseText.contains("SAMPLE RESPONSE MESSAGE"));
+ }
+
+
+
+ /**
+ * Test sending a SOAP 1.2 request in MESSAGE mode
+ */
+ public void testSourceDispatchMessageMode() throws Exception {
+ // Create the JAX-WS client needed to send the request
+ Service service = Service.create(QNAME_SERVICE);
+ service.addPort(QNAME_PORT, SOAPBinding.SOAP12HTTP_BINDING, URL_ENDPOINT);
+ Dispatch<Source> dispatch = service.createDispatch(
+ QNAME_PORT, Source.class, Mode.MESSAGE);
+
+ // Create the Source object with the message contents. Since
+ // we're in MESSAGE mode, we'll need to make sure we create this
+ // with the right protocol.
+ byte[] bytes = sampleEnvelope.getBytes();
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ StreamSource request = new StreamSource(bais);
+
+ Source response = dispatch.invoke(request);
+
+ // Convert the response to a more consumable format
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ StreamResult result = new StreamResult(baos);
+
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer trans = factory.newTransformer();
+ trans.transform(response, result);
+
+ // Check to make sure the contents of the message are correct
+ String responseText = baos.toString();
+ assertTrue(responseText.contains("soap"));
+ assertTrue(responseText.contains("Body"));
+ assertTrue(responseText.contains("Envelope"));
+ assertTrue(responseText.contains("SAMPLE RESPONSE MESSAGE"));
+
+ // Check to make sure the message returned had the right protocol version
+ // TODO: Need to determine whether or not we should be using the hard
+ // coded URLs here, or whether we should be using a constant for the
+ // purposes of the test.
+ assertTrue(responseText.contains("http://www.w3.org/2003/05/soap-envelope"));
+ assertTrue(!responseText.contains("http://schemas.xmlsoap.org/soap/envelope"));
+
+ // Invoke a second time to verify
+ bais = new ByteArrayInputStream(bytes);
+ request = new StreamSource(bais);
+
+ response = dispatch.invoke(request);
+
+ // Convert the response to a more consumable format
+ baos = new ByteArrayOutputStream();
+ result = new StreamResult(baos);
+
+ factory = TransformerFactory.newInstance();
+ trans = factory.newTransformer();
+ trans.transform(response, result);
+
+ // Check to make sure the contents of the message are correct
+ responseText = baos.toString();
+ assertTrue(responseText.contains("soap"));
+ assertTrue(responseText.contains("Body"));
+ assertTrue(responseText.contains("Envelope"));
+ assertTrue(responseText.contains("SAMPLE RESPONSE MESSAGE"));
+
+ // Check to make sure the message returned had the right protocol version
+ // TODO: Need to determine whether or not we should be using the hard
+ // coded URLs here, or whether we should be using a constant for the
+ // purposes of the test.
+ assertTrue(responseText.contains("http://www.w3.org/2003/05/soap-envelope"));
+ assertTrue(!responseText.contains("http://schemas.xmlsoap.org/soap/envelope"));
+ }
+
+ /**
+ * Test sending a SOAP 1.2 request in PAYLOAD mode
+ */
+ public void testOMElementDispatchPayloadMode() throws Exception {
+ // Create the JAX-WS client needed to send the request
+ Service service = Service.create(QNAME_SERVICE);
+ service.addPort(QNAME_PORT, SOAPBinding.SOAP12HTTP_BINDING, URL_ENDPOINT);
+ Dispatch<OMElement> dispatch = service.createDispatch(
+ QNAME_PORT, OMElement.class, Mode.PAYLOAD);
+
+ // Create the OMElement object with the payload contents. Since
+ // we're in PAYLOAD mode, we don't have to worry about the envelope.
+ StringReader sr = new StringReader(sampleRequest);
+ XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
+ StAXOMBuilder builder = new StAXOMBuilder(inputReader);
+ OMElement om = builder.getDocumentElement();
+
+ // Send the SOAP 1.2 request
+ OMElement response = dispatch.invoke(om);
+
+ assertTrue("The response was null. We expected content to be returned.", response != null);
+
+ // Check to make sure the contents are correct. Again, since we're
+ // in PAYLOAD mode, we shouldn't have anything related to the envelope
+ // in the return, just the contents of the Body.
+ String responseText = response.toStringWithConsume();
+ assertTrue(!responseText.contains("soap"));
+ assertTrue(!responseText.contains("Envelope"));
+ assertTrue(!responseText.contains("Body"));
+ assertTrue(responseText.contains("SAMPLE RESPONSE MESSAGE"));
+
+ // Send the SOAP 1.2 request
+ response = dispatch.invoke(om);
+
+ assertTrue("The response was null. We expected content to be returned.", response != null);
+
+ // Check to make sure the contents are correct. Again, since we're
+ // in PAYLOAD mode, we shouldn't have anything related to the envelope
+ // in the return, just the contents of the Body.
+ responseText = response.toStringWithConsume();
+ assertTrue(!responseText.contains("soap"));
+ assertTrue(!responseText.contains("Envelope"));
+ assertTrue(!responseText.contains("Body"));
+ assertTrue(responseText.contains("SAMPLE RESPONSE MESSAGE"));
+ }
+
+
+
+ /**
+ * Test sending a SOAP 1.2 request in MESSAGE mode
+ */
+ public void testOMElementDispatchMessageMode() throws Exception {
+ // Create the JAX-WS client needed to send the request
+ Service service = Service.create(QNAME_SERVICE);
+ service.addPort(QNAME_PORT, SOAPBinding.SOAP12HTTP_BINDING, URL_ENDPOINT);
+ Dispatch<OMElement> dispatch = service.createDispatch(
+ QNAME_PORT, OMElement.class, Mode.MESSAGE);
+
+ // Create the OMElement object with the payload contents. Since
+ // we're in PAYLOAD mode, we don't have to worry about the envelope.
+ StringReader sr = new StringReader(sampleEnvelope);
+ XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr);
+ StAXOMBuilder builder = new StAXOMBuilder(inputReader);
+ OMElement om = builder.getDocumentElement();
+
+ OMElement response = dispatch.invoke(om);
+
+ // Check to make sure the contents of the message are correct
+ //String responseText = baos.toString();
+ String responseText = response.toStringWithConsume();
+ assertTrue(responseText.contains("soap"));
+ assertTrue(responseText.contains("Body"));
+ assertTrue(responseText.contains("Envelope"));
+ assertTrue(responseText.contains("SAMPLE RESPONSE MESSAGE"));
+
+ // Check to make sure the message returned had the right protocol version
+ // TODO: Need to determine whether or not we should be using the hard
+ // coded URLs here, or whether we should be using a constant for the
+ // purposes of the test.
+ assertTrue(responseText.contains("http://www.w3.org/2003/05/soap-envelope"));
+ assertTrue(!responseText.contains("http://schemas.xmlsoap.org/soap/envelope"));
+
+ StringReader sr2 = new StringReader(sampleEnvelope);
+ inputReader = inputFactory.createXMLStreamReader(sr2);
+ builder = new StAXOMBuilder(inputReader);
+ om = builder.getDocumentElement();
+ response = dispatch.invoke(om);
+
+ // Check to make sure the contents of the message are correct
+ responseText = response.toStringWithConsume();
+ assertTrue(responseText.contains("soap"));
+ assertTrue(responseText.contains("Body"));
+ assertTrue(responseText.contains("Envelope"));
+ assertTrue(responseText.contains("SAMPLE RESPONSE MESSAGE"));
+
+ // Check to make sure the message returned had the right protocol version
+ // TODO: Need to determine whether or not we should be using the hard
+ // coded URLs here, or whether we should be using a constant for the
+ // purposes of the test.
+ assertTrue(responseText.contains("http://www.w3.org/2003/05/soap-envelope"));
+ assertTrue(!responseText.contains("http://schemas.xmlsoap.org/soap/envelope"));
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/META-INF/OMElementProviderService.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/META-INF/OMElementProviderService.wsdl?rev=708309&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/META-INF/OMElementProviderService.wsdl (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/META-INF/OMElementProviderService.wsdl Mon Oct 27 13:53:31 2008
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<wsdl:definitions targetNamespace="http://org/apache/axis2/jaxws/test/OMELEMENT"
+ xmlns:impl="http://org/apache/axis2/jaxws/test/OMELEMENT"
+ xmlns:intf="http://org/apache/axis2/jaxws/test/OMELEMENT"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://org/apache/axis2/jaxws/test/OMELEMENT"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:impl="http://org/apache/axis2/jaxws/test/OMELEMENT"
+ xmlns:intf="http://org/apache/axis2/jaxws/test/OMELEMENT"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <element name="echoOMElement">
+ <complexType>
+ <sequence>
+ <element name="input" nillable="true" type="xsd:anyType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="echoOMElementResponse">
+ <complexType>
+ <sequence>
+ <element name="echoOMElementReturn" nillable="true" type="xsd:anyType"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="echoOMElementResponse">
+
+ <wsdl:part element="impl:echoOMElementResponse" name="parameters"/>
+
+ </wsdl:message>
+
+ <wsdl:message name="echoOMElementRequest">
+
+ <wsdl:part element="impl:echoOMElement" name="parameters"/>
+
+ </wsdl:message>
+
+ <wsdl:portType name="Echo">
+
+ <wsdl:operation name="echoOMElement">
+
+ <wsdl:input message="impl:echoOMElementRequest" name="echoOMElementRequest"/>
+
+ <wsdl:output message="impl:echoOMElementResponse" name="echoOMElementResponse"/>
+
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="OMElementBinding" type="impl:Echo">
+
+ <wsdlsoap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="echoOMElement">
+
+ <wsdlsoap12:operation soapAction=""/>
+
+ <wsdl:input name="echoOMElementRequest">
+
+ <wsdlsoap12:body use="literal"/>
+
+ </wsdl:input>
+
+ <wsdl:output name="echoOMElementResponse">
+
+ <wsdlsoap12:body use="literal"/>
+
+ </wsdl:output>
+
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="OMElementProviderService">
+
+ <wsdl:port binding="impl:OMElementBinding" name="OMElementProviderPort">
+
+ <wsdlsoap12:address location="http://localhost:9080/axis2/services/OMElementProviderService"/>
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions>
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/OMElementProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/OMElementProvider.java?rev=708309&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/OMElementProvider.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/dispatch/server/OMElementProvider.java Mon Oct 27 13:53:31 2008
@@ -0,0 +1,100 @@
+/*
+ * 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.dispatch.server;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.impl.llom.soap12.SOAP12Factory;
+import org.apache.axis2.jaxws.ExceptionFactory;
+
+/**
+ * A Provider<OMElement> implementation used to test sending and
+ * receiving SOAP 1.2 messages.
+ */
+@WebServiceProvider(
+ serviceName="OMElementProviderService",
+ wsdlLocation="META-INF/OMElementProviderService.wsdl",
+ targetNamespace="http://org/apache/axis2/jaxws/test/OMELEMENT")
+@BindingType(SOAPBinding.SOAP12HTTP_BINDING)
+@ServiceMode(value=Service.Mode.MESSAGE)
+public class OMElementProvider implements Provider<OMElement> {
+
+ private static final String sampleResponse =
+ "<test:echoOMElement xmlns:test=\"http://org/apache/axis2/jaxws/test/OMELEMENT\">" +
+ "<test:input>SAMPLE RESPONSE MESSAGE</test:input>" +
+ "</test:echoOMElement>";
+
+ private static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+ public OMElement invoke(OMElement obj) {
+ try {
+ System.out.println("MIKE: " + obj.toStringWithConsume());
+ } catch (XMLStreamException e) {
+ System.out.println("MIKE: PROBLEM");
+ }
+ OMElement payload = createPayload();
+
+ SOAPFactory factory = new SOAP12Factory();
+ SOAPEnvelope env = factory.createSOAPEnvelope();
+ SOAPBody body = factory.createSOAPBody(env);
+
+ body.addChild(payload);
+
+ return env;
+ }
+
+ private OMElement createPayload() {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace omNs = fac.createOMNamespace("http://org/apache/axis2/jaxws/test/SOAPENVELOPE", "test");
+
+ OMElement response = fac.createOMElement("echoOMElement", omNs);
+
+ OMElement output = fac.createOMElement("output", omNs);
+ response.addChild(output);
+
+ OMElement data = fac.createOMElement("data", omNs);
+ output.addChild(data);
+
+ OMText binaryData = fac.createOMText("SAMPLE RESPONSE MESSAGE");
+ data.addChild(binaryData);
+
+ return response;
+ }
+
+}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatch.java?rev=708309&r1=708308&r2=708309&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatch.java Mon Oct 27 13:53:31 2008
@@ -31,6 +31,7 @@
import org.apache.axis2.jaxws.message.factory.BlockFactory;
import org.apache.axis2.jaxws.message.factory.DataSourceBlockFactory;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.message.factory.OMBlockFactory;
import org.apache.axis2.jaxws.message.factory.SOAPEnvelopeBlockFactory;
import org.apache.axis2.jaxws.message.factory.SourceBlockFactory;
import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory;
@@ -39,6 +40,9 @@
import org.apache.axis2.Constants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.jaxws.message.databinding.OMBlock;
+import org.apache.axis2.jaxws.message.databinding.impl.OMBlockFactoryImpl;
import javax.activation.DataSource;
import javax.xml.soap.SOAPEnvelope;
@@ -178,6 +182,9 @@
block = message.getBodyBlock(null, factory);
if (block != null) {
value = block.getBusinessObject(true);
+ if (value instanceof OMBlockFactoryImpl) {
+ value = ((OMBlock)value).getOMElement();
+ }
} else {
// REVIEW This seems like the correct behavior. If the body is empty, return a null
// Any changes here should also be made to XMLDispatch.getValue
@@ -190,12 +197,16 @@
} else if (mode.equals(Mode.MESSAGE)) {
BlockFactory factory = (BlockFactory)FactoryRegistry.getFactory(blockFactoryType);
- value = message.getValue(null, factory);
+ if (factory instanceof OMBlockFactoryImpl) {
+ value = (OMElement)message.getAsOMElement();
+ } else {
+ value = message.getValue(null, factory);
+ }
if (value == null) {
if (log.isDebugEnabled()) {
log.debug(
"There are no elements to unmarshal. XMLDispatch returns a null value");
- }
+ }
}
}
@@ -205,7 +216,9 @@
}
throw ExceptionFactory.makeWebServiceException(e);
} finally {
- message.close();
+ if (!(value instanceof OMElement)) {
+ message.close();
+ }
}
if (log.isDebugEnabled()) {
@@ -244,6 +257,11 @@
log.debug(">> returning SOAPEnvelope");
}
return SOAPEnvelopeBlockFactory.class;
+ } else if (OMElement.class.isAssignableFrom(o.getClass())) {
+ if (log.isDebugEnabled()) {
+ log.debug(">> returning OMBlockFactory");
+ }
+ return OMBlockFactory.class;
}
if (log.isDebugEnabled()) {
log.debug(">> ERROR: Factory not found");
@@ -273,6 +291,11 @@
log.debug(">> returning SOAPEnvelope");
}
return SOAPEnvelopeBlockFactory.class;
+ } else if (OMElement.class.isAssignableFrom(type)) {
+ if (log.isDebugEnabled()) {
+ log.debug(">> returning OMBlockFactory");
+ }
+ return OMBlockFactory.class;
}
if (log.isDebugEnabled()) {
log.debug(">> ERROR: Factory not found");
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?rev=708309&r1=708308&r2=708309&view=diff
==============================================================================
--- 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 Oct 27 13:53:31 2008
@@ -31,9 +31,11 @@
import org.apache.axis2.jaxws.message.Message;
import org.apache.axis2.jaxws.message.Protocol;
import org.apache.axis2.jaxws.message.XMLFault;
+import org.apache.axis2.jaxws.message.databinding.OMBlock;
import org.apache.axis2.jaxws.message.factory.BlockFactory;
import org.apache.axis2.jaxws.message.factory.DataSourceBlockFactory;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.message.factory.OMBlockFactory;
import org.apache.axis2.jaxws.message.factory.SOAPEnvelopeBlockFactory;
import org.apache.axis2.jaxws.message.factory.SourceBlockFactory;
import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory;
@@ -49,6 +51,7 @@
import org.apache.axis2.jaxws.utility.SingleThreadedExecutor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.axiom.om.OMElement;
import javax.activation.DataSource;
import javax.xml.soap.SOAPMessage;
@@ -285,8 +288,11 @@
log.debug("Number Message attachments=" + message.getAttachmentIDs().size());
}
}
-
- requestParamValue = message.getValue(null, factory);
+ if (providerType.equals(OMElement.class)) {
+ requestParamValue = message.getAsOMElement();
+ } else {
+ requestParamValue = message.getValue(null, factory);
+ }
if (requestParamValue == null) {
if (log.isDebugEnabled()) {
log.debug(
@@ -299,6 +305,9 @@
if (block != null) {
try {
requestParamValue = block.getBusinessObject(true);
+ if (requestParamValue instanceof OMBlock) {
+ requestParamValue = ((OMBlock)requestParamValue).getOMElement();
+ }
} catch (WebServiceException e) {
throw ExceptionFactory.makeWebServiceException(e);
} catch (XMLStreamException e) {
@@ -527,6 +536,8 @@
provider = (Provider<SOAPMessage>)serviceInstance;
} else if (clazz == DataSource.class) {
provider = (Provider<DataSource>)serviceInstance;
+ } else if (clazz == OMElement.class) {
+ provider = (Provider<OMElement>)serviceInstance;
}
if (provider == null) {
@@ -578,6 +589,7 @@
* javax.xml.transform.Source
* javax.xml.soap.SOAPMessage
* javax.activation.DataSource
+ * org.apache.axiom.om.OMElement
*
* We've also added support for String types which is NOT dictated
* by the spec.
@@ -586,7 +598,8 @@
boolean valid = clazz == String.class ||
clazz == SOAPMessage.class ||
clazz == Source.class ||
- clazz == DataSource.class;
+ clazz == DataSource.class ||
+ clazz == OMElement.class;
if (!valid) {
if (log.isDebugEnabled()) {
@@ -617,6 +630,9 @@
} else if (type.equals(SOAPMessage.class)) {
_blockFactory = (SOAPEnvelopeBlockFactory)FactoryRegistry.getFactory(
SOAPEnvelopeBlockFactory.class);
+ } else if (type.equals(OMElement.class)) {
+ _blockFactory = (OMBlockFactory)FactoryRegistry.getFactory(
+ OMBlockFactory.class);
} else {
throw ExceptionFactory.makeWebServiceException(
Messages.getMessage("bFactoryErr",type.getName()));
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java?rev=708309&r1=708308&r2=708309&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java Mon Oct 27 13:53:31 2008
@@ -20,6 +20,30 @@
package org.apache.axis2.jaxws.spi;
+import java.lang.reflect.Field;
+import java.lang.reflect.Proxy;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.Iterator;
+import java.util.concurrent.Executor;
+
+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.Dispatch;
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.handler.HandlerResolver;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.java.security.AccessController;
@@ -43,28 +67,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-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.Dispatch;
-import javax.xml.ws.EndpointReference;
-import javax.xml.ws.Service;
-import javax.xml.ws.Service.Mode;
-import javax.xml.ws.WebServiceException;
-import javax.xml.ws.WebServiceFeature;
-import javax.xml.ws.handler.HandlerResolver;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Proxy;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.Iterator;
-import java.util.concurrent.Executor;
-
/**
* The ServiceDelegate serves as the backing implementation for all of the methods in the {@link
* javax.xml.ws.Service} API. This is the plug point for the client implementation.
@@ -774,7 +776,8 @@
return clazz != null && (clazz == String.class ||
clazz == Source.class ||
clazz == DataSource.class ||
- clazz == SOAPMessage.class);
+ clazz == SOAPMessage.class ||
+ clazz == OMElement.class);
}
private boolean isValidDispatchTypeWithMode(Class clazz, Mode mode) {
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java?rev=708309&r1=708308&r2=708309&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java Mon Oct 27 13:53:31 2008
@@ -38,6 +38,7 @@
public static final String PROVIDER_DATASOURCE =
"javax.xml.ws.Provider<javax.activation.DataSource>";
public static final String PROVIDER_STRING = "javax.xml.ws.Provider<java.lang.String>";
+ public static final String PROVIDER_OMELEMENT = "javax.xml.ws.Provider<org.apache.axiom.om.OMElement>";
public static final String WSDL_FILE_NAME = "WSDL_FILE_NAME";
public static final String SCHEMA_DOCS = "SCHEMA_DOCS";
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?rev=708309&r1=708308&r2=708309&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java Mon Oct 27 13:53:31 2008
@@ -1403,7 +1403,8 @@
if (interfaceString.equals(MDQConstants.PROVIDER_SOURCE)
|| interfaceString.equals(MDQConstants.PROVIDER_SOAP)
|| interfaceString.equals(MDQConstants.PROVIDER_DATASOURCE)
- || interfaceString.equals(MDQConstants.PROVIDER_STRING)) {
+ || interfaceString.equals(MDQConstants.PROVIDER_STRING)
+ || interfaceString.equals(MDQConstants.PROVIDER_OMELEMENT)) {
providerInterfaceValid = true;
//This is a provider based endpoint, make sure the annotation exists
if (composite.getWebServiceProviderAnnot() == null) {