Author: mmao
Date: Thu May 24 00:52:56 2007
New Revision: 541220
URL: http://svn.apache.org/viewvc?view=rev&rev=541220
Log:
CXF-669
* Fixed when SEI's and IMPLS have different namespaces, generate two wsdls,
one for logical wsdl, and another for physical wsdl
* TODO: The types namespace still not correct
* Fixed test in aegis databinding due to this change
* Clean up dependencies in common/common
Added:
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/Hello.java
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/HelloImpl.java
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/SayHi.java
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/SayHiResponse.java
Modified:
incubator/cxf/trunk/common/common/pom.xml
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/OperationNSTest.java
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
Modified: incubator/cxf/trunk/common/common/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/pom.xml?view=diff&rev=541220&r1=541219&r2=541220
==============================================================================
--- incubator/cxf/trunk/common/common/pom.xml (original)
+++ incubator/cxf/trunk/common/common/pom.xml Thu May 24 00:52:56 2007
@@ -81,11 +81,6 @@
<artifactId>jaxb-impl</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-xjc</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java?view=diff&rev=541220&r1=541219&r2=541220
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/AbstractCXFTest.java
Thu May 24 00:52:56 2007
@@ -192,6 +192,10 @@
namespaces.put(ns, uri);
}
+ public Map<String, String> getNamespaces() {
+ return namespaces;
+ }
+
protected InputStream getResourceAsStream(String resource) {
return getClass().getResourceAsStream(resource);
}
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java?view=diff&rev=541220&r1=541219&r2=541220
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
Thu May 24 00:52:56 2007
@@ -22,9 +22,9 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
-
import javax.wsdl.Binding;
import javax.wsdl.BindingFault;
import javax.wsdl.BindingInput;
@@ -32,6 +32,7 @@
import javax.wsdl.BindingOutput;
import javax.wsdl.Definition;
import javax.wsdl.Fault;
+import javax.wsdl.Import;
import javax.wsdl.Input;
import javax.wsdl.Message;
import javax.wsdl.Operation;
@@ -52,7 +53,6 @@
import org.w3c.dom.Element;
import com.ibm.wsdl.extensions.schema.SchemaImpl;
-
import org.apache.cxf.Bus;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.XMLUtils;
@@ -74,13 +74,13 @@
public final class ServiceWSDLBuilder {
- private Map<String, String> ns2prefix;
+ private final Map<String, String> ns2prefix;
private Definition definition;
- private List<ServiceInfo> services;
+ private final List<ServiceInfo> services;
private boolean useSchemaImports;
private String baseFileName;
private int xsdCount;
- private Bus bus;
+ private final Bus bus;
public ServiceWSDLBuilder(Bus b, List<ServiceInfo> services) {
this.services = services;
@@ -108,27 +108,52 @@
//ignore
}
if (definition == null) {
- definition =
bus.getExtension(WSDLManager.class).getWSDLFactory().newDefinition();
-
definition.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtenstionRegistry());
-
- addNamespace(WSDLConstants.NP_SCHEMA_XSD,
WSDLConstants.NU_SCHEMA_XSD);
-
ServiceInfo si = services.get(0);
- definition.setQName(si.getName());
- definition.setTargetNamespace(si.getTargetNamespace());
+ definition = newDefinition(si.getName(), si.getTargetNamespace());
addExtensibiltyElements(definition, getWSDL11Extensors(si));
- if (si.getSchemas() != null && si.getSchemas().size() > 0) {
- buildTypes(si.getSchemas(), imports);
+
+ Collection<PortType> portTypes = new HashSet<PortType>();
+ for (ServiceInfo service : services) {
+ Definition portTypeDef = definition;
+ if (!isSameTNS(service)) {
+ portTypeDef =
newDefinition(service.getInterface().getName(),
+ service.getTargetNamespace());
+ Import wsdlImport = definition.createImport();
+ String tns =
service.getInterface().getName().getNamespaceURI();
+ wsdlImport.setDefinition(portTypeDef);
+ wsdlImport.setNamespaceURI(tns);
+
wsdlImport.setLocationURI(service.getInterface().getName().getLocalPart() +
".wsdl");
+ definition.addImport(wsdlImport);
+ addNamespace(tns);
+ }
+ portTypes.add(buildPortType(service.getInterface(),
portTypeDef));
+
+ if (service.getSchemas() != null &&
service.getSchemas().size() > 0) {
+ buildTypes(service.getSchemas(), imports, portTypeDef);
+ }
}
+
for (ServiceInfo service : services) {
- buildPortType(service.getInterface());
- buildBinding(service.getBindings());
+ buildBinding(service.getBindings(), portTypes);
buildService(service);
}
}
return definition;
}
+ private boolean isSameTNS(final ServiceInfo service) {
+ return
service.getName().getNamespaceURI().equals(service.getInterface().getName().getNamespaceURI());
+ }
+
+ private Definition newDefinition(final QName name, String targetNamespace)
{
+ Definition d =
bus.getExtension(WSDLManager.class).getWSDLFactory().newDefinition();
+
d.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtenstionRegistry());
+ d.setQName(name);
+ d.setTargetNamespace(targetNamespace);
+ addNamespace(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NU_SCHEMA_XSD,
d);
+ return d;
+ }
+
public List<ExtensibilityElement>
getWSDL11Extensors(AbstractPropertiesHolder holder) {
return holder.getExtensors(ExtensibilityElement.class);
@@ -145,8 +170,10 @@
}
}
- protected void buildTypes(Collection<SchemaInfo> schemas, Map<String,
SchemaInfo> imports) {
- Types types = definition.createTypes();
+ protected void buildTypes(final Collection<SchemaInfo> schemas,
+ final Map<String, SchemaInfo> imports,
+ final Definition def) {
+ Types types = def.createTypes();
Document doc = null;
try {
@@ -186,16 +213,15 @@
schemaImpl.setElement(nd);
types.addExtensibilityElement(schemaImpl);
}
- definition.setTypes(types);
+ def.setTypes(types);
}
- protected void buildBinding(Collection<BindingInfo> bindingInfos) {
+ protected void buildBinding(Collection<BindingInfo> bindingInfos,
Collection<PortType> portTypes) {
Binding binding = null;
for (BindingInfo bindingInfo : bindingInfos) {
binding = definition.createBinding();
binding.setUndefined(false);
- for (PortType portType
- : CastUtils.cast(definition.getPortTypes().values(),
PortType.class)) {
+ for (PortType portType : portTypes) {
if
(portType.getQName().equals(bindingInfo.getInterface().getName())) {
binding.setPortType(portType);
break;
@@ -272,7 +298,6 @@
for (EndpointInfo ei : serviceInfo.getEndpoints()) {
addNamespace(ei.getTransportId());
- //addNamespace(ei.getBinding().getBindingId());
Port port = definition.createPort();
port.setName(ei.getName().getLocalPart());
port.setBinding(definition.getBinding(ei.getBinding().getName()));
@@ -281,7 +306,7 @@
}
}
- protected void buildPortType(InterfaceInfo intf) {
+ protected PortType buildPortType(InterfaceInfo intf, final Definition def)
{
PortType portType = null;
try {
portType = intf.getProperty(WSDLServiceBuilder.WSDL_PORTTYPE,
PortType.class);
@@ -290,14 +315,19 @@
}
if (portType == null) {
- portType = definition.createPortType();
+ portType = def.createPortType();
portType.setQName(intf.getName());
- addNamespace(intf.getName().getNamespaceURI());
+ addNamespace(intf.getName().getNamespaceURI(), def);
portType.setUndefined(false);
- buildPortTypeOperation(portType, intf.getOperations());
+ buildPortTypeOperation(portType, intf.getOperations(), def);
}
- definition.addPortType(portType);
+ def.addPortType(portType);
+ return portType;
+ }
+
+ protected void addNamespace(String namespaceURI, Definition def) {
+ addNamespace(getPrefix(namespaceURI), namespaceURI, def);
}
protected void addNamespace(String namespaceURI) {
@@ -305,11 +335,17 @@
}
protected void addNamespace(String prefix, String namespaceURI) {
+ addNamespace(prefix, namespaceURI, definition);
+ }
+
+ protected void addNamespace(String prefix, String namespaceURI, Definition
def) {
ns2prefix.put(namespaceURI, prefix);
- definition.addNamespace(prefix, namespaceURI);
+ def.addNamespace(prefix, namespaceURI);
}
- protected void buildPortTypeOperation(PortType portType,
Collection<OperationInfo> operationInfos) {
+ protected void buildPortTypeOperation(PortType portType,
+ Collection<OperationInfo>
operationInfos,
+ final Definition def) {
for (OperationInfo operationInfo : operationInfos) {
Operation operation = null;
try {
@@ -320,25 +356,25 @@
}
if (operation == null) {
- operation = definition.createOperation();
+ operation = def.createOperation();
operation.setUndefined(false);
operation.setName(operationInfo.getName().getLocalPart());
- addNamespace(operationInfo.getName().getNamespaceURI());
+ addNamespace(operationInfo.getName().getNamespaceURI(), def);
if (operationInfo.isOneWay()) {
operation.setStyle(OperationType.ONE_WAY);
}
- Input input = definition.createInput();
+ Input input = def.createInput();
input.setName(operationInfo.getInputName());
- Message message = definition.createMessage();
- buildMessage(message, operationInfo.getInput());
+ Message message = def.createMessage();
+ buildMessage(message, operationInfo.getInput(), def);
input.setMessage(message);
operation.setInput(input);
if (operationInfo.getOutput() != null) {
- Output output = definition.createOutput();
+ Output output = def.createOutput();
output.setName(operationInfo.getOutputName());
- message = definition.createMessage();
- buildMessage(message, operationInfo.getOutput());
+ message = def.createMessage();
+ buildMessage(message, operationInfo.getOutput(), def);
output.setMessage(message);
operation.setOutput(output);
}
@@ -346,10 +382,10 @@
Collection<FaultInfo> faults = operationInfo.getFaults();
Fault fault = null;
for (FaultInfo faultInfo : faults) {
- fault = definition.createFault();
+ fault = def.createFault();
fault.setName(faultInfo.getFaultName().getLocalPart());
- message = definition.createMessage();
- buildMessage(message, faultInfo);
+ message = def.createMessage();
+ buildMessage(message, faultInfo, def);
fault.setMessage(message);
operation.addFault(fault);
}
@@ -382,22 +418,24 @@
return prefix;
}
- protected void buildMessage(Message message, AbstractMessageContainer
messageContainer) {
+ protected void buildMessage(Message message,
+ AbstractMessageContainer messageContainer,
+ final Definition def) {
message.setQName(messageContainer.getName());
message.setUndefined(false);
- definition.addMessage(message);
+ def.addMessage(message);
List<MessagePartInfo> messageParts =
messageContainer.getMessageParts();
Part messagePart = null;
for (MessagePartInfo messagePartInfo : messageParts) {
- messagePart = definition.createPart();
+ messagePart = def.createPart();
messagePart.setName(messagePartInfo.getName().getLocalPart());
if (messagePartInfo.isElement()) {
messagePart.setElementName(messagePartInfo.getElementQName());
-
addNamespace(messagePartInfo.getElementQName().getNamespaceURI());
+
addNamespace(messagePartInfo.getElementQName().getNamespaceURI(), def);
} else if (messagePartInfo.getTypeQName() != null) {
messagePart.setTypeName(messagePartInfo.getTypeQName());
- addNamespace(messagePartInfo.getTypeQName().getNamespaceURI());
+ addNamespace(messagePartInfo.getTypeQName().getNamespaceURI(),
def);
}
message.addPart(messagePart);
}
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java?view=diff&rev=541220&r1=541219&r2=541220
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java
Thu May 24 00:52:56 2007
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -28,7 +29,6 @@
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
-
import javax.wsdl.Definition;
import javax.wsdl.Import;
import javax.wsdl.extensions.ExtensionRegistry;
@@ -97,16 +97,20 @@
throw new RuntimeException(msg.toString(), we);
}
}
-
- private void parseImports(Definition def) {
- List<Import> importList = new ArrayList<Import>();
- Map imports = def.getImports();
+
+ public static Collection<Import> getImports(final Definition wsdlDef) {
+ Collection<Import> importList = new ArrayList<Import>();
+ Map imports = wsdlDef.getImports();
for (Iterator iter = imports.keySet().iterator(); iter.hasNext();) {
String uri = (String)iter.next();
List<Import> lst = CastUtils.cast((List)imports.get(uri));
importList.addAll(lst);
}
- for (Import impt : importList) {
+ return importList;
+ }
+
+ private void parseImports(Definition def) {
+ for (Import impt : getImports(def)) {
parseImports(impt.getDefinition());
importedDefinitions.add(impt.getDefinition());
}
Modified:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java?view=diff&rev=541220&r1=541219&r2=541220
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
(original)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
Thu May 24 00:52:56 2007
@@ -18,7 +18,10 @@
*/
package org.apache.cxf.aegis;
+import java.util.ArrayList;
+import java.util.Collection;
import javax.wsdl.Definition;
+import javax.wsdl.Import;
import javax.wsdl.WSDLException;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLWriter;
@@ -48,6 +51,7 @@
import org.apache.cxf.transport.local.LocalTransportFactory;
import org.apache.cxf.wsdl.WSDLManager;
import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
+import org.apache.cxf.wsdl11.WSDLDefinitionBuilder;
import org.apache.cxf.wsdl11.WSDLManagerImpl;
import org.junit.Before;
@@ -128,23 +132,42 @@
sf.getServiceFactory().getServiceConfigurations().add(0, new
AegisServiceConfiguration());
sf.getServiceFactory().setDataBinding(new AegisDatabinding());
}
-
- protected Document getWSDLDocument(String string) throws WSDLException {
+ protected Collection<Document> getWSDLDocuments(String string) throws
WSDLException {
+ WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
+
+ Collection<Document> docs = new ArrayList<Document>();
+ Definition definition = getWSDLDefinition(string);
+ if (definition == null) {
+ return null;
+ }
+ docs.add(writer.getDocument(definition));
+
+ for (Import wsdlImport : WSDLDefinitionBuilder.getImports(definition))
{
+ docs.add(writer.getDocument(wsdlImport.getDefinition()));
+ }
+ return docs;
+ }
+
+ protected Definition getWSDLDefinition(String string) throws WSDLException
{
ServerRegistry svrMan = getBus().getExtension(ServerRegistry.class);
for (Server s : svrMan.getServers()) {
Service svc = s.getEndpoint().getService();
if (svc.getName().getLocalPart().equals(string)) {
ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus,
svc.getServiceInfos());
- Definition definition = builder.build();
-
- WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
- return writer.getDocument(definition);
+ return builder.build();
}
}
-
return null;
+
}
-
+ protected Document getWSDLDocument(String string) throws WSDLException {
+ Definition definition = getWSDLDefinition(string);
+ if (definition == null) {
+ return null;
+ }
+ WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
+ return writer.getDocument(definition);
+ }
}
Modified:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/OperationNSTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/OperationNSTest.java?view=diff&rev=541220&r1=541219&r2=541220
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/OperationNSTest.java
(original)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/OperationNSTest.java
Thu May 24 00:52:56 2007
@@ -18,23 +18,27 @@
*/
package org.apache.cxf.aegis.type.java5;
+import java.util.Collection;
import java.util.List;
-
+import java.util.Map;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
+import javax.xml.xpath.XPathConstants;
import org.w3c.dom.Document;
import org.apache.cxf.aegis.AbstractAegisTest;
import org.apache.cxf.aegis.databinding.AegisDatabinding;
import org.apache.cxf.aegis.util.XmlConstants;
+import org.apache.cxf.helpers.XPathUtils;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.junit.Before;
import org.junit.Test;
+
public class OperationNSTest extends AbstractAegisTest {
@Before
@@ -51,10 +55,21 @@
@Test
public void testWSDL() throws Exception {
- Document wsdl = getWSDLDocument("NotificationService");
+ Collection<Document> wsdls = getWSDLDocuments("NotificationService");
addNamespace("xsd", XmlConstants.XSD);
- assertValid("//xsd:[EMAIL PROTECTED]'Notify']", wsdl);
+ //assertValid("//xsd:[EMAIL PROTECTED]'Notify']", wsdl);
+ assertTrue(isExist(wsdls, "//xsd:[EMAIL PROTECTED]'Notify']",
getNamespaces()));
+ }
+
+ private boolean isExist(Collection<Document> docs, String xpath,
Map<String, String> ns) {
+ XPathUtils xpather = new XPathUtils(ns);
+ for (Document doc : docs) {
+ if (xpather.isExist(xpath, doc, XPathConstants.NODE)) {
+ return true;
+ }
+ }
+ return false;
}
@WebService(name = "NotificationLog", targetNamespace =
"http://www.sics.se/NotificationLog")
Modified:
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java?view=diff&rev=541220&r1=541219&r2=541220
==============================================================================
---
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java
(original)
+++
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/AbstractGenerator.java
Thu May 24 00:52:56 2007
@@ -63,14 +63,15 @@
public abstract T generate(File file);
- protected void createOutputDir(File file) {
+ protected File createOutputDir(File file) {
String parent = file.getParent();
if (parent == null) {
- return;
+ return null;
}
File parentDir = new File(parent);
if (parentDir.isDirectory() && !parentDir.exists()) {
parentDir.mkdirs();
}
+ return parentDir;
}
}
Modified:
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java?view=diff&rev=541220&r1=541219&r2=541220
==============================================================================
---
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java
(original)
+++
incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java
Thu May 24 00:52:56 2007
@@ -19,19 +19,26 @@
package org.apache.cxf.tools.java2wsdl.generator.wsdl11;
-import java.io.*;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
-
import javax.wsdl.Definition;
+import javax.wsdl.Import;
import javax.wsdl.WSDLException;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLWriter;
+import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.service.model.SchemaInfo;
import org.apache.cxf.tools.common.ToolException;
import org.apache.cxf.tools.java2wsdl.generator.AbstractGenerator;
import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
+import org.apache.cxf.wsdl11.WSDLDefinitionBuilder;
public class WSDL11Generator extends AbstractGenerator<Definition> {
@@ -47,7 +54,7 @@
file = new File(getServiceModel().getName().getLocalPart() +
".wsdl");
}
- createOutputDir(file);
+ File outputdir = createOutputDir(file);
Definition def = null;
try {
OutputStream os = new BufferedOutputStream(new
FileOutputStream(file));
@@ -64,6 +71,21 @@
def = builder.build(imports);
wsdlWriter.writeWSDL(def, os);
os.close();
+
+ if (def.getImports().size() > 0) {
+ for (Import wsdlImport :
WSDLDefinitionBuilder.getImports(def)) {
+ Definition wsdlDef = wsdlImport.getDefinition();
+ File wsdlFile = null;
+ if (!StringUtils.isEmpty(wsdlImport.getLocationURI())) {
+ wsdlFile = new File(outputdir,
wsdlImport.getLocationURI());
+ } else {
+ wsdlFile = new File(outputdir,
wsdlDef.getQName().getLocalPart() + ".wsdl");
+ }
+ OutputStream wsdlOs = new BufferedOutputStream(new
FileOutputStream(wsdlFile));
+ wsdlWriter.writeWSDL(wsdlDef, wsdlOs);
+ wsdlOs.close();
+ }
+ }
for (Map.Entry<String, SchemaInfo> imp : imports.entrySet()) {
File impfile = new File(file.getParentFile(), imp.getKey());
Added:
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/Hello.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/Hello.java?view=auto&rev=541220
==============================================================================
---
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/Hello.java
(added)
+++
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/Hello.java
Thu May 24 00:52:56 2007
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.tools.fortest.cxf699;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
[EMAIL PROTECTED](targetNamespace = "http://foo.com/HelloWorld", name =
"HelloWorld")
[EMAIL PROTECTED](style = SOAPBinding.Style.RPC)
+public interface Hello {
+
+ @WebResult(partName = "out", name = "out")
+ @WebMethod
+ String echoFoo(@WebParam(partName = "in", name = "in") String s);
+
+ @WebResult
+ @WebMethod
+ SayHiResponse sayHi(SayHi s);
+}
Added:
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/HelloImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/HelloImpl.java?view=auto&rev=541220
==============================================================================
---
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/HelloImpl.java
(added)
+++
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/HelloImpl.java
Thu May 24 00:52:56 2007
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.tools.fortest.cxf699;
+
+import javax.jws.WebService;
+
[EMAIL PROTECTED](serviceName = "HelloService",
+ portName = "HelloPort",
+ endpointInterface = "org.apache.cxf.tools.fortest.cxf699.Hello",
+ targetNamespace = "http://foo.com/HelloWorldService")
+public class HelloImpl {
+ public String echoFoo(String s) {
+ return s;
+ }
+
+ public SayHiResponse sayHi(SayHi s) {
+ return new SayHiResponse();
+ }
+}
Added:
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/SayHi.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/SayHi.java?view=auto&rev=541220
==============================================================================
---
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/SayHi.java
(added)
+++
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/SayHi.java
Thu May 24 00:52:56 2007
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.tools.fortest.cxf699;
+
+public class SayHi {
+
+ /**
+ * Describe msg here.
+ */
+ private String msg;
+
+ /**
+ * Get the <code>Msg</code> value.
+ *
+ * @return a <code>String</code> value
+ */
+ public final String getMsg() {
+ return msg;
+ }
+
+ /**
+ * Set the <code>Msg</code> value.
+ *
+ * @param newMsg The new Msg value.
+ */
+ public final void setMsg(final String newMsg) {
+ this.msg = newMsg;
+ }
+}
Added:
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/SayHiResponse.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/SayHiResponse.java?view=auto&rev=541220
==============================================================================
---
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/SayHiResponse.java
(added)
+++
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/fortest/cxf699/SayHiResponse.java
Thu May 24 00:52:56 2007
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.tools.fortest.cxf699;
+
+public class SayHiResponse {
+
+ /**
+ * Describe msg here.
+ */
+ private String msg;
+
+ /**
+ * Get the <code>Msg</code> value.
+ *
+ * @return a <code>String</code> value
+ */
+ public final String getMsg() {
+ return msg;
+ }
+
+ /**
+ * Set the <code>Msg</code> value.
+ *
+ * @param newMsg The new Msg value.
+ */
+ public final void setMsg(final String newMsg) {
+ this.msg = newMsg;
+ }
+}
Modified:
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?view=diff&rev=541220&r1=541219&r2=541220
==============================================================================
---
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
(original)
+++
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Thu May 24 00:52:56 2007
@@ -162,7 +162,7 @@
System.setProperty("java.class.path", "");
-// test flag
+ // test flag
String[] args = new String[] {"-o",
"java2wsdl.wsdl",
"-cp",
Modified:
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java?view=diff&rev=541220&r1=541219&r2=541220
==============================================================================
---
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
(original)
+++
incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
Thu May 24 00:52:56 2007
@@ -21,9 +21,12 @@
import java.io.File;
import java.io.FileInputStream;
+import java.util.Collection;
+import javax.xml.namespace.QName;
import org.apache.cxf.BusFactory;
import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.service.model.BindingInfo;
import org.apache.cxf.service.model.ServiceInfo;
import org.apache.cxf.tools.common.ProcessorTestBase;
import org.apache.cxf.tools.fortest.classnoanno.docbare.Stock;
@@ -31,6 +34,7 @@
import org.apache.cxf.tools.java2wsdl.generator.wsdl11.WSDL11Generator;
import org.apache.cxf.tools.util.AnnotationUtil;
import org.apache.hello_world_rpclit.GreeterRPCLit;
+import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -46,7 +50,7 @@
generator.setBus(builder.getBus());
}
- @org.junit.After
+ @After
public void tearDown() {
super.tearDown();
}
@@ -275,6 +279,13 @@
public void testRpcLitNoSEI() throws Exception {
builder.setServiceClass(org.apache.cxf.tools.fortest.withannotation.rpc.EchoImpl.class);
ServiceInfo service = builder.build();
+ assertNotNull(service);
+
+ assertEquals(new QName("http://cxf.apache.org/echotest",
"EchoService"),
+ service.getName());
+ assertEquals(new QName("http://cxf.apache.org/echotest", "Echo"),
+ service.getInterface().getName());
+
generator.setServiceModel(service);
File output = getOutputFile("rpclist_no_sei.wsdl");
@@ -289,6 +300,48 @@
.getResource("expected/expected_doc_lit_wrapped_with_wrapperclass.wsdl").getFile();
assertFileEquals(expectedFile, output.getAbsolutePath());
*/
+ }
+
+ @Test
+ public void testCXF669() throws Exception {
+ boolean oldSetting = generator.allowImports();
+ generator.setAllowImports(true);
+
+
builder.setServiceClass(org.apache.cxf.tools.fortest.cxf699.HelloImpl.class);
+ ServiceInfo service = builder.build();
+ assertNotNull(service);
+ assertEquals(new QName("http://foo.com/HelloWorldService",
"HelloService"), service.getName());
+ assertEquals(new QName("http://foo.com/HelloWorld", "HelloWorld"),
service.getInterface().getName());
+
+ // TODO this is not correct, schema namespace should be
http://foo.com/HelloWorld
+ assertEquals("http://foo.com/HelloWorldService",
+ service.getSchemas().iterator().next().getNamespaceURI());
+
+ Collection<BindingInfo> bindings = service.getBindings();
+ assertEquals(1, bindings.size());
+ assertEquals(new QName("http://foo.com/HelloWorldService",
"HelloServiceSoapBinding"),
+ bindings.iterator().next().getName());
+
+ generator.setServiceModel(service);
+ File wsdl = getOutputFile("HelloService.wsdl");
+ assertNotNull(wsdl);
+ generator.generate(wsdl);
+ assertTrue(wsdl.exists());
+ File logical = new File(output, "HelloWorld.wsdl");
+ assertTrue(logical.exists());
+ File schema = new File(output, "HelloService_schema1.xsd");
+ assertTrue(schema.exists());
+
+ String s = IOUtils.toString(new FileInputStream(wsdl));
+ assertTrue(s.indexOf("<wsdl:import
namespace=\"http://foo.com/HelloWorld\" "
+ + "location=\"HelloWorld.wsdl\">") != -1);
+
+ s = IOUtils.toString(new FileInputStream(logical));
+
+ assertTrue(s.indexOf("<import
namespace=\"http://foo.com/HelloWorldService\" "
+ +
"schemaLocation=\"HelloService_schema1.xsd\"/>") != -1);
+
+ generator.setAllowImports(oldSetting);
}
private File getOutputFile(String fileName) {