Author: mmao
Date: Thu Mar 22 23:56:37 2007
New Revision: 521602
URL: http://svn.apache.org/viewvc?view=rev&rev=521602
Log:
[CXF-474] soapheader.wsdl and soapheader2.wsdl is not valid wsdl
* Tools validator add another WSI-BP V1.0 Rule 2210
* Remove the not valid part in soapheader.wsdl and soapheader2.wsdl in
testutils
* Comment the not valid part in unit test, MUST revisit later
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader.wsdl
incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader2.wsdl
incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java?view=diff&rev=521602&r1=521601&r2=521602
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
Thu Mar 22 23:56:37 2007
@@ -288,18 +288,19 @@
throw (Exception)ex.getCause();
}
}
-
- @Test
- public void testHolderNotTheFirstMessagePart() throws Exception {
- URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
- assertNotNull(wsdl);
-
- SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
- assertNotNull(service);
- TestHeader proxy = service.getPort(portName, TestHeader.class);
- Holder<SimpleAll> simpleAll = new Holder<SimpleAll>();
- simpleAll.value = new SimpleAll();
- proxy.sendReceiveAnyType(simpleAll, new SimpleChoice());
-
- }
+
+ // REVIST: This is not a valid WSDL according to WSI-BP V1.0
+ // @Test
+ // public void testHolderNotTheFirstMessagePart() throws Exception {
+ // URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
+ // assertNotNull(wsdl);
+
+ // SOAPHeaderService service = new SOAPHeaderService(wsdl,
serviceName);
+ // assertNotNull(service);
+ // TestHeader proxy = service.getPort(portName, TestHeader.class);
+ // Holder<SimpleAll> simpleAll = new Holder<SimpleAll>();
+ // simpleAll.value = new SimpleAll();
+ // proxy.sendReceiveAnyType(simpleAll, new SimpleChoice());
+
+ // }
}
Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader.wsdl
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader.wsdl?view=diff&rev=521602&r1=521601&r2=521602
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader.wsdl
(original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader.wsdl Thu
Mar 22 23:56:37 2007
@@ -224,10 +224,14 @@
<wsdl:output name="testHeaderPartBeforeBodyPartResponse"
message="tns:testHeaderPartBeforeBodyPartResponse"/>
</wsdl:operation>
+
+ <!-- this is not a valid operation according to WSI-BP V1.0 R2210
+ A unit test also commented out in HeaderClientServerTest in
rt/frontend/jaxws
<operation name="send_receive_any_type">
<input name="send_receive_any_type_request"
message="tns:AnyTypeRequest"/>
<output name="send_receive_any_type_response"
message="tns:AnyTypeResponse"/>
</operation>
+ -->
</wsdl:portType>
<wsdl:binding name="TestHeader_SOAPBinding" type="tns:TestHeader">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
@@ -296,6 +300,7 @@
part="inoutHeader" use="literal"/>
</wsdl:output>
</wsdl:operation>
+ <!-- this is not a valid operation according to WSI-BP V1.0 R2210
<operation name="send_receive_any_type">
<soap:operation soapAction="" style="document"/>
<input>
@@ -305,6 +310,7 @@
<soap:body use="literal"/>
</output>
</operation>
+ -->
</wsdl:binding>
<wsdl:service name="SOAPHeaderService">
<wsdl:port name="SoapHeaderPort" binding="tns:TestHeader_SOAPBinding">
Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader2.wsdl
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader2.wsdl?view=diff&rev=521602&r1=521601&r2=521602
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader2.wsdl
(original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/soapheader2.wsdl Thu
Mar 22 23:56:37 2007
@@ -104,41 +104,6 @@
</operation>
</portType>
- <binding name="headerTesterSOAPBinding" type="tns:headerTester">
- <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
- <operation name="inHeader">
- <soap:operation soapAction="" style="document" />
- <input name="inHeaderRequest">
- <soap:body parts="me" use="literal" />
- <soap:header message="tns:inHeaderRequest" part="header_info"
use="literal" />
- </input>
- <output name="inHeaderResponse">
- <soap:body use="literal" />
- </output>
- </operation>
- <operation name="outHeader">
- <soap:operation soapAction="" style="document" />
- <input name="outHeaderRequest">
- <soap:body use="literal" />
- </input>
- <output name="outHeaderResponse">
- <soap:body parts="the_response" use="literal" />
- <soap:header message="tns:outHeaderResponse"
part="header_info" use="literal" />
- </output>
- </operation>
- <operation name="inoutHeader">
- <soap:operation soapAction="" style="document" />
- <input name="inoutHeaderRequest">
- <soap:body parts="me" use="literal" />
- <soap:header message="tns:inoutHeaderRequest"
part="header_info" use="literal" />
- </input>
- <output name="inoutHeaderResponse">
- <soap:body parts="the_response" use="literal" />
- <soap:header message="tns:inoutHeaderResponse"
part="header_info" use="literal" />
- </output>
- </operation>
- </binding>
-
<wsdl:binding name="headerTesterXMLBinding" type="tns:headerTester">
<xformat:binding />
<wsdl:operation name="inHeader">
Modified:
incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java?view=diff&rev=521602&r1=521601&r2=521602
==============================================================================
---
incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
(original)
+++
incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
Thu Mar 22 23:56:37 2007
@@ -67,18 +67,22 @@
}
}
} catch (ToolException ex) {
- System.err.println("Error : " + ex.getMessage());
+ System.err.println("WSDLValidator Error : " + ex.getMessage());
if (ex.getCause() instanceof BadUsageException) {
printUsageException(TOOL_NAME,
(BadUsageException)ex.getCause());
}
System.err.println();
if (isVerboseOn()) {
+ System.err.println("[+] Verbose turned on");
+ System.err.println();
ex.printStackTrace();
}
} catch (Exception ex) {
- System.err.println("Error : " + ex.getMessage());
+ System.err.println("WSDLValidator Error : " + ex.getMessage());
System.err.println();
if (isVerboseOn()) {
+ System.err.println("[+] Verbose turned on");
+ System.err.println();
ex.printStackTrace();
}
}
Modified:
incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java?view=diff&rev=521602&r1=521601&r2=521602
==============================================================================
---
incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
(original)
+++
incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
Thu Mar 22 23:56:37 2007
@@ -67,6 +67,108 @@
}
+ private boolean checkR2201Input(final Operation operation,
+ final BindingOperation bop,
+ final Binding binding) {
+ List<Part> partsList = wsdlHelper.getInMessageParts(operation);
+ int inmessagePartsCount = partsList.size();
+ SoapBody soapBody = SOAPBindingUtil.getBindingInputSOAPBody(bop);
+ if (soapBody != null) {
+ List parts = soapBody.getParts();
+ int boundPartSize = parts == null ? inmessagePartsCount :
parts.size();
+ SoapHeader soapHeader =
SOAPBindingUtil.getBindingInputSOAPHeader(bop);
+ boundPartSize = soapHeader != null
+ && soapHeader.getMessage().equals(
+ operation.getInput().getMessage()
+ .getQName())
+ ? boundPartSize - 1 : boundPartSize;
+
+ if (parts != null) {
+ Iterator partsIte = parts.iterator();
+ while (partsIte.hasNext()) {
+ String partName = (String)partsIte.next();
+ boolean isDefined = false;
+ for (Part part : partsList) {
+ if (partName.equalsIgnoreCase(part.getName())) {
+ isDefined = true;
+ break;
+ }
+ }
+ if (!isDefined) {
+ addErrorMessage("Violate WSI-BP-1.0 R2201 operation '"
+ + operation.getName() + "' soapBody
parts : "
+ + partName + " not found in the
message, wrong WSDL");
+ return false;
+ }
+ }
+ } else {
+ if (partsList.size() > 1) {
+ addErrorMessage("Violate WSI-BP-1.0 R2210: operation '" +
operation.getName()
+ + "' more than one part bound to body");
+ return false;
+ }
+ }
+
+
+ if (boundPartSize > 1) {
+ addErrorMessage("Violate WSI-BP-1.0 R2201 operation '" +
operation.getName()
+ + "' more than one part bound to body");
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean checkR2201Output(final Operation operation,
+ final BindingOperation bop,
+ final Binding binding) {
+ int outmessagePartsCount =
wsdlHelper.getOutMessageParts(operation).size();
+ SoapBody soapBody = SOAPBindingUtil.getBindingOutputSOAPBody(bop);
+ if (soapBody != null) {
+ List parts = soapBody.getParts();
+ int boundPartSize = parts == null ? outmessagePartsCount :
parts.size();
+ SoapHeader soapHeader =
SOAPBindingUtil.getBindingOutputSOAPHeader(bop);
+ boundPartSize = soapHeader != null
+ && soapHeader.getMessage().equals(
+ operation.getOutput().getMessage()
+ .getQName())
+ ? boundPartSize - 1 : boundPartSize;
+ if (parts != null) {
+ Iterator partsIte = parts.iterator();
+ while (partsIte.hasNext()) {
+ String partName = (String)partsIte.next();
+ boolean isDefined = false;
+ for (Part part : wsdlHelper.getOutMessageParts(operation))
{
+ if (partName.equalsIgnoreCase(part.getName())) {
+ isDefined = true;
+ break;
+ }
+ }
+ if (!isDefined) {
+ addErrorMessage("Violate WSI-BP-1.0 R2201 operation '"
+ + operation.getName() + "' soapBody
parts : "
+ + partName + " not found in the
message, wrong WSDL");
+ return false;
+ }
+
+ }
+ } else {
+ if (wsdlHelper.getOutMessageParts(operation).size() > 1) {
+ addErrorMessage("Violate WSI-BP-1.0 R2210: operation '" +
operation.getName()
+ + "' more than one part bound to body");
+ return false;
+ }
+ }
+
+ if (boundPartSize > 1) {
+ addErrorMessage("Violate WSI-BP-1.0 R2201 operation '" +
operation.getName()
+ + "' more than one part bound to body");
+ return false;
+ }
+ }
+ return true;
+ }
+
public boolean checkR2201() {
for (PortType portType : wsdlHelper.getPortTypes(def)) {
Iterator ite = portType.getOperations().iterator();
@@ -83,82 +185,11 @@
? bindingStyle :
SOAPBindingUtil.getSOAPOperationStyle(bop);
if ("DOCUMENT".equalsIgnoreCase(style)) {
- List<Part> partsList =
wsdlHelper.getInMessageParts(operation);
- int inmessagePartsCount = partsList.size();
- SoapBody soapBody =
SOAPBindingUtil.getBindingInputSOAPBody(bop);
- if (soapBody != null) {
- List parts = soapBody.getParts();
- int boundPartSize = parts == null ?
inmessagePartsCount : parts.size();
- SoapHeader soapHeader =
SOAPBindingUtil.getBindingInputSOAPHeader(bop);
- boundPartSize = soapHeader != null
- && soapHeader.getMessage().equals(
-
operation.getInput().getMessage()
-
.getQName())
- ? boundPartSize - 1 : boundPartSize;
-
- if (parts != null) {
- Iterator partsIte = parts.iterator();
- while (partsIte.hasNext()) {
- String partName = (String)partsIte.next();
- boolean isDefined = false;
- for (Part part : partsList) {
- if
(partName.equalsIgnoreCase(part.getName())) {
- isDefined = true;
- break;
- }
- }
- if (!isDefined) {
- addErrorMessage("operation: " +
operation.getName() + " soapBody parts : "
- + partName + " not found
in the message, wrong WSDL");
- return false;
- }
-
- }
- }
-
- if (boundPartSize > 1) {
- addErrorMessage("operation:" + operation.getName()
- + " more than one part bound to
body");
- return false;
- }
+ if (!checkR2201Input(operation, bop, binding)) {
+ return false;
}
-
- int outmessagePartsCount =
wsdlHelper.getOutMessageParts(operation).size();
- soapBody = SOAPBindingUtil.getBindingOutputSOAPBody(bop);
- if (soapBody != null) {
- List parts = soapBody.getParts();
- int boundPartSize = parts == null ?
outmessagePartsCount : parts.size();
- SoapHeader soapHeader =
SOAPBindingUtil.getBindingOutputSOAPHeader(bop);
- boundPartSize = soapHeader != null
- && soapHeader.getMessage().equals(
-
operation.getOutput().getMessage()
-
.getQName())
- ? boundPartSize - 1 : boundPartSize;
- if (parts != null) {
- Iterator partsIte = parts.iterator();
- while (partsIte.hasNext()) {
- String partName = (String)partsIte.next();
- boolean isDefined = false;
- for (Part part :
wsdlHelper.getOutMessageParts(operation)) {
- if
(partName.equalsIgnoreCase(part.getName())) {
- isDefined = true;
- break;
- }
- }
- if (!isDefined) {
- addErrorMessage("operation: " +
operation.getName() + " soapBody parts : "
- + partName + " not found
in the message, wrong WSDL");
- return false;
- }
-
- }
- }
-
- if (boundPartSize > 1) {
- addErrorMessage("operation:" + operation.getName()
- + " more than one part bound to
body");
- return false;
- }
+ if (!checkR2201Output(operation, bop, binding)) {
+ return false;
}
}
}
Modified:
incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java?view=diff&rev=521602&r1=521601&r2=521602
==============================================================================
---
incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
(original)
+++
incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
Thu Mar 22 23:56:37 2007
@@ -140,6 +140,18 @@
}
+ public void testWSIBP2210() throws Exception {
+ try {
+ String[] args = new String[] {"-verbose",
+
getLocation("/validator_wsdl/soapheader.wsdl")};
+ WSDLValidator.main(args);
+ assertTrue(getStdErr().indexOf("WSI-BP-1.0 R2210") > -1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
protected String getLocation(String wsdlFile) throws Exception {
Enumeration<URL> e =
WSDLValidationTest.class.getClassLoader().getResources(wsdlFile);
while (e.hasMoreElements()) {