Author: sergeyb
Date: 2010-09-28 12:38:50 -0400 (Tue, 28 Sep 2010)
New Revision: 13035
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/saaj/
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/saaj/SOAPConnectionFactoryImpl.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/saaj/SOAPConnectionImpl.java
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/javax.xml.soap.SOAPConnectionFactory
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/InputStreamDataSource.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/SOAPConnectionTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/ServiceIface.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/ServiceImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/cxf/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/cxf/WEB-INF/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/cxf/WEB-INF/web.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/cxf/WEB-INF/wsdl/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/cxf/WEB-INF/wsdl/SaajService.wsdl
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
Log:
[JBWS-3084] Enabling control of chunked encoding when using SOAPConnection
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/saaj/SOAPConnectionFactoryImpl.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/saaj/SOAPConnectionFactoryImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/saaj/SOAPConnectionFactoryImpl.java 2010-09-28
16:38:50 UTC (rev 13035)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.saaj;
+
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPException;
+
+public class SOAPConnectionFactoryImpl extends SOAPConnectionFactory {
+
+ @Override
+ public SOAPConnection createConnection() throws SOAPException {
+ return new SOAPConnectionImpl();
+ }
+
+}
Property changes on:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/saaj/SOAPConnectionFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/saaj/SOAPConnectionImpl.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/saaj/SOAPConnectionImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/saaj/SOAPConnectionImpl.java 2010-09-28
16:38:50 UTC (rev 13035)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.saaj;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.MimeHeader;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.helpers.LoadingByteArrayOutputStream;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.ConduitInitiator;
+import org.apache.cxf.transport.ConduitInitiatorManager;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.transport.http.HTTPConduit;
+
+public class SOAPConnectionImpl extends SOAPConnection {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public SOAPMessage call(SOAPMessage msgOut, Object addressObject) throws
SOAPException {
+
+ String address = getAddress(addressObject);
+ ConduitInitiator ci = getConduitInitiator(address);
+
+
+ // create a new Message and Exchange
+ EndpointInfo info = new EndpointInfo();
+ info.setAddress(address);
+ Message outMessage = new MessageImpl();
+ Exchange exch = new ExchangeImpl();
+ outMessage.setExchange(exch);
+
+ // sent SOAPMessage
+ try {
+ final Conduit c = ci.getConduit(info);
+
+
+ Map<String, List<String>> outHeaders = new HashMap<String,
List<String>>();
+ for (Iterator it = msgOut.getMimeHeaders().getAllHeaders(); it.hasNext();) {
+ MimeHeader mimeHeader = (MimeHeader)it.next();
+ if ("Content-Type".equals(mimeHeader.getName())) {
+ outMessage.put(Message.CONTENT_TYPE, mimeHeader.getValue());
+ }
+
+ // disable the chunked encoding if requested
+ if ("Transfer-Encoding".equals(mimeHeader.getName())
+ && "disabled".equals(mimeHeader.getValue())
+ && c instanceof HTTPConduit) {
+ ((HTTPConduit)c).getClient().setAllowChunking(false);
+ continue;
+ }
+
+ List<String> values = outHeaders.get(mimeHeader.getName());
+ if (values == null) {
+ values = new ArrayList<String>();
+ outHeaders.put(mimeHeader.getName(), values);
+ }
+ values.add(mimeHeader.getValue());
+ }
+ outMessage.put(Message.HTTP_REQUEST_METHOD, "POST");
+ outMessage.put(Message.PROTOCOL_HEADERS, outHeaders);
+ c.prepare(outMessage);
+
+ OutputStream outs = outMessage.getContent(OutputStream.class);
+ msgOut.writeTo(outs);
+
+ c.setMessageObserver(new MessageObserver() {
+ public void onMessage(Message inMessage) {
+ LoadingByteArrayOutputStream bout = new
LoadingByteArrayOutputStream();
+ try {
+ IOUtils.copy(inMessage.getContent(InputStream.class), bout);
+ inMessage.getExchange().put(InputStream.class,
bout.createInputStream());
+
+ Map<String, List<String>> inHeaders =
+ (Map<String,
List<String>>)inMessage.get(Message.PROTOCOL_HEADERS);
+
+ inMessage.getExchange().put(Message.PROTOCOL_HEADERS,
inHeaders);
+ c.close(inMessage);
+ } catch (IOException e) {
+ //ignore
+ }
+ }
+ });
+
+ c.close(outMessage);
+ } catch (Exception ex) {
+ throw new SOAPException("SOAPMessage can not be sent", ex);
+ }
+
+ // read SOAPMessage
+ try {
+ InputStream ins = exch.get(InputStream.class);
+ Map<String, List<String>> inHeaders =
+ (Map<String,
List<String>>)exch.get(Message.PROTOCOL_HEADERS);
+
+ MimeHeaders mimeHeaders = new MimeHeaders();
+ if (inHeaders != null) {
+ for (Map.Entry<String, List<String>> entry :
inHeaders.entrySet()) {
+ if (entry.getValue() != null) {
+ for (String value : entry.getValue()) {
+ mimeHeaders.addHeader(entry.getKey(), value);
+ }
+ }
+ }
+ }
+
+ MessageFactory msgFac = MessageFactory.newInstance();
+ return msgFac.createMessage(mimeHeaders, ins);
+ } catch (Exception ex) {
+ throw new SOAPException("SOAPMessage can not be read", ex);
+ }
+
+
+ }
+
+ @Override
+ public void close() throws SOAPException {
+ // complete
+ }
+
+ private String getAddress(Object addressObject) throws SOAPException {
+ if (addressObject instanceof URL || addressObject instanceof String) {
+ return addressObject.toString();
+ }
+ throw new SOAPException("Address object of type " +
addressObject.getClass().getName()
+ + " is not supported");
+ }
+
+ private ConduitInitiator getConduitInitiator(String address) throws SOAPException {
+
+ ConduitInitiator ci = null;
+ try {
+ Bus bus = BusFactory.getThreadDefaultBus(true);
+ ConduitInitiatorManager mgr =
bus.getExtension(ConduitInitiatorManager.class);
+
+ if (address.startsWith("http")) {
+ ci =
mgr.getConduitInitiator("http://cxf.apache.org/transports/http");
+ }
+ if (ci == null) {
+ ci = mgr.getConduitInitiatorForUri(address);
+ }
+
+ } catch (Exception ex) {
+ throw new SOAPException("No ConduitInitiator is available for " +
address, ex);
+ }
+
+ if (ci == null) {
+ throw new SOAPException("No ConduitInitiator is available for " +
address);
+ }
+ return ci;
+ }
+}
Property changes on:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/saaj/SOAPConnectionImpl.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/javax.xml.soap.SOAPConnectionFactory
===================================================================
---
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/javax.xml.soap.SOAPConnectionFactory
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/javax.xml.soap.SOAPConnectionFactory 2010-09-28
16:38:50 UTC (rev 13035)
@@ -0,0 +1 @@
+org.jboss.wsf.stack.cxf.saaj.SOAPConnectionFactoryImpl
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2010-09-28
14:51:13 UTC (rev 13034)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2010-09-28
16:38:50 UTC (rev 13035)
@@ -121,9 +121,25 @@
dir="${tests.output.dir}/test-resources/jaxws/samples/wsrm/WEB-INF/wsdl"
prefix="WEB-INF/wsdl"/>
</war>
-
+
+ <!-- saaj-soap-connection -->
+ <war
+ warfile="${tests.output.dir}/test-libs/saaj-soap-connection.war"
+
webxml="${tests.output.dir}/test-resources/saaj/cxf/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/saaj/ServiceImpl.class"/>
+ <include name="org/jboss/test/ws/saaj/ServiceIface.class"/>
+ <include
name="org/jboss/test/ws/saaj/InputStreamDataSource.class"/>
+ </classes>
+ <zipfileset
+ dir="${tests.output.dir}/test-resources/saaj/cxf/WEB-INF/wsdl"
+ prefix="WEB-INF/wsdl"/>
+ </war>
+
+
<!-- Please add alphabetically -->
+
</target>
</project>
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/InputStreamDataSource.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/InputStreamDataSource.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/InputStreamDataSource.java 2010-09-28
16:38:50 UTC (rev 13035)
@@ -0,0 +1,44 @@
+package org.jboss.test.ws.saaj;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.activation.DataSource;
+
+public class InputStreamDataSource implements DataSource
+{
+
+ private InputStream is;
+ private String contentType;
+ private String name;
+
+ public InputStreamDataSource(InputStream is, String contentType, String name)
+ {
+ this.is = is;
+ this.contentType = contentType;
+ this.name = name;
+ }
+ @Override
+ public String getContentType()
+ {
+ return contentType;
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException
+ {
+ return is;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public OutputStream getOutputStream() throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/InputStreamDataSource.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/SOAPConnectionTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/SOAPConnectionTestCase.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/SOAPConnectionTestCase.java 2010-09-28
16:38:50 UTC (rev 13035)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.saaj;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPMessage;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 11-Jun-2010
+ */
+public class SOAPConnectionTestCase extends JBossWSTest
+{
+ private final String serviceURL = "http://" + getServerHost() +
":8081/saaj-soap-connection/SaajService";
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(SOAPConnectionTestCase.class,
"saaj-soap-connection.war");
+ }
+
+ public void testSoapConnectionWithoutChunkedEncoding() throws Exception
+ {
+ doTestSoapConnection(true);
+ }
+
+ public void testSoapConnectionWithChunkedEncoding() throws Exception
+ {
+ doTestSoapConnection(false);
+ }
+
+ private void doTestSoapConnection(boolean disableChunking) throws Exception
+ {
+ SOAPFactory soapFac = SOAPFactory.newInstance();
+ MessageFactory msgFac = MessageFactory.newInstance();
+ SOAPConnectionFactory conFac = SOAPConnectionFactory.newInstance();
+ SOAPMessage msg = msgFac.createMessage();
+
+ if (disableChunking)
+ {
+ // this is the custom header checked by ServiceImpl
+ msg.getMimeHeaders().addHeader("Transfer-Encoding-Disabled",
"true");
+ // this is a hint to SOAPConnection that the chunked encoding is not needed
+ msg.getMimeHeaders().addHeader("Transfer-Encoding",
"disabled");
+ }
+
+ QName sayHi = new
QName("http://www.jboss.org/jbossws/saaj",
"sayHello");
+ msg.getSOAPBody().addChildElement(soapFac.createElement(sayHi));
+ AttachmentPart ap1 = msg.createAttachmentPart();
+
+ char[] content = new char[16 * 1024];
+ Arrays.fill(content, 'A');
+
+ ap1.setContent(new String(content), "text/plain");
+ msg.addAttachmentPart(ap1);
+
+ AttachmentPart ap2 = msg.createAttachmentPart();
+ ap2.setContent("Attachment content - Part 2", "text/plain");
+ msg.addAttachmentPart(ap2);
+ msg.saveChanges();
+
+ SOAPConnection con = conFac.createConnection();
+ URL endpoint = new URL(serviceURL);
+ SOAPMessage response = con.call(msg, endpoint);
+ QName sayHiResp = new
QName("http://www.jboss.org/jbossws/saaj",
"sayHelloResponse");
+
+ Iterator<?> sayHiRespIterator =
response.getSOAPBody().getChildElements(sayHiResp);
+ SOAPElement soapElement = (SOAPElement)sayHiRespIterator.next();
+ assertNotNull(soapElement);
+
+ assertEquals(2, response.countAttachments());
+
+ String[] values =
response.getMimeHeaders().getHeader("Transfer-Encoding-Disabled");
+ if (disableChunking)
+ {
+ // this means that the ServiceImpl executed the code branch verifying
+ // that chunking was disabled
+ assertNotNull(values);
+ assertTrue(values.length == 1);
+ }
+ else
+ {
+ assertNull(values);
+ }
+ }
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/SOAPConnectionTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/ServiceIface.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/ServiceIface.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/ServiceIface.java 2010-09-28
16:38:50 UTC (rev 13035)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.saaj;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+@WebService
+(
+ targetNamespace = "http://www.jboss.org/jbossws/saaj"
+)
+public interface ServiceIface
+{
+ @WebMethod
+ String sayHello();
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/ServiceIface.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/ServiceImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/ServiceImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/ServiceImpl.java 2010-09-28
16:38:50 UTC (rev 13035)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.saaj;
+
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.activation.DataHandler;
+import javax.annotation.Resource;
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.helpers.LoadingByteArrayOutputStream;
+
+@WebService
+(
+ portName = "SaajServicePort",
+ serviceName = "SaajService",
+ wsdlLocation = "WEB-INF/wsdl/SaajService.wsdl",
+ targetNamespace = "http://www.jboss.org/jbossws/saaj",
+ endpointInterface = "org.jboss.test.ws.saaj.ServiceIface"
+)
+public class ServiceImpl implements ServiceIface
+{
+ @Resource
+ private WebServiceContext context;
+
+ public String sayHello()
+ {
+ Map<String, List<String>> reqHeaders = CastUtils.cast(
+ (Map<?,
?>)context.getMessageContext().get(MessageContext.HTTP_REQUEST_HEADERS));
+
+ boolean chunkedEncodingDisabled =
reqHeaders.get("transfer-encoding-disabled") != null;
+
+ List<String> transferEncHeader = reqHeaders.get("transfer-encoding");
+
+ if (!chunkedEncodingDisabled)
+ {
+ if (transferEncHeader == null || transferEncHeader.size() != 1)
+ {
+ throw new RuntimeException("Transfer-Encoding is missing");
+ }
+ if (!"chunked".equals(transferEncHeader.get(0)))
+ {
+ throw new RuntimeException("Wrong Transfer-Encoding value");
+ }
+ }
+ else
+ {
+ if (transferEncHeader != null)
+ {
+ throw new RuntimeException("Unexpected Transfer-Encoding header");
+ }
+ Map<String, List<String>> respHeaders = CastUtils.cast(
+ (Map<?,
?>)context.getMessageContext().get(MessageContext.HTTP_RESPONSE_HEADERS));
+ if (respHeaders == null) {
+ respHeaders = new HashMap<String, List<String>>();
+ context.getMessageContext().put(MessageContext.HTTP_RESPONSE_HEADERS,
respHeaders);
+ }
+ respHeaders.put("Transfer-Encoding-Disabled",
Arrays.asList("true"));
+ }
+
+ Map<String, DataHandler> dataHandlers = CastUtils.cast(
+ (Map<?,
?>)context.getMessageContext().get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS));
+
+ Map<String, DataHandler> outDataHandlers = CastUtils.cast(
+ (Map<?,
?>)context.getMessageContext().get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS));
+
+ int index = 0;
+ try
+ {
+ for (Map.Entry<String, DataHandler> entry : dataHandlers.entrySet())
+ {
+ InputStream is = entry.getValue().getInputStream();
+ LoadingByteArrayOutputStream bous = new LoadingByteArrayOutputStream();
+ IOUtils.copy(is, bous);
+ String name = Integer.toString(index++);
+ DataHandler handler = new DataHandler(
+ new InputStreamDataSource(bous.createInputStream(), "text/plain",
name));
+ outDataHandlers.put(name, handler);
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(ex);
+ }
+
+ return "Hello World!";
+ }
+
+}
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/ServiceImpl.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/cxf/WEB-INF/web.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/cxf/WEB-INF/web.xml
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/cxf/WEB-INF/web.xml 2010-09-28
16:38:50 UTC (rev 13035)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app
+ version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <servlet>
+ <servlet-name>SaajService</servlet-name>
+ <servlet-class>org.jboss.test.ws.saaj.ServiceImpl</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>SaajService</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/cxf/WEB-INF/web.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/cxf/WEB-INF/wsdl/SaajService.wsdl
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/cxf/WEB-INF/wsdl/SaajService.wsdl
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/cxf/WEB-INF/wsdl/SaajService.wsdl 2010-09-28
16:38:50 UTC (rev 13035)
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="SaajService"
targetNamespace="http://www.jboss.org/jbossws/saaj"
xmlns:tns="http://www.jboss.org/jbossws/saaj"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <wsdl:types>
+<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.jboss.org/jbossws/saaj"
attributeFormDefault="unqualified" elementFormDefault="unqualified"
targetNamespace="http://www.jboss.org/jbossws/saaj">
+<xsd:element name="sayHello" type="tns:sayHello"/>
+<xsd:complexType name="sayHello">
+<xsd:sequence/>
+</xsd:complexType>
+<xsd:element name="sayHelloResponse"
type="tns:sayHelloResponse"/>
+<xsd:complexType name="sayHelloResponse">
+<xsd:sequence>
+<xsd:element minOccurs="0" name="return"
type="xsd:string"/>
+</xsd:sequence>
+</xsd:complexType>
+</xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="sayHelloResponse">
+ <wsdl:part name="parameters"
element="tns:sayHelloResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="sayHello">
+ <wsdl:part name="parameters" element="tns:sayHello">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="ServiceIface">
+ <wsdl:operation name="sayHello">
+ <wsdl:input name="sayHello" message="tns:sayHello">
+ </wsdl:input>
+ <wsdl:output name="sayHelloResponse"
message="tns:sayHelloResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="SaajServiceSoapBinding"
type="tns:ServiceIface">
+ <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="sayHello">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sayHello">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sayHelloResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="SaajService">
+ <wsdl:port name="SaajServicePort"
binding="tns:SaajServiceSoapBinding">
+ <soap:address location="http://localhost:8080/SaajService"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/cxf/WEB-INF/wsdl/SaajService.wsdl
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native