Author: dkulp
Date: Tue Jan 29 10:54:00 2008
New Revision: 616476
URL: http://svn.apache.org/viewvc?rev=616476&view=rev
Log:
Fix issue with generated schemas for wrapped operations that don't match the
rules for wrapped (element ref instead of type)
Fix problems with faults possibly causing created schemas to not be qualified
when qualified is asked for.
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ComplexException.java
(with props)
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java
incubator/cxf/trunk/pom.xml
incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/expected_get_book123_xmlwrapped.txt
incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookServiceWrapped.java
incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/wraped/CustomerService.java
incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java?rev=616476&r1=616475&r2=616476&view=diff
==============================================================================
---
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java
(original)
+++
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/SchemaInfo.java
Tue Jan 29 10:54:00 2008
@@ -29,6 +29,7 @@
import org.apache.cxf.wsdl.WSDLConstants;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaForm;
public final class SchemaInfo extends AbstractPropertiesHolder {
@@ -42,10 +43,14 @@
String systemId;
public SchemaInfo(ServiceInfo serviceInfo, String namespaceUri) {
+ this(serviceInfo, namespaceUri, false, false);
+ }
+ public SchemaInfo(ServiceInfo serviceInfo, String namespaceUri,
+ boolean qElement, boolean qAttribute) {
this.serviceInfo = serviceInfo;
this.namespaceUri = namespaceUri;
- this.isElementQualified = false;
- this.isAttributeQualified = false;
+ this.isElementQualified = qElement;
+ this.isAttributeQualified = qAttribute;
}
public String toString() {
@@ -126,6 +131,8 @@
public void setSchema(XmlSchema schema) {
this.schema = schema;
+ isElementQualified =
schema.getElementFormDefault().getValue().equals(XmlSchemaForm.QUALIFIED);
+ isAttributeQualified =
schema.getAttributeFormDefault().getValue().equals(XmlSchemaForm.QUALIFIED);
}
public String getSystemId() {
Modified: incubator/cxf/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/pom.xml?rev=616476&r1=616475&r2=616476&view=diff
==============================================================================
--- incubator/cxf/trunk/pom.xml (original)
+++ incubator/cxf/trunk/pom.xml Tue Jan 29 10:54:00 2008
@@ -443,7 +443,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
- <version>2.0-alpha-4</version>
+ <version>2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Modified:
incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java?rev=616476&r1=616475&r2=616476&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
(original)
+++
incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
Tue Jan 29 10:54:00 2008
@@ -99,6 +99,13 @@
}
boolean isElement = beanInfo.isElement();
+ boolean hasType = !beanInfo.getTypeNames().isEmpty();
+ if (isElement && isFromWrapper && hasType) {
+ //if there is both a Global element and a global type, AND we are
in a wrapper,
+ //make sure we use the type instead of a ref to the element to
+ //match the rules for wrapped/unwrapped
+ isElement = false;
+ }
part.setElement(isElement);
@@ -178,10 +185,15 @@
}
return;
}
- schemaInfo = new SchemaInfo(serviceInfo, qn.getNamespaceURI());
+
+ schemaInfo = new SchemaInfo(serviceInfo, qn.getNamespaceURI(),
qualifiedSchemas, false);
+
el = createXsElement(part, typeName, schemaInfo);
XmlSchema schema =
schemas.newXmlSchemaInCollection(qn.getNamespaceURI());
+ if (qualifiedSchemas) {
+ schema.setElementFormDefault(new
XmlSchemaForm(XmlSchemaForm.QUALIFIED));
+ }
schemaInfo.setSchema(schema);
schema.getElements().add(el.getQName(), el);
schema.getItems().add(el);
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java?rev=616476&r1=616475&r2=616476&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
Tue Jan 29 10:54:00 2008
@@ -341,6 +341,10 @@
assertEquals(3, ints.length);
assertEquals(1, ints[0]);
+ testExceptionCases(port);
+ }
+
+ private void testExceptionCases(DocLitWrappedCodeFirstService port) throws
Exception {
/* CXF-926 test case */
try {
port.throwException(10);
@@ -363,7 +367,20 @@
assertEquals("CE: -2", ex.getMessage());
assertEquals("A Value", ex.getA());
assertEquals("B Value", ex.getB());
- }
+ }
+ // CXF-1407
+ try {
+ port.throwException(-3);
+ fail("Expected exception not found");
+ } catch (ComplexException ex) {
+ assertEquals("Throw user fault -3", ex.getMessage());
+ }
+ try {
+ port.throwException(-3);
+ fail("Expected exception not found");
+ } catch (ComplexException ex) {
+ assertEquals("Throw user fault -3", ex.getMessage());
+ }
}
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ComplexException.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ComplexException.java?rev=616476&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ComplexException.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ComplexException.java
Tue Jan 29 10:54:00 2008
@@ -0,0 +1,76 @@
+/**
+ * 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.systest.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
[EMAIL PROTECTED](XmlAccessType.FIELD)
+public class ComplexException extends org.omg.CORBA.UserException {
+
+ private String reason;
+ private MyBean[] beans;
+
+ public ComplexException(String msg) {
+ super(msg);
+ }
+
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ public MyBean[] getBeans() {
+ return beans;
+ }
+
+ public void setBeans(MyBean[] beans) {
+ this.beans = beans;
+ }
+
+
+ @XmlAccessorType(XmlAccessType.PROPERTY)
+ public static class MyBean {
+
+ private String name;
+ private int age;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+
+ }
+}
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ComplexException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ComplexException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java?rev=616476&r1=616475&r2=616476&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
Tue Jan 29 10:54:00 2008
@@ -83,7 +83,8 @@
List<Foo[]> listObjectArrayOutput();
@WebMethod
- int throwException(int i) throws ServiceTestFault, CustomException;
+ int throwException(int i)
+ throws ServiceTestFault, CustomException, ComplexException;
@RequestWrapper(localName = "echoIntX")
@ResponseWrapper(localName = "echoIntXResponse")
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java?rev=616476&r1=616475&r2=616476&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
Tue Jan 29 10:54:00 2008
@@ -120,7 +120,8 @@
return Arrays.asList(new Foo[] {a, b}, new Foo[] {c, d});
}
- public int throwException(int i) throws ServiceTestFault, CustomException {
+ public int throwException(int i)
+ throws ServiceTestFault, CustomException, ComplexException {
switch (i) {
case -1:
throw new ServiceTestFault("Hello!");
@@ -129,6 +130,14 @@
cex.setA("A Value");
cex.setB("B Value");
throw cex;
+ }
+ case -3: {
+ ComplexException ex = new ComplexException("Throw user fault -3");
+ ex.setReason("Test");
+ ComplexException.MyBean bean = new ComplexException.MyBean();
+ bean.setName("Marco");
+ ex.setBeans(new ComplexException.MyBean[] {bean});
+ throw ex;
}
default:
throw new ServiceTestFault(new
ServiceTestFault.ServiceTestDetails(i));
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java?rev=616476&r1=616475&r2=616476&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
Tue Jan 29 10:54:00 2008
@@ -47,7 +47,7 @@
@BeforeClass
public static void startServers() throws Exception {
- assertTrue("server did not launch correctly",
launchServer(BookServer.class));
+ assertTrue("server did not launch correctly",
launchServer(BookServer.class, true));
}
@Test
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/expected_get_book123_xmlwrapped.txt
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/expected_get_book123_xmlwrapped.txt?rev=616476&r1=616475&r2=616476&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/expected_get_book123_xmlwrapped.txt
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/resources/expected_get_book123_xmlwrapped.txt
Tue Jan 29 10:54:00 2008
@@ -1 +1 @@
-<ns1:getBookResponse xmlns:ns1="http://book.customer.cxf.apache.org/"><Book
xmlns="http://book.acme.com"><id>123</id><name>CXF in
Action</name></Book></ns1:getBookResponse>
\ No newline at end of file
+<ns1:getBookResponse
xmlns:ns1="http://book.customer.cxf.apache.org/"><ns2:Book
xmlns:ns2="http://book.customer.cxf.apache.org/"
xmlns="http://book.acme.com"><id>123</id><name>CXF in
Action</name></ns2:Book></ns1:getBookResponse>
\ No newline at end of file
Modified:
incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookServiceWrapped.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookServiceWrapped.java?rev=616476&r1=616475&r2=616476&view=diff
==============================================================================
---
incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookServiceWrapped.java
(original)
+++
incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookServiceWrapped.java
Tue Jan 29 10:54:00 2008
@@ -21,6 +21,7 @@
import javax.jws.WebParam;
+import javax.jws.WebResult;
import javax.jws.WebService;
import org.codehaus.jra.Get;
@@ -32,6 +33,7 @@
@Get
@HttpResource(location = "/books/{id}")
+ @WebResult(name = "Book")
Book getBook(@WebParam(name = "id")long bookid) throws BookNotFoundFault;
Modified:
incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/wraped/CustomerService.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/wraped/CustomerService.java?rev=616476&r1=616475&r2=616476&view=diff
==============================================================================
---
incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/wraped/CustomerService.java
(original)
+++
incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/wraped/CustomerService.java
Tue Jan 29 10:54:00 2008
@@ -23,6 +23,7 @@
import javax.jws.WebMethod;
import javax.jws.WebParam;
+import javax.jws.WebResult;
import javax.jws.WebService;
import org.apache.cxf.customer.Customer;
@@ -47,6 +48,7 @@
@Get
@HttpResource(location = "/customers")
@WebMethod
+ @WebResult(name = "customers")
public Customers getCustomers() {
Customers cbean = new Customers();
cbean.setCustomer(customers.values());
@@ -56,6 +58,7 @@
@Get
@HttpResource(location = "/customers/{id}")
@WebMethod
+ @WebResult(name = "customer")
public Customer getCustomer(@WebParam(name = "id") Long id) {
return customers.get(id);
}
@@ -63,7 +66,8 @@
@Put
@HttpResource(location = "/customers/{id}")
@WebMethod
- public void updateCustomer(@WebParam(name = "id") String id, Customer c) {
+ public void updateCustomer(@WebParam(name = "id") String id,
+ @WebParam(name = "customer") Customer c) {
customers.put(c.getId(), c);
}
Modified:
incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?rev=616476&r1=616475&r2=616476&view=diff
==============================================================================
---
incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
(original)
+++
incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Tue Jan 29 10:54:00 2008
@@ -573,6 +573,9 @@
File wsdlFile = new File(output, "epr_schema1.xsd");
assertTrue(wsdlFile.exists());
String expectedString =
"schemaLocation=\"http://www.w3.org/2006/03/addressing/ws-addr.xsd\"";
- assertTrue(getStringFromFile(wsdlFile).indexOf(expectedString) != -1);
+ String xsd = getStringFromFile(wsdlFile);
+ assertTrue(xsd.indexOf(expectedString) != -1);
+ assertTrue(xsd.indexOf("ref=") == -1);
+
}
}