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 nt...@apache.org on 2008/11/10 21:02:21 UTC
svn commit: r712819 - in /webservices/axis2/trunk/java/modules:
jaxws-integration/
jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/
jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/META-INF/
jaxws-integration/test/o...
Author: nthaker
Date: Mon Nov 10 12:02:20 2008
New Revision: 712819
URL: http://svn.apache.org/viewvc?rev=712819&view=rev
Log:
JIRA AXIS2-4126
Multiple SOAP Binding Support for JAX-WS Provider endpoint
Added:
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/META-INF/
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/META-INF/MANIFEST.MF
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/SOAPBindingProvider.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/soapmsg/
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/soapmsg/META-INF/
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/soapmsg/SoapMessageProvider.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/string/
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/string/META-INF/
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/string/StringProvider.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SOAPBindingProviderTests.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SoapMessageProviderTests.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/StringProviderTests.java
Modified:
webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Constants.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.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/EndpointDescriptionImpl.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java
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=712819&r1=712818&r2=712819&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml Mon Nov 10 12:02:20 2008
@@ -1220,7 +1220,54 @@
basedir="${pom.basedir}/target/test-classes/servicejars/StringListService"
/>
<delete dir="target/test-classes/servicejars/StringListService"/>
-
+
+ <copy toDir="target/test-classes/servicejars/SOAPBindingProviderService/">
+ <fileset dir="target/test-classes">
+ <include name="org/apache/axis2/jaxws/provider/soapbinding/SOAPBindingProvider**"/>
+ <exclude name="org/apache/axis2/jaxws/provider/soapbinding/META-INF/services.xml" />
+ </fileset>
+ <fileset dir="test/org/apache/axis2/jaxws/provider/soapbinding">
+ <include name="META-INF/**"/>
+ <exclude name = "services.xml" />
+ </fileset>
+ </copy>
+ <zip destfile="target/test-classes/servicejars/SOAPBindingProviderService.jar"
+ basedir="${pom.basedir}/target/test-classes/servicejars/SOAPBindingProviderService"
+ />
+
+ <delete dir="target/test-classes/servicejars/SOAPBindingProviderService"/>
+
+ <copy toDir="target/test-classes/servicejars/SOAPBindingStringProviderService/">
+ <fileset dir="target/test-classes">
+ <include name="org/apache/axis2/jaxws/provider/soapbinding/string/**"/>
+ <exclude name="org/apache/axis2/jaxws/provider/soapbinding/string/META-INF/services.xml" />
+ </fileset>
+ <fileset dir="test/org/apache/axis2/jaxws/provider/soapbinding/string">
+ <include name="META-INF/**"/>
+ <exclude name = "services.xml" />
+ </fileset>
+ </copy>
+
+ <zip destfile="target/test-classes/servicejars/SOAPBindingStringProviderService.jar"
+ basedir="${pom.basedir}/target/test-classes/servicejars/SOAPBindingStringProviderService"
+ />
+ <delete dir="target/test-classes/servicejars/SOAPBindingStringProviderService"/>
+
+ <copy toDir="target/test-classes/servicejars/SoapMessageProviderService/">
+ <fileset dir="target/test-classes">
+ <include name="org/apache/axis2/jaxws/provider/soapbinding/soapmsg/**"/>
+ <exclude name="org/apache/axis2/jaxws/provider/soapbinding/soapmsg/META-INF/services.xml" />
+ </fileset>
+ <fileset dir="test/org/apache/axis2/jaxws/provider/soapbinding/soapmsg">
+ <include name="META-INF/**"/>
+ <exclude name = "services.xml" />
+ </fileset>
+ </copy>
+ <zip destfile="target/test-classes/servicejars/SoapMessageProviderService.jar"
+ basedir="${pom.basedir}/target/test-classes/servicejars/SoapMessageProviderService"
+ />
+ <delete dir="target/test-classes/servicejars/SoapMessageProviderService"/>
+
<copy toDir="target/test-classes/servicejars/HandlerHeaderService/">
<fileset dir="target/test-classes">
<include name="org/apache/axis2/jaxws/handler/header/**"/>
@@ -1242,7 +1289,7 @@
basedir="${pom.basedir}/target/test-classes/servicejars/HandlerHeaderService"
/>
<delete dir="target/test-classes/servicejars/HandlerHeaderService"/>
-
+
<copy toDir="target/test-classes/">
<fileset dir="test-resources/">
<include name="**/*.properties"/>
@@ -1355,6 +1402,10 @@
<include>**/RuntimeExceptionsAsyncMepTest.java</include>
<include>**/AddressingProviderTests.java</include>
<include>**/TypeSubstitutionTests.java</include>
+ <include>**/SOAPBindingProviderTests.java</include>
+ <include>**/SoapMessageProviderTests.java</include>
+ <include>**/StringProviderTests.java</include>
+
</includes>
<systemProperties>
<property>
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/META-INF/MANIFEST.MF?rev=712819&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/META-INF/MANIFEST.MF (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/META-INF/MANIFEST.MF Mon Nov 10 12:02:20 2008
@@ -0,0 +1 @@
+Manifest-Version: 1.0
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/SOAPBindingProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/SOAPBindingProvider.java?rev=712819&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/SOAPBindingProvider.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/SOAPBindingProvider.java Mon Nov 10 12:02:20 2008
@@ -0,0 +1,95 @@
+package org.apache.axis2.jaxws.provider.soapbinding;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.WebServiceProvider;
+
+import org.apache.axis2.jaxws.Constants;
+@WebServiceProvider(serviceName="SOAPBindingProviderService",
+ targetNamespace="http://SOAPBindingProvider.provider.jaxws.axis2.apache.org",
+ portName="SOAPBindingProviderPort")
+@ServiceMode(value=Service.Mode.MESSAGE)
+@BindingType(Constants.SOAP_HTTP_BINDING)
+public class SOAPBindingProvider implements Provider<SOAPMessage> {
+ private static final String SOAP11_NS_URI = "http://schemas.xmlsoap.org/soap/envelope/";
+ private static final String SOAP12_NS_URI = "http://www.w3.org/2003/05/soap-envelope";
+
+ public static final String SOAP11_ENVELOPE_HEAD = "<?xml version='1.0' encoding='utf-8'?>" +
+ "<soapenv:Envelope xmlns:soapenv=\"" + SOAP11_NS_URI + "\">" +
+ "<soapenv:Header />" +
+ "<soapenv:Body>";
+
+ public static final String SOAP12_ENVELOPE_HEAD =
+ "<?xml version='1.0' encoding='utf-8'?>" +
+ "<soapenv:Envelope xmlns:soapenv=\"" + SOAP12_NS_URI + "\">" +
+ "<soapenv:Header />" +
+ "<soapenv:Body>";
+
+ public static final String SOAP11_ENVELOPE_TAIL =
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public static final String SOAP12_ENVELOPE_TAIL =
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+
+ String soap11ResponseStr = "SOAP11 request received";
+ String soap12ResponseStr = "SOAP12 request received";
+
+ public SOAPMessage invoke(SOAPMessage soapMessage) {
+ try{
+ System.out.println("Start Invoke(SOAPMessage)");
+ String namespaceURI = getSoapVersionURI(soapMessage);
+ //return SOAP11 response if this is a SOAP11 Message
+ if(namespaceURI.equals(SOAP11_NS_URI)){
+ System.out.println("SOAP11_NS_URI found in the request");
+ return getSOAP11Response();
+ }
+ //return SOAP12 response if this is a SOAP11 Message
+ if(namespaceURI.equals(SOAP12_NS_URI)){
+ System.out.println("SOAP12_NS_URI found in the request");
+ return getSOAP12Response();
+ }
+ }catch(Exception e){
+ throw new WebServiceException(e);
+ }
+ throw new WebServiceException("Request received but could not interper the protocol");
+ }
+
+ private String getSoapVersionURI(SOAPMessage soapMessage)throws SOAPException{
+ SOAPPart sp = soapMessage.getSOAPPart();
+ SOAPEnvelope envelope = sp.getEnvelope();
+ return envelope.getNamespaceURI();
+ }
+
+ private SOAPMessage getSOAP11Response() throws SOAPException, IOException{
+ MessageFactory factory = MessageFactory.newInstance();
+ String responseXML = SOAP11_ENVELOPE_HEAD +"<return>"+ soap11ResponseStr+"</return>" + SOAP11_ENVELOPE_TAIL;
+ System.out.println("Creating SOAP11 Response");
+ return factory.createMessage(null, new ByteArrayInputStream(responseXML.getBytes()));
+
+ }
+
+ private SOAPMessage getSOAP12Response() throws SOAPException, IOException{
+ MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+ MimeHeaders header = new MimeHeaders();
+ header.addHeader("Content-Type", "application/soap+xml");
+ String responseXML = SOAP12_ENVELOPE_HEAD +"<return>"+ soap12ResponseStr+"</return>" + SOAP12_ENVELOPE_TAIL;
+ System.out.println("Creating SOAP12 Response");
+ return factory.createMessage(header, new ByteArrayInputStream(responseXML.getBytes()));
+ }
+}
+
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/soapmsg/SoapMessageProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/soapmsg/SoapMessageProvider.java?rev=712819&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/soapmsg/SoapMessageProvider.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/soapmsg/SoapMessageProvider.java Mon Nov 10 12:02:20 2008
@@ -0,0 +1,472 @@
+package org.apache.axis2.jaxws.provider.soapbinding.soapmsg;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import javax.xml.namespace.QName;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.Detail;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.Name;
+import javax.xml.soap.Node;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.transform.Result;
+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.BindingType;
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.apache.axis2.jaxws.Constants;
+
+@WebServiceProvider(serviceName="SoapMessageProviderService", portName="SoapMessageProviderPort")
+@BindingType(Constants.SOAP_HTTP_BINDING)
+@ServiceMode(value=Service.Mode.MESSAGE)
+public class SoapMessageProvider implements Provider<SOAPMessage> {
+
+ String responseMsgStart = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header/><soapenv:Body>";
+ String responseMsgEnd = "</soapenv:Body></soapenv:Envelope>";
+
+ // Requests and Response values of invoke_str and return_str
+ // These constants are referenced by the SoapMessageProviderTest and SoapMessageProvider
+ public static String RESPONSE_NAME = "ReturnType";
+ public static String RESPONSE_DATA_NAME = "return_str";
+ public static String REQUEST_NAME = "invokeOp";
+ public static String REQUEST_DATA_NAME = "invoke_str";
+
+ public static String XML_REQUEST = "xml request";
+ public static String XML_RESPONSE = "xml response";
+ public static String XML_EMPTYBODY_REQUEST = "xml empty body request";
+ public static String XML_CHECKHEADERS_REQUEST = "xml check headers request";
+ public static String XML_CHECKHEADERS_RESPONSE= "xml check headers response";
+ public static String XML_ATTACHMENT_REQUEST = "xml and attachment request";
+ public static String XML_ATTACHMENT_RESPONSE = "xml and attachment response";
+ public static String XML_MTOM_REQUEST = "xml and mtom request";
+ public static String XML_MTOM_RESPONSE = "xml and mtom response";
+ public static String XML_SWAREF_REQUEST = "xml and swaref request";
+ public static String XML_SWAREF_RESPONSE = "xml and swaref response";
+ public static String XML_FAULT_REQUEST = "xml fault";
+ public static String XML_SOAP12_FAULT_REQUEST = "xml soap12 fault";
+ public static String XML_WSE_REQUEST = "xml wse fault";
+ public static String XML_SOAP12_RESPONSE = "xml soap12 response";
+
+ private String XML_RETURN = "<ns2:ReturnType xmlns:ns2=\"http://test\"><return_str>" +
+ SoapMessageProvider.XML_RESPONSE +
+ "</return_str></ns2:ReturnType>";
+ private String ATTACHMENT_RETURN = "<ns2:ReturnType xmlns:ns2=\"http://test\"><return_str>" +
+ SoapMessageProvider.XML_ATTACHMENT_RESPONSE +
+ "</return_str></ns2:ReturnType>";
+ private String MTOM_RETURN = "<ns2:ReturnType xmlns:ns2=\"http://test\"><return_str>" +
+ SoapMessageProvider.XML_MTOM_RESPONSE +
+ "</return_str>" +
+ SoapMessageProvider.MTOM_REF +
+ "</ns2:ReturnType>";
+ private String SWAREF_RETURN = "<ns2:ReturnType xmlns:ns2=\"http://test\"><return_str>" +
+ SoapMessageProvider.XML_SWAREF_RESPONSE +
+ "</return_str>" +
+ SoapMessageProvider.SWAREF_REF +
+ "</ns2:ReturnType>";
+ private String CHECKHEADERS_RETURN = "<ns2:ReturnType xmlns:ns2=\"http://test\"><return_str>" +
+ SoapMessageProvider.XML_CHECKHEADERS_RESPONSE +
+ "</return_str>" +
+ "</ns2:ReturnType>";
+
+ public static String TEXT_XML_ATTACHMENT = "<myAttachment>Hello World</myAttachment>";
+ public static String ID = "helloWorld123";
+
+ public static String MTOM_REF = "<data>" +
+ "<xop:Include href='" + ID + "' xmlns:xop='http://www.w3.org/2004/08/xop/include' />" +
+ "</data>";
+ public static String SWAREF_REF = "<data>" +
+ "cid:" + ID +
+ "</data>";
+
+ public static final QName FOO_HEADER_QNAME = new QName("http://sample1", "foo", "pre1");
+ public static final QName BAR_HEADER_QNAME = new QName("http://sample2", "bar", "pre2");
+ public static final QName BAT_HEADER_QNAME = new QName("http://sample3", "bat", "pre3");
+
+ public static final String FOO_HEADER_CONTENT = "foo content";
+ public static final String BAR_HEADER_CONTENT1 = "bar content1";
+ public static final String BAR_HEADER_CONTENT2 = "bar content2";
+ public static final String BAT_HEADER_CONTENT = "bat content";
+ private static final String SOAP11_NS_URI = "http://schemas.xmlsoap.org/soap/envelope/";
+ private static final String SOAP12_NS_URI = "http://www.w3.org/2003/05/soap-envelope";
+ public static final String SOAP11_ENVELOPE_HEAD = "<?xml version='1.0' encoding='utf-8'?>" +
+ "<soapenv:Envelope xmlns:soapenv=\"" + SOAP11_NS_URI + "\">" +
+ "<soapenv:Header />" +
+ "<soapenv:Body>";
+
+ public static final String SOAP12_ENVELOPE_HEAD =
+ "<?xml version='1.0' encoding='utf-8'?>" +
+ "<soapenv:Envelope xmlns:soapenv=\"" + SOAP12_NS_URI + "\">" +
+ "<soapenv:Header />" +
+ "<soapenv:Body>";
+
+ public static final String SOAP11_ENVELOPE_TAIL =
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public static final String SOAP12_ENVELOPE_TAIL =
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public SOAPMessage invoke(SOAPMessage soapMessage) throws SOAPFaultException {
+ 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");
+
+ // Get the discrimination element. This performs basic assertions on the received message
+ SOAPElement discElement = assertRequestXML(soapMessage);
+
+ // Use the data element text to determine the type of response to send
+ SOAPMessage response = null;
+ // TODO AXIS2 SAAJ should (but does not) support the getTextContent();
+ // String text = dataElement.getTextContent();
+ String text = discElement.getValue();
+ if (XML_REQUEST.equals(text)) {
+ response = getXMLResponse(soapMessage, discElement);
+ } else if (XML_EMPTYBODY_REQUEST.equals(text)) {
+ response = getXMLEmptyBodyResponse(soapMessage, discElement);
+ } else if (XML_CHECKHEADERS_REQUEST.equals(text)) {
+ response = getXMLCheckHeadersResponse(soapMessage, discElement);
+ } else if (XML_ATTACHMENT_REQUEST.equals(text)) {
+ response = getXMLAttachmentResponse(soapMessage, discElement);
+ } else if (XML_MTOM_REQUEST.equals(text)) {
+ response = getXMLMTOMResponse(soapMessage, discElement);
+ } else if (XML_SWAREF_REQUEST.equals(text)) {
+ response = getXMLSWARefResponse(soapMessage, discElement);
+ } else if (XML_FAULT_REQUEST.equals(text)) {
+ throwSOAPFaultException();
+ } else if (XML_WSE_REQUEST.equals(text)) {
+ throwWebServiceException();
+ } else if(XML_SOAP12_RESPONSE.equals(text)){
+ response = getSOAP12Response();
+ }else {
+ // We should not get here
+ System.out.println("Unknown Type of Message");
+ assertTrue(false);
+ }
+
+ // Write out the Message
+ System.out.println(">> Response being sent by Server:");
+ //response.writeTo(System.out);
+ //System.out.println("\n");
+ return response;
+ } catch (WebServiceException wse) {
+ throw wse;
+ } catch(Exception e){
+ System.out.println("***ERROR: In SoapMessageProvider.invoke: Caught exception " + e);
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * Common assertion checking of the request
+ * @param msg
+ * @return SOAPElement representing the data element
+ */
+ private SOAPElement assertRequestXML(SOAPMessage msg) throws Exception {
+ assertTrue(msg != null);
+ SOAPBody body = msg.getSOAPBody();
+ assertTrue(body != null);
+
+ Node invokeElement = (Node) body.getFirstChild();
+ assertTrue(invokeElement instanceof SOAPElement);
+ assertTrue(SoapMessageProvider.REQUEST_NAME.equals(invokeElement.getLocalName()));
+
+ Node discElement = (Node) invokeElement.getFirstChild();
+ assertTrue(discElement instanceof SOAPElement);
+ assertTrue(SoapMessageProvider.REQUEST_DATA_NAME.equals(discElement.getLocalName()));
+
+ String text = discElement.getValue();
+ assertTrue(text != null);
+ assertTrue(text.length() > 0);
+ System.out.println("Request Message Type is:" + text);
+
+ return (SOAPElement) discElement;
+ }
+
+ /**
+ * Get the response for an XML only request
+ * @param request
+ * @param dataElement
+ * @return SOAPMessage
+ */
+ private SOAPMessage getXMLResponse(SOAPMessage request, SOAPElement dataElement) throws Exception {
+ SOAPMessage response;
+
+ // Transport header check
+ assertTrue(request.getContentDescription() != null);
+ assertTrue(request.getContentDescription().equals(SoapMessageProvider.XML_REQUEST));
+
+ // Additional assertion checks
+ assertTrue(countAttachments(request) == 0);
+
+ // Build the Response
+ MessageFactory factory = MessageFactory.newInstance();
+ String responseXML = responseMsgStart + XML_RETURN + responseMsgEnd;
+ response = factory.createMessage(null, new ByteArrayInputStream(responseXML.getBytes()));
+
+ // Set a content description
+ response.setContentDescription(SoapMessageProvider.XML_RESPONSE);
+ return response;
+ }
+
+ /**
+ * Get the response for an XML only request
+ * @param request
+ * @param dataElement
+ * @return SOAPMessage
+ */
+ private SOAPMessage getXMLEmptyBodyResponse(SOAPMessage request, SOAPElement dataElement) throws Exception {
+ SOAPMessage response;
+
+
+ // Additional assertion checks
+ assertTrue(countAttachments(request) == 0);
+
+ // Build the Response
+ MessageFactory factory = MessageFactory.newInstance();
+ response = factory.createMessage();
+
+ return response;
+ }
+
+ /**
+ * Get the response for an XML check headers request
+ * @param request
+ * @param dataElement
+ * @return SOAPMessage
+ */
+ private SOAPMessage getXMLCheckHeadersResponse(SOAPMessage request,
+ SOAPElement dataElement) throws Exception {
+ SOAPMessage response;
+
+ // Additional assertion checks
+ assertTrue(countAttachments(request) == 0);
+
+ // Check for specific headers
+ SOAPHeader sh = request.getSOAPHeader();
+ assertTrue(sh != null);
+
+ SOAPHeaderElement she = (SOAPHeaderElement)
+ sh.getChildElements(FOO_HEADER_QNAME).next();
+ assertTrue(she != null);
+ assertTrue(she instanceof SOAPHeaderElement);
+ String text = she.getValue();
+ assertTrue(FOO_HEADER_CONTENT.equals(text));
+
+ Iterator it = sh.getChildElements(BAR_HEADER_QNAME);
+ she = (SOAPHeaderElement) it.next();
+ assertTrue(she != null);
+ assertTrue(she instanceof SOAPHeaderElement);
+ text = she.getValue();
+ assertTrue(BAR_HEADER_CONTENT1.equals(text));
+ she = (SOAPHeaderElement) it.next();
+ assertTrue(she != null);
+ assertTrue(she instanceof SOAPHeaderElement);
+ text = she.getValue();
+ assertTrue(BAR_HEADER_CONTENT2.equals(text));
+
+ assertTrue(!sh.getChildElements(BAT_HEADER_QNAME).hasNext());
+
+
+ // Build the Response
+ MessageFactory factory = MessageFactory.newInstance();
+ String responseXML = responseMsgStart + CHECKHEADERS_RETURN + responseMsgEnd;
+ response = factory.createMessage(null, new ByteArrayInputStream(responseXML.getBytes()));
+ response.getSOAPHeader().addHeaderElement(BAR_HEADER_QNAME).
+ addTextNode(BAR_HEADER_CONTENT1);
+ response.getSOAPHeader().addHeaderElement(BAR_HEADER_QNAME).
+ addTextNode(BAR_HEADER_CONTENT2);
+ response.getSOAPHeader().addHeaderElement(BAT_HEADER_QNAME).
+ addTextNode(BAT_HEADER_CONTENT);
+
+ return response;
+ }
+
+ /**
+ * Get the response for an XML and an Attachment request
+ * @param request
+ * @param dataElement
+ * @return SOAPMessage
+ */
+ private SOAPMessage getXMLAttachmentResponse(SOAPMessage request, SOAPElement dataElement) throws Exception {
+ SOAPMessage response;
+
+ // Additional assertion checks
+ assertTrue(countAttachments(request) == 1);
+ AttachmentPart requestAP = (AttachmentPart) request.getAttachments().next();
+ StreamSource contentSS = (StreamSource) requestAP.getContent();
+ String content = getAsString(contentSS);
+ assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+
+ // Build the Response
+ MessageFactory factory = MessageFactory.newInstance();
+ String responseXML = responseMsgStart + ATTACHMENT_RETURN + responseMsgEnd;
+ response = factory.createMessage(null, new ByteArrayInputStream(responseXML.getBytes()));
+
+ // Create and attach the attachment
+ AttachmentPart ap = response.createAttachmentPart(SoapMessageProvider.TEXT_XML_ATTACHMENT, "text/xml");
+ ap.setContentId(ID);
+ response.addAttachmentPart(ap);
+
+ return response;
+ }
+
+ /**
+ * Get the response for an XML and an MTOM Attachment request
+ * @param request
+ * @param dataElement
+ * @return SOAPMessage
+ */
+ private SOAPMessage getXMLMTOMResponse(SOAPMessage request, SOAPElement dataElement) throws Exception {
+ SOAPMessage response;
+
+ System.out.println("Received MTOM Message");
+ // Additional assertion checks
+ assertTrue(countAttachments(request) == 1);
+ AttachmentPart requestAP = (AttachmentPart) request.getAttachments().next();
+ StreamSource contentSS = (StreamSource) requestAP.getContent();
+ String content = getAsString(contentSS);
+ assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+
+ System.out.println("The MTOM Request Message appears correct.");
+
+ // Build the Response
+ MessageFactory factory = MessageFactory.newInstance();
+ String responseXML = responseMsgStart + MTOM_RETURN + responseMsgEnd;
+ response = factory.createMessage(null, new ByteArrayInputStream(responseXML.getBytes()));
+
+ // Create and attach the attachment
+ AttachmentPart ap = response.createAttachmentPart(SoapMessageProvider.TEXT_XML_ATTACHMENT, "text/xml");
+ ap.setContentId(ID);
+ response.addAttachmentPart(ap);
+
+ System.out.println("Returning the Response Message");
+ return response;
+ }
+
+ /**
+ * Get the response for an XML and an MTOM Attachment request
+ * @param request
+ * @param dataElement
+ * @return SOAPMessage
+ */
+ private SOAPMessage getXMLSWARefResponse(SOAPMessage request, SOAPElement dataElement) throws Exception {
+ SOAPMessage response;
+
+ // Additional assertion checks
+ assertTrue(countAttachments(request) == 1);
+ AttachmentPart requestAP = (AttachmentPart) request.getAttachments().next();
+ assertTrue(requestAP.getContentId().equals(ID));
+ StreamSource contentSS = (StreamSource) requestAP.getContent();
+ String content = getAsString(contentSS);
+ assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+
+ // Build the Response
+ MessageFactory factory = MessageFactory.newInstance();
+ String responseXML = responseMsgStart + SWAREF_RETURN + responseMsgEnd;
+ response = factory.createMessage(null, new ByteArrayInputStream(responseXML.getBytes()));
+
+ // Create and attach the attachment
+ AttachmentPart ap = response.createAttachmentPart(SoapMessageProvider.TEXT_XML_ATTACHMENT, "text/xml");
+ ap.setContentId(ID);
+ response.addAttachmentPart(ap);
+
+ return response;
+ }
+
+ private void throwSOAPFaultException() throws SOAPFaultException {
+ try {
+ MessageFactory mf = MessageFactory.newInstance();
+ SOAPFactory sf = SOAPFactory.newInstance();
+
+ SOAPMessage m = mf.createMessage();
+ SOAPBody body = m.getSOAPBody();
+ SOAPFault fault = body.addFault();
+ QName faultCode = new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "Client");
+ fault.setFaultCode(faultCode);
+ fault.setFaultString("sample fault");
+ Detail detail = fault.addDetail();
+ Name deName = sf.createName("detailEntry");
+ SOAPElement detailEntry = detail.addDetailEntry(deName);
+ detailEntry.addTextNode("sample detail");
+ fault.setFaultActor("sample actor");
+
+ SOAPFaultException sfe = new SOAPFaultException(fault);
+ throw sfe;
+ } catch (SOAPFaultException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ private void throwWebServiceException() throws WebServiceException {
+ throw new WebServiceException("A WSE was thrown");
+ }
+ /**
+ * Count Attachments
+ * @param msg
+ * @return
+ */
+ private int countAttachments(SOAPMessage msg) {
+ Iterator it = msg.getAttachments();
+ int count = 0;
+ assertTrue(it != null);
+ while (it.hasNext()) {
+ it.next();
+ count++;
+ }
+ return count;
+ }
+
+ public static String getAsString(StreamSource ss) throws Exception {
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ Result result = new StreamResult(out);
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.transform(ss, result);
+ String text = new String(out.toByteArray());
+ return text;
+ }
+
+ private void assertTrue(boolean testAssertion) {
+ if (!testAssertion) {
+ throw new RuntimeException("Assertion false");
+ }
+ }
+ private SOAPMessage getSOAP12Response() throws SOAPException, IOException{
+ MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+ MimeHeaders header = new MimeHeaders();
+ header.addHeader("Content-Type", "application/soap+xml");
+ String responseXML = SOAP12_ENVELOPE_HEAD +"<return>"+XML_SOAP12_RESPONSE+"</return>" + SOAP12_ENVELOPE_TAIL;
+ System.out.println("Creating SOAP12 Response");
+ return factory.createMessage(header, new ByteArrayInputStream(responseXML.getBytes()));
+ }
+}
+
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/string/StringProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/string/StringProvider.java?rev=712819&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/string/StringProvider.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/string/StringProvider.java Mon Nov 10 12:02:20 2008
@@ -0,0 +1,26 @@
+package org.apache.axis2.jaxws.provider.soapbinding.string;
+
+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 org.apache.axis2.jaxws.Constants;
+@WebServiceProvider(serviceName="SOAPBindingStringProviderService",
+ targetNamespace="http://StringProvider.soapbinding.provider.jaxws.axis2.apache.org",
+ portName="SOAPBindingStringProviderPort")
+@ServiceMode(value=Service.Mode.PAYLOAD)
+@BindingType(Constants.SOAP_HTTP_BINDING)
+/*
+ * Provider with PAYLOAD Mode on Server, will receive soap11 and soap12 requests.
+ */
+public class StringProvider implements Provider<String> {
+ public String invoke(String obj) {
+ if(obj == null){
+ return null;
+ }
+ return "<return>Hello String Provider</return>";
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SOAPBindingProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SOAPBindingProviderTests.java?rev=712819&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SOAPBindingProviderTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SOAPBindingProviderTests.java Mon Nov 10 12:02:20 2008
@@ -0,0 +1,126 @@
+package org.apache.axis2.jaxws.provider.soapbinding.tests;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+
+import org.apache.axis2.jaxws.framework.AbstractTestCase;
+import org.apache.axis2.jaxws.polymorphic.shape.tests.PolymorphicTests;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class SOAPBindingProviderTests extends AbstractTestCase {
+ private String endpointUrl = "http://localhost:6060/axis2/services/SOAPBindingProviderService.SOAPBindingProviderPort";
+ private QName serviceName = new QName("http://SOAPBindingProvider.provider.jaxws.axis2.apache.org", "SOAPBindingProviderService");
+ private QName portName = new QName("http://SOAPBindingProvider.provider.jaxws.axis2.apache.org", "SOAPBindingProviderPort");
+
+ private static final String SOAP11_NS_URI = "http://schemas.xmlsoap.org/soap/envelope/";
+ private static final String SOAP12_NS_URI = "http://www.w3.org/2003/05/soap-envelope";
+
+ public static final String SOAP11_ENVELOPE_HEAD = "<?xml version='1.0' encoding='utf-8'?>" +
+ "<soapenv:Envelope xmlns:soapenv=\"" + SOAP11_NS_URI + "\">" +
+ "<soapenv:Header />" +
+ "<soapenv:Body>";
+
+ public static final String SOAP12_ENVELOPE_HEAD =
+ "<?xml version='1.0' encoding='utf-8'?>" +
+ "<soapenv:Envelope xmlns:soapenv=\"" + SOAP12_NS_URI + "\">" +
+ "<soapenv:Header />" +
+ "<soapenv:Body>";
+
+ public static final String SOAP11_ENVELOPE_TAIL =
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public static final String SOAP12_ENVELOPE_TAIL =
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+
+ String request = "<invokeOp>Hello World</invokeOp>";
+
+ public static Test suite() {
+ return getTestSetup(new TestSuite(SOAPBindingProviderTests.class));
+ }
+
+ public void testSoap11Request(){
+ try{
+ System.out.println("---------------------------------------");
+ System.out.println("test: " + getName());
+
+ Dispatch<SOAPMessage> dispatch=getDispatch();
+ String soapMessage = getSOAP11Message();
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage message = factory.createMessage(null, new ByteArrayInputStream(soapMessage.getBytes()));
+ Object obj = dispatch.invoke(message);
+ assertTrue(obj!=null && obj instanceof SOAPMessage);
+ assertTrue(getVersionURI(message).equals(SOAP11_NS_URI));
+ }catch(Exception e){
+ System.out.println("Failure while sending soap 11 request");
+ System.out.println(e.getMessage());
+ fail();
+ }
+ }
+
+ public void testSoap12Request(){
+ try{
+ System.out.println("---------------------------------------");
+ System.out.println("test: " + getName());
+
+ Dispatch<SOAPMessage> dispatch=getDispatch();
+ String soapMessage = getSOAP12Message();
+ System.out.println("soap message ="+soapMessage);
+ MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+ MimeHeaders header = new MimeHeaders();
+ header.addHeader("Content-Type", "application/soap+xml");
+ SOAPMessage message = factory.createMessage(header, new ByteArrayInputStream(soapMessage.getBytes()));
+ Object obj = dispatch.invoke(message);
+ assertTrue(obj!=null && obj instanceof SOAPMessage);
+ assertTrue(getVersionURI(message).equals(SOAP12_NS_URI));
+ System.out.println("Provider endpoint was able to receive both SOAP 11 and SOAP 12 request");
+ }catch(Exception e){
+ System.out.println("Expecting that endpoint will be able to receive soap 12 and soap 11 request");
+ System.out.println(e.getMessage());
+ fail();
+
+ }
+ }
+
+ private Dispatch<SOAPMessage> getDispatch(){
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName, null, endpointUrl);
+ Dispatch<SOAPMessage> dispatch = svc.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
+ BindingProvider p = (BindingProvider) dispatch;
+ p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUrl);
+ return dispatch;
+ }
+
+ private String getSOAP11Message() throws SOAPException, IOException{
+ return SOAP11_ENVELOPE_HEAD+request+SOAP11_ENVELOPE_TAIL;
+ }
+
+ private String getSOAP12Message() throws SOAPException, IOException{
+ return SOAP12_ENVELOPE_HEAD+request+SOAP12_ENVELOPE_TAIL;
+ }
+
+ private String getVersionURI(SOAPMessage soapMessage)throws SOAPException{
+ SOAPPart sp = soapMessage.getSOAPPart();
+ SOAPEnvelope envelope = sp.getEnvelope();
+ return envelope.getNamespaceURI();
+ }
+}
+
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SoapMessageProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SoapMessageProviderTests.java?rev=712819&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SoapMessageProviderTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/SoapMessageProviderTests.java Mon Nov 10 12:02:20 2008
@@ -0,0 +1,509 @@
+package org.apache.axis2.jaxws.provider.soapbinding.tests;
+
+
+import java.io.ByteArrayInputStream;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.DetailEntry;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.Node;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.axis2.jaxws.framework.AbstractTestCase;
+import org.apache.axis2.jaxws.polymorphic.shape.tests.PolymorphicTests;
+import org.apache.axis2.jaxws.provider.soapbinding.soapmsg.SoapMessageProvider;
+
+/**
+ * Tests Dispatch<SOAPMessage> client and a Provider<SOAPMessage> service.
+ * The client and service interaction tests various xml and attachment scenarios
+ *
+ */
+public class SoapMessageProviderTests extends AbstractTestCase {
+ private String endpointUrl = "http://localhost:6060/axis2/services/SoapMessageProviderService.SoapMessageProviderPort";
+ private QName serviceName = new QName("http://soapmsg.soapbinding.provider.jaxws.axis2.apache.org", "SOAPBindingSoapMessageProviderService");
+ private QName portName = new QName("http://soapmsg.soapbinding.provider.jaxws.axis2.apache.org", "SoapMessageProviderPort");
+
+ private String reqMsgStart = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body>";
+ ;
+
+ private String reqMsgEnd = "</soap:Body></soap:Envelope>";
+
+ private String XML_INVOKE = "<ns2:invokeOp xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_REQUEST +
+ "</invoke_str></ns2:invokeOp>";
+ private String EMPTYBODY_INVOKE = "<ns2:invokeOp xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_EMPTYBODY_REQUEST +
+ "</invoke_str></ns2:invokeOp>";
+ private String CHECKHEADERS_INVOKE = "<ns2:invokeOp xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_CHECKHEADERS_REQUEST +
+ "</invoke_str></ns2:invokeOp>";
+ private String ATTACHMENT_INVOKE = "<ns2:invokeOp xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_ATTACHMENT_REQUEST +
+ "</invoke_str></ns2:invokeOp>";
+ private String MTOM_INVOKE = "<ns2:invokeOp xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_MTOM_REQUEST +
+ "</invoke_str>" +
+ SoapMessageProvider.MTOM_REF +
+ "</ns2:invokeOp>";
+ private String SWAREF_INVOKE = "<ns2:invokeOp xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_SWAREF_REQUEST +
+ "</invoke_str>" +
+ SoapMessageProvider.SWAREF_REF +
+ "</ns2:invokeOp>";
+ private String XML_FAULT_INVOKE = "<ns2:invokeOp xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_FAULT_REQUEST +
+ "</invoke_str></ns2:invokeOp>";
+ private String XML_WSE_INVOKE = "<ns2:invokeOp xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_WSE_REQUEST +
+ "</invoke_str></ns2:invokeOp>";
+ private String XML_SOAP12_FAULT_INVOKE = "<ns2:invokeOp xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_SOAP12_FAULT_REQUEST +
+ "</invoke_str></ns2:invokeOp>";
+ private String XML_SOAP12_RESPONSE_INVOKE = "<ns2:invokeOp xmlns:ns2=\"http://org.test.soapmessage\"><invoke_str>" +
+ SoapMessageProvider.XML_SOAP12_RESPONSE +
+ "</invoke_str></ns2:invokeOp>";
+
+ public static Test suite() {
+ return getTestSetup(new TestSuite(SoapMessageProviderTests.class));
+ }
+ /**
+ * Sends an SOAPMessage containing only xml data
+ * Provider will throw a Fault
+ */
+ public void testProviderSOAPMessageSOAPFault() throws Exception {
+
+ // Create the dispatch
+ Dispatch<SOAPMessage> dispatch = createDispatch();
+
+ // Create the SOAPMessage
+ String msg = reqMsgStart + XML_FAULT_INVOKE + reqMsgEnd;
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage request = factory.createMessage(null,
+ new ByteArrayInputStream(msg.getBytes()));
+
+ // Test the transport headers by sending a content description
+ request.setContentDescription(SoapMessageProvider.XML_FAULT_REQUEST);
+
+ try {
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ SOAPMessage response = dispatch.invoke(request);
+ assertTrue("Expected failure", false);
+ } catch (SOAPFaultException e) {
+ // Okay
+ SOAPFault fault = e.getFault();
+ assertTrue(fault != null);
+ assertTrue(fault.getFaultString().equals("sample fault"));
+ QName expectedFaultCode = new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "Client");
+ assertTrue(fault.getFaultCodeAsQName().equals(expectedFaultCode));
+ assertTrue(fault.getDetail() != null);
+ DetailEntry de = (DetailEntry) fault.getDetail().getDetailEntries().next();
+ assertTrue(de != null);
+ assertTrue(de.getLocalName().equals("detailEntry"));
+ assertTrue(de.getValue().equals("sample detail"));
+ assertTrue(fault.getFaultActor().equals("sample actor"));
+ }
+
+ // Try a second time
+ try {
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ SOAPMessage response = dispatch.invoke(request);
+ assertTrue("Expected failure", false);
+ } catch (SOAPFaultException e) {
+ // Okay
+ SOAPFault fault = e.getFault();
+ assertTrue(fault != null);
+ assertTrue(fault.getFaultString().equals("sample fault"));
+ QName expectedFaultCode = new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "Client");
+ assertTrue(fault.getFaultCodeAsQName().equals(expectedFaultCode));
+ assertTrue(fault.getDetail() != null);
+ DetailEntry de = (DetailEntry) fault.getDetail().getDetailEntries().next();
+ assertTrue(de != null);
+ assertTrue(de.getLocalName().equals("detailEntry"));
+ assertTrue(de.getValue().equals("sample detail"));
+ assertTrue(fault.getFaultActor().equals("sample actor"));
+ }
+ }
+
+
+ /**
+ * Sends an SOAPMessage containing only xml data
+ * Provider will throw a generic WebServicesException
+ */
+ public void testProviderSOAPMessageWebServiceException() throws Exception {
+
+ // Create the dispatch
+ Dispatch<SOAPMessage> dispatch = createDispatch();
+
+ // Create the SOAPMessage
+ String msg = reqMsgStart + XML_WSE_INVOKE + reqMsgEnd;
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage request = factory.createMessage(null,
+ new ByteArrayInputStream(msg.getBytes()));
+
+ // Test the transport headers by sending a content description
+ request.setContentDescription(SoapMessageProvider.XML_WSE_REQUEST);
+
+ try {
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ SOAPMessage response = dispatch.invoke(request);
+ assertTrue("Expected failure", false);
+ } catch (SOAPFaultException e) {
+ // Okay...SOAPFaultException should be thrown
+ SOAPFault fault = e.getFault();
+ assertTrue(fault != null);
+ assertTrue(fault.getFaultString().equals("A WSE was thrown"));
+ }
+
+ // Try a second time
+ try {
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ SOAPMessage response = dispatch.invoke(request);
+ assertTrue("Expected failure", false);
+ } catch (SOAPFaultException e) {
+ // Okay...SOAPFaultException should be thrown
+ SOAPFault fault = e.getFault();
+ assertTrue(fault != null);
+ assertTrue(fault.getFaultString().equals("A WSE was thrown"));
+ }
+ }
+
+
+ /**
+ * Sends an SOAPMessage containing xml data and raw attachments to the web service.
+ * Receives a response containing xml data and the same raw attachments.
+ */
+
+ public void testProviderSOAPMessageRawAttachment(){
+ // Raw Attachments are attachments that are not referenced in the xml with MTOM or SWARef.
+ // Currently there is no support in Axis 2 for these kinds of attachments.
+ // The belief is that most customers will use MTOM. Some legacy customers will use SWARef.
+ // Raw Attachments may be so old that no customers need this behavior.
+ try{
+ // Create the dispatch
+ Dispatch<SOAPMessage> dispatch = createDispatch();
+
+ // Create the SOAPMessage
+ String msg = reqMsgStart + ATTACHMENT_INVOKE + reqMsgEnd;
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage request = factory.createMessage(null,
+ new ByteArrayInputStream(msg.getBytes()));
+
+ // Add the Attachment
+ AttachmentPart ap = request.createAttachmentPart(SoapMessageProvider.TEXT_XML_ATTACHMENT, "text/xml");
+ ap.setContentId(SoapMessageProvider.ID);
+ request.addAttachmentPart(ap);
+
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ SOAPMessage response = dispatch.invoke(request);
+
+ // Check assertions and get the data element
+ SOAPElement dataElement = assertResponseXML(response, SoapMessageProvider.XML_ATTACHMENT_RESPONSE);
+ assertTrue(countAttachments(response) == 1);
+
+ // Get the Attachment
+ AttachmentPart attachmentPart = (AttachmentPart) response.getAttachments().next();
+
+ // Check the attachment
+ StreamSource contentSS = (StreamSource) attachmentPart.getContent();
+ String content = SoapMessageProvider.getAsString(contentSS);
+ assertTrue(content != null);
+ assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+
+ // Print out the response
+ System.out.println(">> Response [" + response.toString() + "]");
+
+
+ // Try a second time
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ response = dispatch.invoke(request);
+
+ // Check assertions and get the data element
+ dataElement = assertResponseXML(response, SoapMessageProvider.XML_ATTACHMENT_RESPONSE);
+ assertTrue(countAttachments(response) == 1);
+
+ // Get the Attachment
+ attachmentPart = (AttachmentPart) response.getAttachments().next();
+
+ // Check the attachment
+ contentSS = (StreamSource) attachmentPart.getContent();
+ content = SoapMessageProvider.getAsString(contentSS);
+ assertTrue(content != null);
+ assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+
+ // Print out the response
+ System.out.println(">> Response [" + response.toString() + "]");
+
+ }catch(Exception e){
+ e.printStackTrace();
+ fail("Caught exception " + e);
+ }
+
+ }
+
+ /**
+ * Sends an SOAPMessage containing xml data and mtom attachment.
+ * Receives a response containing xml data and the mtom attachment.
+ */
+ public void testProviderSOAPMessageMTOM(){
+ try{
+ // Create the dispatch
+ Dispatch<SOAPMessage> dispatch = createDispatch();
+
+ // MTOM should be automatically detected. There is no need to set it
+ //Binding binding = dispatch.getBinding();
+ //SOAPBinding soapBinding = (SOAPBinding) binding;
+ //soapBinding.setMTOMEnabled(true);
+
+ // Create the SOAPMessage
+ String msg = reqMsgStart + MTOM_INVOKE + reqMsgEnd;
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage request = factory.createMessage(null,
+ new ByteArrayInputStream(msg.getBytes()));
+
+ // Add the Attachment
+ AttachmentPart ap = request.createAttachmentPart(SoapMessageProvider.TEXT_XML_ATTACHMENT, "text/xml");
+ ap.setContentId(SoapMessageProvider.ID);
+ request.addAttachmentPart(ap);
+
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ SOAPMessage response = dispatch.invoke(request);
+
+ // Check assertions and get the data element
+ SOAPElement dataElement = assertResponseXML(response, SoapMessageProvider.XML_MTOM_RESPONSE);
+ assertTrue(countAttachments(response) == 1);
+
+ // Get the Attachment
+ AttachmentPart attachmentPart = (AttachmentPart) response.getAttachments().next();
+
+ // Check the attachment
+ StreamSource contentSS = (StreamSource) attachmentPart.getContent();
+ String content = SoapMessageProvider.getAsString(contentSS);
+ assertTrue(content != null);
+ assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+
+ // Print out the response
+ System.out.println(">> Response [" + response.toString() + "]");
+
+
+ // Try a second time
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ response = dispatch.invoke(request);
+
+ // Check assertions and get the data element
+ dataElement = assertResponseXML(response, SoapMessageProvider.XML_MTOM_RESPONSE);
+ assertTrue(countAttachments(response) == 1);
+
+ // Get the Attachment
+ attachmentPart = (AttachmentPart) response.getAttachments().next();
+
+ // Check the attachment
+ contentSS = (StreamSource) attachmentPart.getContent();
+ content = SoapMessageProvider.getAsString(contentSS);
+ assertTrue(content != null);
+ assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+
+ // Print out the response
+ System.out.println(">> Response [" + response.toString() + "]");
+
+ }catch(Exception e){
+ e.printStackTrace();
+ fail("Caught exception " + e);
+ }
+
+ }
+
+ /**
+ * Sends an SOAPMessage containing xml data and a swaref attachment to the web service.
+ * Receives a response containing xml data and the swaref attachment attachment.
+ */
+ public void testProviderSOAPMessageSWARef(){
+ try{
+ // Create the dispatch
+ Dispatch<SOAPMessage> dispatch = createDispatch();
+
+ // Create the SOAPMessage
+ String msg = reqMsgStart + SWAREF_INVOKE + reqMsgEnd;
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage request = factory.createMessage(null,
+ new ByteArrayInputStream(msg.getBytes()));
+
+ // Add the Attachment
+ AttachmentPart ap = request.createAttachmentPart(SoapMessageProvider.TEXT_XML_ATTACHMENT, "text/xml");
+ ap.setContentId(SoapMessageProvider.ID);
+ request.addAttachmentPart(ap);
+
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ SOAPMessage response = dispatch.invoke(request);
+
+ // Check assertions and get the data element
+ SOAPElement dataElement = assertResponseXML(response, SoapMessageProvider.XML_SWAREF_RESPONSE);
+ assertTrue(countAttachments(response) == 1);
+
+ // Get the Attachment
+ AttachmentPart attachmentPart = (AttachmentPart) response.getAttachments().next();
+
+ // Check the attachment
+ StreamSource contentSS = (StreamSource) attachmentPart.getContent();
+ String content = SoapMessageProvider.getAsString(contentSS);
+ assertTrue(content != null);
+ assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+ assertEquals(SoapMessageProvider.ID, attachmentPart.getContentId());
+
+ // Print out the response
+ System.out.println(">> Response [" + response.toString() + "]");
+
+
+
+ // Try a second time
+ // Dispatch
+ System.out.println(">> Invoking SOAPMessageProviderDispatch");
+ response = dispatch.invoke(request);
+
+ // Check assertions and get the data element
+ dataElement = assertResponseXML(response, SoapMessageProvider.XML_SWAREF_RESPONSE);
+ assertTrue(countAttachments(response) == 1);
+
+ // Get the Attachment
+ attachmentPart = (AttachmentPart) response.getAttachments().next();
+
+ // Check the attachment
+ contentSS = (StreamSource) attachmentPart.getContent();
+ content = SoapMessageProvider.getAsString(contentSS);
+ assertTrue(content != null);
+ assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+ assertEquals(SoapMessageProvider.ID, attachmentPart.getContentId());
+
+ // Print out the response
+ System.out.println(">> Response [" + response.toString() + "]");
+
+ }catch(Exception e){
+ e.printStackTrace();
+ fail("Caught exception " + e);
+ }
+
+ }
+
+ /* This is a negative test case for a Provider that has NO SOAPBinding restriction
+ * Dispatch will send a SOAP11 request and Provider will send a SOAP12 Response.
+ */
+ public void testSoap11RequestWithSoap12Response(){
+ SOAPMessage request = null;
+ Dispatch<SOAPMessage> dispatch = null;
+ try{
+ // Create the dispatch
+ dispatch = createDispatch();
+ // Create the SOAPMessage
+ String msg = reqMsgStart + XML_SOAP12_RESPONSE_INVOKE + reqMsgEnd;
+ MessageFactory factory = MessageFactory.newInstance();
+ request = factory.createMessage(null,
+ new ByteArrayInputStream(msg.getBytes()));
+ }catch(Exception e){
+ e.printStackTrace();
+ fail("Caught Exception "+e);
+ }
+ try{
+ SOAPMessage response = dispatch.invoke(request);
+ assertTrue("Expecting Failure", false);
+ }catch(SOAPFaultException e){
+ SOAPFault fault = e.getFault();
+ assertTrue(fault != null);
+ assertTrue(fault.getFaultString().equals("Request SOAP message protocol is version 1.1, but Response SOAP message is configured for SOAP 1.2. This is not supported."));
+ }
+
+ }
+ /**
+ * @return
+ * @throws Exception
+ */
+ private Dispatch<SOAPMessage> createDispatch() throws Exception {
+
+
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName,null, endpointUrl);
+ Dispatch<SOAPMessage> dispatch =
+ svc.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
+ return dispatch;
+ }
+
+ /**
+ * @return
+ * @throws Exception
+ */
+ private Dispatch<String> createStringDispatch() throws Exception {
+
+
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName,null, endpointUrl);
+ Dispatch<String> dispatch =
+ svc.createDispatch(portName, String.class, Service.Mode.PAYLOAD);
+ return dispatch;
+ }
+
+ /**
+ * Common assertion checking of the response
+ * @param msg
+ * @param expectedText
+ * @return SOAPElement representing the data element
+ */
+ private SOAPElement assertResponseXML(SOAPMessage msg, String expectedText) throws Exception {
+ assertTrue(msg != null);
+ SOAPBody body = msg.getSOAPBody();
+ assertTrue(body != null);
+
+ Node invokeElement = (Node) body.getFirstChild();
+ assertTrue(invokeElement instanceof SOAPElement);
+ assertEquals(SoapMessageProvider.RESPONSE_NAME, invokeElement.getLocalName());
+
+ Node dataElement = (Node) invokeElement.getFirstChild();
+ assertTrue(dataElement instanceof SOAPElement);
+ assertEquals(SoapMessageProvider.RESPONSE_DATA_NAME, dataElement.getLocalName());
+
+ // TODO AXIS2 SAAJ should (but does not) support the getTextContent();
+ // String text = dataElement.getTextContent();
+ String text = dataElement.getValue();
+ assertEquals("Found ("+ text + ") but expected (" + expectedText + ")", expectedText, text);
+
+ return (SOAPElement) dataElement;
+ }
+
+ /**
+ * Count Attachments
+ * @param msg
+ * @return
+ */
+ private int countAttachments(SOAPMessage msg) {
+ Iterator it = msg.getAttachments();
+ int count = 0;
+ assertTrue(it != null);
+ while (it.hasNext()) {
+ it.next();
+ count++;
+ }
+ return count;
+ }
+}
+
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/StringProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/StringProviderTests.java?rev=712819&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/StringProviderTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapbinding/tests/StringProviderTests.java Mon Nov 10 12:02:20 2008
@@ -0,0 +1,80 @@
+package org.apache.axis2.jaxws.provider.soapbinding.tests;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.axis2.jaxws.framework.AbstractTestCase;
+
+public class StringProviderTests extends AbstractTestCase {
+ private String endpointUrl = "http://localhost:7777/axis2/services/SOAPBindingStringProviderService.SOAPBindingStringProviderPort";
+ private QName serviceName = new QName("http://StringProvider.soapbinding.provider.jaxws.axis2.apache.org", "SOAPBindingStringProviderService");
+ private QName portName = new QName("http://StringProvider.soapbinding.provider.jaxws.axis2.apache.org", "SOAPBindingStringProviderPort");
+
+ private static final String SOAP11_NS_URI = "http://schemas.xmlsoap.org/soap/envelope/";
+ private static final String SOAP12_NS_URI = "http://www.w3.org/2003/05/soap-envelope";
+ public static final String SOAP11_ENVELOPE_HEAD = "<?xml version='1.0' encoding='utf-8'?>" +
+ "<soapenv:Envelope xmlns:soapenv=\"" + SOAP11_NS_URI + "\">" +
+ "<soapenv:Header />" +
+ "<soapenv:Body>";
+
+ public static final String SOAP12_ENVELOPE_HEAD =
+ "<?xml version='1.0' encoding='utf-8'?>" +
+ "<soapenv:Envelope xmlns:soapenv=\"" + SOAP12_NS_URI + "\">" +
+ "<soapenv:Header />" +
+ "<soapenv:Body>";
+
+ public static final String SOAP11_ENVELOPE_TAIL =
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public static final String SOAP12_ENVELOPE_TAIL =
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ public static Test suite() {
+ return getTestSetup(new TestSuite(StringProviderTests.class));
+ }
+/*
+ * This test case makes sure that we receive a soap11 response for a soap11 request.
+ */
+ public void testsoap11request(){
+ System.out.println("---------------------------------------");
+ System.out.println("test: " + getName());
+ try{
+ Service svc = Service.create(serviceName);
+ svc.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
+
+ Dispatch<String> dispatch =
+ svc.createDispatch(portName, String.class, Service.Mode.MESSAGE);
+ String xmlMessage = SOAP11_ENVELOPE_HEAD+"<invokeOp>soap11 request</invokeOp>"+SOAP11_ENVELOPE_TAIL;
+ String response = dispatch.invoke(xmlMessage);
+
+ MessageFactory factory = MessageFactory.newInstance();
+ SOAPMessage soapMessage = factory.createMessage(null, new ByteArrayInputStream(response.getBytes()));
+ assertTrue(getVersionURI(soapMessage).equals(SOAP11_NS_URI));
+ }catch(Exception e){
+ System.out.println("Failure while sending soap 11 request");
+ System.out.println(e.getMessage());
+ fail();
+ }
+
+ }
+
+ private String getVersionURI(SOAPMessage soapMessage)throws SOAPException{
+ SOAPPart sp = soapMessage.getSOAPPart();
+ SOAPEnvelope envelope = sp.getEnvelope();
+ return envelope.getNamespaceURI();
+ }
+}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Constants.java?rev=712819&r1=712818&r2=712819&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Constants.java Mon Nov 10 12:02:20 2008
@@ -63,4 +63,12 @@
*/
public static final String JAXWS_WEBMETHOD_EXCEPTION =
org.apache.axis2.Constants.JAXWS_WEBMETHOD_EXCEPTION;
+
+ /**
+ * This constant introduces an extension for @BindingType annotation.
+ * When the value of BindingType annotation is set to this constant,
+ * the javax.xml.ws.Provider java endpoints will cater to SOAP11 and SOAP12
+ * messages.
+ */
+ public static final String SOAP_HTTP_BINDING ="SOAP_HTTP_BINDING";
}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java?rev=712819&r1=712818&r2=712819&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java Mon Nov 10 12:02:20 2008
@@ -45,6 +45,7 @@
import org.apache.axis2.jaxws.message.factory.MessageFactory;
import org.apache.axis2.jaxws.registry.FactoryRegistry;
import org.apache.axis2.jaxws.server.dispatcher.EndpointDispatcher;
+import org.apache.axis2.jaxws.server.dispatcher.ProviderDispatcher;
import org.apache.axis2.jaxws.server.dispatcher.factory.EndpointDispatcherFactory;
import org.apache.axis2.jaxws.server.endpoint.Utils;
import org.apache.axis2.jaxws.spi.Constants;
@@ -212,16 +213,7 @@
Class serviceEndpoint = getServiceImplementation(request);
EndpointDescription endpointDesc = getEndpointDescription(request);
request.setEndpointDescription(endpointDesc);
-
- // Need to make sure the protocol (envelope ns) of the request matches the binding
- // expected by the service description
- if (!Utils.bindingTypesMatch(request, endpointDesc)) {
- Protocol protocol = request.getMessage().getProtocol();
- MessageContext faultContext = Utils.createVersionMismatchMessage(request, protocol);
- eic.setResponseMessageContext(faultContext);
- return false;
- }
-
+
// TODO: review: make sure the handlers are set on the InvocationContext
// This implementation of the JAXWS runtime does not use Endpoint, which
// would normally be the place to initialize and store the handler list.
@@ -269,6 +261,31 @@
}
// Set the dispatcher.
EndpointDispatcher dispatcher = getEndpointDispatcher(request, serviceEndpoint, serviceInstance);
+ Boolean ignoreSOAPVersion = false;
+ if(log.isDebugEnabled()){
+ log.debug("Checking for ProviderDispatcher instance");
+ }
+ if(dispatcher instanceof ProviderDispatcher){
+ if(log.isDebugEnabled()){
+ log.debug("ProviderDispatcher instance Found");
+ }
+ String bindingType = endpointDesc.getBindingType();
+ if(bindingType.equals(org.apache.axis2.jaxws.Constants.SOAP_HTTP_BINDING)){
+ ignoreSOAPVersion = true;
+ }
+ if(log.isDebugEnabled()){
+ log.debug("ignoreSOAPVersion Value ="+ignoreSOAPVersion.booleanValue());
+ }
+ }
+ //Need to make sure the protocol (envelope ns) of the request matches the binding
+ // expected by the service description
+ if (!ignoreSOAPVersion && !Utils.bindingTypesMatch(request, endpointDesc)) {
+ Protocol protocol = request.getMessage().getProtocol();
+ MessageContext faultContext = Utils.createVersionMismatchMessage(request, protocol);
+ eic.setResponseMessageContext(faultContext);
+ return false;
+ }
+
eic.setEndpointDispatcher(dispatcher);
return true;
} else { // the inbound handler chain must have had a problem, and we've reversed directions
@@ -335,6 +352,25 @@
try {
if (response != null) {
+ //Before running inbound handlers lets make sure that the request and response have no protocol mismatch.
+ EndpointDescription endpointDesc =request.getEndpointDescription();
+ String bindingType = endpointDesc.getBindingType();
+ if(bindingType.equals(org.apache.axis2.jaxws.Constants.SOAP_HTTP_BINDING)){
+ if(log.isDebugEnabled()){
+ log.debug("Check for protocol mismatch");
+ }
+ MessageContext faultContext = isProtocolMismatch(request, response);
+ if(faultContext!=null){
+ if(log.isDebugEnabled()){
+ log.debug("There is a protocol mismatch, generating fault message");
+ }
+ eic.setResponseMessageContext(faultContext);
+ return false;
+ }
+ if(log.isDebugEnabled()){
+ log.debug("There is no protocol mismatch");
+ }
+ }
// Invoke the outbound response handlers.
// If the message is one way, we should not invoke the response handlers. There is no response
// MessageContext since a one way invocation is considered to have a "void" return.
@@ -648,4 +684,28 @@
return elmf.createHandlerLifecycleManager();
}
+ private MessageContext isProtocolMismatch(MessageContext request, MessageContext response){
+ Protocol requestProtocol =request.getMessage().getProtocol();
+ Protocol responseProtocol = response.getMessage().getProtocol();
+ boolean protocolMismatch = false;
+ String msg = null;
+ if(requestProtocol.equals(Protocol.soap11)){
+ if(!responseProtocol.equals(Protocol.soap11)){
+ protocolMismatch = true;
+ msg = "Request SOAP message protocol is version 1.1, but Response SOAP message is configured for SOAP 1.2. This is not supported.";
+ }
+ }
+ else if(requestProtocol.equals(Protocol.soap12)){
+ if(!responseProtocol.equals(Protocol.soap12)){
+ protocolMismatch = true;
+ msg = "Request SOAP message protocol is version 1.2, but Response SOAP message is configured for SOAP 1.1. This is not supported.";
+ }
+ }
+ MessageContext msgContext = null;
+ if(protocolMismatch){
+ msgContext = Utils.createFaultMessage(response, msg);
+ }
+ return msgContext;
+ }
+
}
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=712819&r1=712818&r2=712819&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 Nov 10 12:02:20 2008
@@ -65,5 +65,5 @@
public static final String SOAP12JMS_BINDING = "http://www.example.org/2006/06/soap/bindings/JMS/";
public static final String SOAP11JMS_MTOM_BINDING = "http://http://www.example.org/2006/06/soap/bindings/JMS/?mtom=true";
public static final String SOAP12JMS_MTOM_BINDING = "http://http://www.example.org/2006/06/soap/bindings/JMS/?mtom=true";
-
+ public static final String SOAP_HTTP_BINDING ="SOAP_HTTP_BINDING";
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?rev=712819&r1=712818&r2=712819&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java Mon Nov 10 12:02:20 2008
@@ -656,7 +656,8 @@
String bindingType = getBindingType();
if (javax.xml.ws.http.HTTPBinding.HTTP_BINDING.equals(bindingType)||
SOAPBinding.SOAP11HTTP_BINDING.equals(bindingType)||
- SOAPBinding.SOAP12HTTP_BINDING.equals(bindingType)) {
+ SOAPBinding.SOAP12HTTP_BINDING.equals(bindingType)||
+ MDQConstants.SOAP_HTTP_BINDING.equals(bindingType)) {
endpointInterfaceDescription = new EndpointInterfaceDescriptionImpl(composite, this);
}
}
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=712819&r1=712818&r2=712819&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 Nov 10 12:02:20 2008
@@ -1611,7 +1611,9 @@
&& !bindingType
.equals(MDQConstants.SOAP12JMS_BINDING)
&& !bindingType
- .equals(MDQConstants.SOAP12JMS_MTOM_BINDING))
+ .equals(MDQConstants.SOAP12JMS_MTOM_BINDING)
+ && !bindingType
+ .equals(MDQConstants.SOAP_HTTP_BINDING))
throw ExceptionFactory.makeWebServiceException(Messages
.getMessage("validatePIsErr2", composite
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java?rev=712819&r1=712818&r2=712819&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java Mon Nov 10 12:02:20 2008
@@ -111,12 +111,19 @@
!MDQConstants.SOAP11JMS_MTOM_BINDING.equals(bindingType) &&
!MDQConstants.SOAP12JMS_BINDING.equals(bindingType) &&
!MDQConstants.SOAP12JMS_MTOM_BINDING.equals(bindingType) &&
- !HTTPBinding.HTTP_BINDING.equals(bindingType)) {
+ !HTTPBinding.HTTP_BINDING.equals(bindingType) &&
+ !MDQConstants.SOAP_HTTP_BINDING.equals(bindingType)) {
addValidationFailure(this,
"Invalid annotation binding value specified: " + bindingType);
isBindingValid = false;
}
+ else if(bindingType.equals(MDQConstants.SOAP_HTTP_BINDING) && endpointDesc.isEndpointBased()){
+ addValidationFailure(this,
+ "A SOAP_HTTP_BINDING was found on a @Bindingtype SEI based Endpoint." +
+ " SOAP_HTTP_BINDING is supported on Provider Endpoints only.");
+ isBindingValid = false;
+ }
// If there's no WSDL, then there will be no WSDL Binding Type to validate against
else if (wsdlBindingType == null) {
isBindingValid = true;
@@ -150,7 +157,14 @@
"This is not supported. " +
"An HTTPBinding must use an @WebServiceProvider endpoint.");
isBindingValid = false;
- } else {
+ }
+ // If wsdl binding is not HTTP binding and BindingType annotation is SOAP_HTTP_BINDING then
+ // wsdl is valid and JAX-WS needs to support both soap 11 and soap 12 on Provider endpoints.
+ else if(!wsdlBindingType.equals(HTTPBinding.HTTP_BINDING)
+ && bindingType.equals(MDQConstants.SOAP_HTTP_BINDING) && endpointDesc.isProviderBased()){
+ isBindingValid = true;
+ }
+ else {
// Mismatched bindings
String wsdlInsert = "[" + bindingHumanReadableDescription(wsdlBindingType) + "]" +