[jboss-svn-commits] JBL Code SVN: r25122 - in labs/jbossesb/trunk/product/rosetta: tests/src/org/jboss/internal/soa/esb/webservice and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Feb 5 12:01:02 EST 2009
Author: kevin.conner at jboss.com
Date: 2009-02-05 12:01:02 -0500 (Thu, 05 Feb 2009)
New Revision: 25122
Added:
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_09.110.expected.wsdl
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_09.110.xml
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java
Log:
Add WS-A to the WSDL: JBESB-2026
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java 2009-02-05 16:13:20 UTC (rev 25121)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java 2009-02-05 17:01:02 UTC (rev 25122)
@@ -19,6 +19,7 @@
*/
package org.jboss.internal.soa.esb.webservice;
+import java.io.PrintWriter;
import java.io.StringWriter;
import java.security.AccessController;
import java.security.PrivilegedActionException;
@@ -43,6 +44,9 @@
import javax.wsdl.PortType;
import javax.wsdl.Types;
import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.extensions.ExtensionSerializer;
import javax.wsdl.extensions.soap.SOAPOperation;
import javax.wsdl.factory.WSDLFactory;
import javax.xml.namespace.QName;
@@ -66,6 +70,12 @@
public class ESBContractGenerator {
private static final QName XSD_QN = new QName("http://www.w3.org/2001/XMLSchema", "schema");
+ private static final String WSDL_NAMESPACE = "http://schemas.xmlsoap.org/wsdl/" ;
+ private static final String WSDL_REQUIRED = "required" ;
+ private static final String WSAW_NAMESPACE = "http://www.w3.org/2006/05/addressing/wsdl" ;
+ private static final String WSAW_PREFIX = "wsaw" ;
+ private static final QName WSAW_ACTION_QN = new QName(WSAW_NAMESPACE, "Action", WSAW_PREFIX) ;
+ private static final QName WSAW_USING_ADDRESSING_QN = new QName(WSAW_NAMESPACE, "UsingAddressing", WSAW_PREFIX) ;
private static WSDLFactory wsdlFactory ;
public static String generateWSDL(final WebserviceInfo serviceConfig, final ESBServiceEndpointInfo serviceInfo)
@@ -75,6 +85,11 @@
def.setTargetNamespace(namespace);
def.addNamespace("tns", namespace);
def.addNamespace("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
+
+ if (serviceInfo.isAddressing()) {
+ def.getExtensionRegistry().registerSerializer(Binding.class, WSAW_USING_ADDRESSING_QN, new UsingAddressingSerializer()) ;
+ def.addNamespace(WSAW_PREFIX, WSAW_NAMESPACE) ;
+ }
// add types
Types types = def.createTypes();
def.setTypes(types);
@@ -218,12 +233,18 @@
Input in = def.createInput();
in.setMessage(inMessage);
in.setName(inMessage.getQName().getLocalPart());
+ if (serviceInfo.isAddressing()) {
+ in.setExtensionAttribute(WSAW_ACTION_QN, serviceInfo.getRequestAction()) ;
+ }
op.setInput(in);
}
if (outMessage != null) {
Output out = def.createOutput();
out.setMessage(outMessage);
out.setName(outMessage.getQName().getLocalPart());
+ if (serviceInfo.isAddressing()) {
+ out.setExtensionAttribute(WSAW_ACTION_QN, serviceInfo.getResponseAction()) ;
+ }
op.setOutput(out);
}
@@ -252,6 +273,9 @@
soapBinding.setStyle("document");
soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
binding.addExtensibilityElement(soapBinding);
+ if (serviceInfo.isAddressing()) {
+ binding.addExtensibilityElement(new UsingAddressingExtension()) ;
+ }
BindingOperation bop = def.createBindingOperation();
@@ -334,4 +358,38 @@
}
return wsdlFactory ;
}
+
+ private static class UsingAddressingExtension implements ExtensibilityElement {
+ public QName getElementType() {
+ return WSAW_USING_ADDRESSING_QN ;
+ }
+
+ public Boolean getRequired() {
+ return Boolean.TRUE ;
+ }
+
+ public void setElementType(final QName qname) {
+ }
+
+ public void setRequired(final Boolean required) {
+ }
+ }
+
+ private static class UsingAddressingSerializer implements ExtensionSerializer
+ {
+ public void marshall(final Class parentType, final QName elementType,
+ final ExtensibilityElement extension, final PrintWriter pw,
+ final Definition definition, final ExtensionRegistry registry)
+ throws WSDLException {
+ if (extension != null) {
+ final String prefix = definition.getPrefix(elementType.getNamespaceURI()) ;
+ pw.print(" <"+prefix+":"+elementType.getLocalPart()) ;
+ if (extension.getRequired().booleanValue()) {
+ final String wsdlPrefix = definition.getPrefix(WSDL_NAMESPACE) ;
+ pw.print(" " + wsdlPrefix + ":" + WSDL_REQUIRED + "=\"true\"") ;
+ }
+ pw.println("/>") ;
+ }
+ }
+ }
}
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java 2009-02-05 16:13:20 UTC (rev 25121)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/ESBContractGeneratorUnitTest.java 2009-02-05 17:01:02 UTC (rev 25122)
@@ -34,6 +34,7 @@
import org.jboss.soa.esb.listeners.config.Generator;
import org.jboss.soa.esb.listeners.config.WebserviceInfo;
import org.jboss.soa.esb.util.ClassUtil;
+import org.jboss.soa.esb.testutils.StringUtils;
import org.xml.sax.InputSource;
public class ESBContractGeneratorUnitTest extends TestCase {
@@ -60,8 +61,15 @@
public void testRequest110() throws Exception {
executeTest("jbossesb_config_08.110.xml") ;
}
-
- private void executeTest(final String resourceName) throws Exception {
+
+ public void testWSAExtensions110() throws Exception {
+ String expectedWsdl = StreamUtils.readStreamString(getClass().getResourceAsStream("jbossesb_config_09.110.expected.wsdl"), "UTF-8");
+ String actualWsdl = executeTest("jbossesb_config_09.110.xml") ;
+
+ assertTrue("WSDL not as expected.", StringUtils.compareXMLContent(expectedWsdl, actualWsdl));
+ }
+
+ private String executeTest(final String resourceName) throws Exception {
final InputStream is = ClassUtil.getResourceAsStream(resourceName, getClass()) ;
final byte[] configBytes = StreamUtils.readStream(is) ;
ByteArrayOutputStream listenerXml = new ByteArrayOutputStream();
@@ -76,6 +84,8 @@
InputSource inputSource = new InputSource(strReader);
Definition def = WSDLFactory.newInstance().newWSDLReader().readWSDL("file://tmp.wsdl", inputSource);
assertNotNull("Failed to generate wsdl file" , def);
- }
+ return wsdl;
+ }
+
}
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_09.110.expected.wsdl
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_09.110.expected.wsdl (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_09.110.expected.wsdl 2009-02-05 17:01:02 UTC (rev 25122)
@@ -0,0 +1,98 @@
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://www.jboss.org/sayHi"
+ xmlns:ns2="http://www.jboss.org/sayHi" xmlns:ns3="http://www.jboss.org/sayHi"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://soa.jboss.org/FirstServiceESB"
+ targetNamespace="http://soa.jboss.org/FirstServiceESB">
+ <wsdl:types>
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x1="http://www.jboss.org/sayHi"
+ elementFormDefault="qualified" targetNamespace="http://www.jboss.org/sayHi" version="1.0">
+ <xs:element name="sayHi" type="x1:sayHi"/>
+ <xs:complexType name="sayHi">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x1="http://www.jboss.org/sayHi"
+ elementFormDefault="qualified" targetNamespace="http://www.jboss.org/sayHi" version="1.0">
+ <xs:element name="sayHiReponse" type="x1:sayHiReponse"/>
+ <xs:complexType name="sayHiReponse">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x1="http://www.jboss.org/sayHi"
+ elementFormDefault="qualified" targetNamespace="http://www.jboss.org/sayHi" version="1.0">
+ <xs:element name="sayFault" type="x1:fault"/>
+ <xs:complexType name="fault">
+ <xs:sequence>
+ <xs:element name="code" type="xs:string"/>
+ <xs:element name="faultString" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="sayFault2" type="x1:fault2"/>
+ <xs:complexType name="fault2">
+ <xs:sequence>
+ <xs:element name="code" type="xs:int"/>
+ <xs:element name="descrption" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ </xs:schema>
+ </wsdl:types>
+ <wsdl:message name="SimpleListenerFault2">
+ <wsdl:part element="ns1:sayFault" name="fault2">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="SimpleListenerFault1">
+ <wsdl:part element="ns1:sayFault" name="fault1">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="SimpleListenerReq">
+ <wsdl:part element="ns1:sayHi" name="in">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="SimpleListenerRes">
+ <wsdl:part element="ns1:sayHiReponse" name="out">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="SimpleListenerPortType">
+ <wsdl:operation name="SimpleListenerOp">
+ <wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" message="tns:SimpleListenerReq"
+ name="SimpleListenerReq" wsaw:Action="http://soa.jboss.org/FirstServiceESB/SimpleListenerOp">
+ </wsdl:input>
+ <wsdl:output xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" message="tns:SimpleListenerRes"
+ name="SimpleListenerRes"
+ wsaw:Action="http://soa.jboss.org/FirstServiceESB/SimpleListenerOpResp">
+ </wsdl:output>
+ <wsdl:fault message="tns:SimpleListenerFault1" name="fault1">
+ </wsdl:fault>
+ <wsdl:fault message="tns:SimpleListenerFault2" name="fault2">
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="SimpleListenerBinding" type="tns:SimpleListenerPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsdl:required="true"/>
+ <wsdl:operation name="SimpleListenerOp">
+ <soap:operation soapAction="http://soa.jboss.org/FirstServiceESB/SimpleListenerOpResp"/>
+ <wsdl:input name="SimpleListenerReq">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="SimpleListenerRes">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ <wsdl:fault name="fault1">
+ <soap:fault name="fault1" use="literal"/>
+ </wsdl:fault>
+ <wsdl:fault name="fault2">
+ <soap:fault name="fault2" use="literal"/>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="SimpleListenerService">
+ <wsdl:port binding="tns:SimpleListenerBinding" name="SimpleListenerPortType">
+ <soap:address location="http://change_this_URI//FirstServiceESB/SimpleListener"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_09.110.expected.wsdl
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_09.110.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_09.110.xml (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_09.110.xml 2009-02-05 17:01:02 UTC (rev 25122)
@@ -0,0 +1,19 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb
+ xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.1.0.xsd">
+ <services>
+ <service category="FirstServiceESB" name="SimpleListener"
+ description="Hello World" invmScope="GLOBAL">
+ <actions
+ inXsd="/org/jboss/internal/soa/esb/webservice/request.xsd"
+ outXsd="/org/jboss/internal/soa/esb/webservice/response.xsd"
+ faultXsd="/org/jboss/internal/soa/esb/webservice/fault.xsd"
+ addressing="true">
+ <action name="action2"
+ class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="printfull" value="true" />
+ </action>
+ </actions>
+ </service>
+ </services>
+</jbossesb>
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/jbossesb_config_09.110.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
More information about the jboss-svn-commits
mailing list