Author: thomas.diesler(a)jboss.com
Date: 2007-10-10 12:10:19 -0400 (Wed, 10 Oct 2007)
New Revision: 4730
Added:
stack/native/trunk/.settings/
stack/native/trunk/.settings/org.eclipse.core.resources.prefs
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java
stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDLGenerator.java
stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDLWriter.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPEndpoint.java
Log:
[JBWS-1761] WSProvide ignores SOAPBinding declaration
Added: stack/native/trunk/.settings/org.eclipse.core.resources.prefs
===================================================================
--- stack/native/trunk/.settings/org.eclipse.core.resources.prefs
(rev 0)
+++ stack/native/trunk/.settings/org.eclipse.core.resources.prefs 2007-10-10 16:10:19 UTC
(rev 4730)
@@ -0,0 +1,3 @@
+#Wed Oct 10 17:09:48 CEST 2007
+eclipse.preferences.version=1
+encoding//src/test/resources/jaxws/jbws1807/WEB-INF/wsdl/provider.wsdl=UTF-8
Modified: stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java 2007-10-10
15:32:16 UTC (rev 4729)
+++ stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java 2007-10-10
16:10:19 UTC (rev 4730)
@@ -468,7 +468,7 @@
if (wsdlStyle.equals(Constants.DOCUMENT_LITERAL))
style = "document";
appendUnknownExtensibilityElements(buffer, binding);
- buffer.append("<" + soapPrefix + ":binding
transport='http://schemas.xmlsoap.org/soap/http' style='" + style +
"'/>");
+ buffer.append("<" + soapPrefix + ":binding
transport='" + binding.getType() + "' style='" + style +
"'/>");
appendBindingOperations(buffer, binding);
buffer.append("</binding>");
}
Modified: stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDLGenerator.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDLGenerator.java 2007-10-10
15:32:16 UTC (rev 4729)
+++ stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDLGenerator.java 2007-10-10
16:10:19 UTC (rev 4730)
@@ -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/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDLWriter.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDLWriter.java 2007-10-10
15:32:16 UTC (rev 4729)
+++ stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDLWriter.java 2007-10-10
16:10:19 UTC (rev 4730)
@@ -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/trunk/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java 2007-10-10
15:32:16 UTC (rev 4729)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPBindingTestCase.java 2007-10-10
16:10:19 UTC (rev 4730)
@@ -23,10 +23,17 @@
// $Id: $
+import static javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING;
+
import java.net.URL;
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,8 +42,15 @@
import junit.framework.Test;
import org.jboss.ws.Constants;
+import org.jboss.ws.metadata.wsdl.WSDLBinding;
+import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
+import org.jboss.ws.metadata.wsdl.WSDLExtensibilityElement;
+import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory;
+import org.jboss.wsf.common.DOMUtils;
+import org.jboss.wsf.common.DOMWriter;
import org.jboss.wsf.test.JBossWSTest;
import org.jboss.wsf.test.JBossWSTestSetup;
+import org.w3c.dom.Element;
/**
* Test SOAP12 binding type
@@ -46,26 +60,59 @@
*/
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", SOAP12HTTP_BINDING, 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);
-
+
BindingProvider provider = (BindingProvider)port;
- List<Handler> handlerChain = new ArrayList<Handler>();
+ List<Handler> handlerChain = new ArrayList<Handler>();
handlerChain.addAll(provider.getBinding().getHandlerChain());
handlerChain.add(new ClientHandler());
provider.getBinding().setHandlerChain(handlerChain);
-
+
String nsURI = port.namespace();
assertEquals(Constants.NS_SOAP12_ENV + ":" + Constants.NS_SOAP12_ENV,
nsURI);
}
-
+
}
Modified:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPEndpoint.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPEndpoint.java 2007-10-10
15:32:16 UTC (rev 4729)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/binding/SOAPEndpoint.java 2007-10-10
16:10:19 UTC (rev 4730)
@@ -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();