Author: alessio.soldano(a)jboss.com
Date: 2009-01-09 08:36:38 -0500 (Fri, 09 Jan 2009)
New Revision: 9004
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/Constants.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/wsdl/WSDLGenerator.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/wsdl/WSDLWriter.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPEndpoint.java
Log:
[JBPAPP-1449] Porting JBWS-1761 fix to EAP branch: wsprovide ignores SOAPBinding
declaration
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/Constants.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/Constants.java 2009-01-09
10:45:25 UTC (rev 9003)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/Constants.java 2009-01-09
13:36:38 UTC (rev 9004)
@@ -90,6 +90,8 @@
static final String URI_SOAP11_ENC = SOAPConstants.URI_NS_SOAP_ENCODING;
/** SOAP-1.2 encoding URI */
static final String URI_SOAP12_ENC = SOAPConstants.URI_NS_SOAP_1_2_ENCODING;
+ /** SOAP HTTP transport URI in wsdl soap binding */
+ static final String URI_SOAP_HTTP = "http://schemas.xmlsoap.org/soap/http";
/** Literal encoding URI */
static final String URI_LITERAL_ENC = "";
/** WSDL 2.0 Encoding Rules */
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java 2009-01-09
10:45:25 UTC (rev 9003)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java 2009-01-09
13:36:38 UTC (rev 9004)
@@ -468,7 +468,12 @@
if (wsdlStyle.equals(Constants.DOCUMENT_LITERAL))
style = "document";
appendUnknownExtensibilityElements(buffer, binding);
- buffer.append("<" + soapPrefix + ":binding
transport='http://schemas.xmlsoap.org/soap/http' style='" + style +
"'/>");
+
+ // The value of the REQUIRED transport attribute (of type xs:anyURI) indicates
which transport of SOAP this binding corresponds to.
+ // The URI value "http://schemas.xmlsoap.org/soap/http" corresponds to
the HTTP binding.
+ // Other URIs may be used here to indicate other transports (such as SMTP, FTP,
etc.).
+
+ buffer.append("<" + soapPrefix + ":binding
transport='" + Constants.URI_SOAP_HTTP + "' style='" + style +
"'/>");
appendBindingOperations(buffer, binding);
buffer.append("</binding>");
}
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/wsdl/WSDLGenerator.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/wsdl/WSDLGenerator.java 2009-01-09
10:45:25 UTC (rev 9003)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/wsdl/WSDLGenerator.java 2009-01-09
13:36:38 UTC (rev 9004)
@@ -27,6 +27,7 @@
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
+import javax.xml.ws.soap.SOAPBinding;
import org.apache.ws.policy.Policy;
import org.apache.ws.policy.util.PolicyFactory;
@@ -104,6 +105,7 @@
QName bindingQName = new QName(interfaceQName.getNamespaceURI(),
interfaceQName.getLocalPart() + "Binding");
WSDLBinding wsdlBinding = new WSDLBinding(wsdl, bindingQName);
wsdlBinding.setInterfaceName(interfaceQName);
+ wsdlBinding.setType(endpoint.getBindingId());
wsdl.addBinding(wsdlBinding);
wsdlEndpoint.setBinding(bindingQName);
@@ -424,9 +426,28 @@
String ns = service.getServiceName().getNamespaceURI();
wsdl.setTargetNamespace(ns);
wsdl.registerNamespaceURI(ns, "tns");
- wsdl.registerNamespaceURI(Constants.NS_SOAP11, "soap");
wsdl.registerNamespaceURI(Constants.NS_SCHEMA_XSD, "xsd");
+ String soapURI = null;
+ String soapPrefix = null;
+ for (EndpointMetaData ep : service.getEndpoints())
+ {
+ String bindingId = ep.getBindingId();
+ if (bindingId.startsWith(SOAPBinding.SOAP11HTTP_BINDING))
+ {
+ soapPrefix = "soap";
+ soapURI = Constants.NS_SOAP11;
+ }
+ else if (bindingId.startsWith(SOAPBinding.SOAP12HTTP_BINDING))
+ {
+ soapPrefix = "soap12";
+ soapURI = Constants.NS_SOAP12;
+ }
+ }
+
+ if (soapURI != null && soapPrefix != null)
+ wsdl.registerNamespaceURI(soapURI, soapPrefix);
+
processTypes();
processService(service);
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/wsdl/WSDLWriter.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/wsdl/WSDLWriter.java 2009-01-09
10:45:25 UTC (rev 9003)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/wsdl/WSDLWriter.java 2009-01-09
13:36:38 UTC (rev 9004)
@@ -66,7 +66,6 @@
*/
protected boolean includeSchemaInWSDL = true;
- /** Use WSDLDefinitions.writeWSDL instead. */
public WSDLWriter(WSDLDefinitions wsdl)
{
if (wsdl == null)
@@ -133,7 +132,7 @@
if (prefix.length() > 0)
{
buffer.append(" xmlns:" + prefix + "='" +
namespaceURI + "'");
- if (Constants.PREFIX_SOAP11.equals(prefix))
+ if (prefix.startsWith("soap"))
soapPrefix = prefix;
}
}
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java 2009-01-09
10:45:25 UTC (rev 9003)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java 2009-01-09
13:36:38 UTC (rev 9004)
@@ -27,6 +27,11 @@
import java.util.ArrayList;
import java.util.List;
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.wsdl.extensions.soap12.SOAP12Binding;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
@@ -35,6 +40,8 @@
import junit.framework.Test;
import org.jboss.ws.Constants;
+import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
+import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestSetup;
@@ -46,14 +53,47 @@
*/
public class SOAPBindingTestCase extends JBossWSTest
{
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-binding";
+
public static Test suite()
{
return new JBossWSTestSetup(SOAPBindingTestCase.class,
"jaxws-binding.war");
}
+
+ // [JBWS-1761] - WSProvide ignores SOAPBinding declaration
+ public void testWSDLAccess() throws Exception
+ {
+ URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
+ //Element root = DOMUtils.parse(wsdlURL.openStream());
+ //System.out.println(DOMWriter.printNode(root, true));
+ WSDLDefinitions defs = WSDLDefinitionsFactory.newInstance().parse(wsdlURL);
+ Definition wsdl = defs.getWsdlOneOneDefinition();
+
+ QName qname = new QName("http://org.jboss.ws/jaxws/binding",
"SOAPEndpointBinding");
+ Binding wsdlBinding = wsdl.getBinding(qname);
+ assertNotNull("Cannot find: " + qname, wsdlBinding);
+
+ String transport = null;
+ List<ExtensibilityElement> extList = wsdlBinding.getExtensibilityElements();
+ for (ExtensibilityElement ext : extList)
+ {
+ if (ext instanceof SOAPBinding)
+ {
+ fail("Expected SOAP-1.2 binding");
+ }
+ else if (ext instanceof SOAP12Binding)
+ {
+ SOAP12Binding soapBinding = (SOAP12Binding)ext;
+ transport = soapBinding.getTransportURI();
+ }
+ }
+ assertEquals("Invalid transport uri", Constants.URI_SOAP_HTTP,
transport);
+ }
+
public void testClientAccess() throws Exception
{
- URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-binding?wsdl");
+ URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
QName qname = new QName("http://org.jboss.ws/jaxws/binding",
"SOAPEndpointBeanService");
Service service = Service.create(wsdlURL, qname);
SOAPEndpoint port = (SOAPEndpoint)service.getPort(SOAPEndpoint.class);
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPEndpoint.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPEndpoint.java 2009-01-09
10:45:25 UTC (rev 9003)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPEndpoint.java 2009-01-09
13:36:38 UTC (rev 9004)
@@ -28,11 +28,12 @@
import javax.jws.soap.SOAPBinding.Style;
import javax.xml.ws.BindingType;
+import static javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING;
+
@WebService(name = "SOAPEndpoint", targetNamespace =
"http://org.jboss.ws/jaxws/binding")
@SOAPBinding(style = Style.RPC)
-// This is the SOAP-1.2 binding identifier
-@BindingType(value = "http://www.w3.org/2003/05/soap/bindings/HTTP/")
+@BindingType(SOAP12HTTP_BINDING)
public interface SOAPEndpoint
{
public String namespace();