Author: midon
Date: Mon Jul 14 11:41:01 2008
New Revision: 676677
URL: http://svn.apache.org/viewvc?rev=676677&view=rev
Log:
check that <mime:content type=""/> is not empty
Modified:
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/Messages.java
ode/branches/APACHE_ODE_1.X/axis2/src/test/resources/http-binding-validator.wsdl
Modified:
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java?rev=676677&r1=676676&r2=676677&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java
(original)
+++
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java
Mon Jul 14 11:41:01 2008
@@ -20,6 +20,9 @@
package org.apache.ode.axis2.httpbinding;
import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.lang.StringUtils;
import org.apache.ode.utils.wsdl.WsdlUtils;
import javax.wsdl.Binding;
@@ -64,7 +67,7 @@
protected void validateOperation(BindingOperation bindingOperation) {
String verb = WsdlUtils.resolveVerb(binding, bindingOperation);
- if(verb==null){
+ if (verb == null) {
throw new
IllegalArgumentException(httpMsgs.msgMissingVerb(binding, bindingOperation));
}
if (!"GET".equalsIgnoreCase(verb)
@@ -77,8 +80,13 @@
BindingOutput output = bindingOperation.getBindingOutput();
MIMEContent outputContent =
WsdlUtils.getMimeContent(output.getExtensibilityElements());
- if (outputContent!=null &&
!outputContent.getType().endsWith("text/xml")) {
- throw new
IllegalArgumentException(httpMsgs.msgUnsupportedContentType(binding,
bindingOperation));
+ if (outputContent != null) {
+ if (StringUtils.isEmpty(outputContent.getType())) {
+ throw new
IllegalArgumentException(httpMsgs.msgEmptyContentType(binding,
bindingOperation));
+ }
+ if (!outputContent.getType().endsWith("text/xml")) {
+ throw new
IllegalArgumentException(httpMsgs.msgUnsupportedContentType(binding,
bindingOperation));
+ }
}
BindingInput input = bindingOperation.getBindingInput();
@@ -89,9 +97,12 @@
}
// only 2 content-types supported
- MIMEContent inputContent=
WsdlUtils.getMimeContent(input.getExtensibilityElements());
+ MIMEContent inputContent =
WsdlUtils.getMimeContent(input.getExtensibilityElements());
if (inputContent != null) {
String inputContentType = inputContent.getType();
+ if (StringUtils.isEmpty(inputContentType)) {
+ throw new
IllegalArgumentException(httpMsgs.msgEmptyContentType(binding,
bindingOperation));
+ }
if (!inputContentType.endsWith("text/xml") &&
!PostMethod.FORM_URL_ENCODED_CONTENT_TYPE.equalsIgnoreCase(inputContentType)) {
throw new
IllegalArgumentException(httpMsgs.msgUnsupportedContentType(binding,
bindingOperation));
}
Modified:
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/Messages.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/Messages.java?rev=676677&r1=676676&r2=676677&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/Messages.java
(original)
+++
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/Messages.java
Mon Jul 14 11:41:01 2008
@@ -43,8 +43,12 @@
return format("This binding does not use http:binding: {0}" +
binding.getQName());
}
+ public String msgEmptyContentType(Binding binding, BindingOperation
operation) {
+ return format("MIME Content Type is empty! binding: {0} operation:
{1}", binding.getQName(), operation.getName());
+ }
+
public String msgUnsupportedContentType(Binding binding, BindingOperation
operation) {
- return format("Unsupported content-type!binding: {0} operation: {1}",
binding.getQName(), operation.getName());
+ return format("Unsupported content-type! binding: {0} operation: {1}",
binding.getQName(), operation.getName());
}
public String msgInvalidURIPattern() {
Modified:
ode/branches/APACHE_ODE_1.X/axis2/src/test/resources/http-binding-validator.wsdl
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/test/resources/http-binding-validator.wsdl?rev=676677&r1=676676&r2=676677&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/axis2/src/test/resources/http-binding-validator.wsdl
(original)
+++
ode/branches/APACHE_ODE_1.X/axis2/src/test/resources/http-binding-validator.wsdl
Mon Jul 14 11:41:01 2008
@@ -172,21 +172,6 @@
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="DummyServiceHttpBinding_put+whatever-content-type"
type="ns1:DummyServicePortType">
- <wsdl:documentation>
- shouldFail # Only application/x-www-form-urlencoded and text/xml
should be supported
- </wsdl:documentation>
- <http:binding verb="PUT"/>
- <wsdl:operation name="hello">
- <http:operation location="DummyService/hello"/>
- <wsdl:input>
- <mime:content type="whatever-content-type" part="TestPart"/>
- </wsdl:input>
- <wsdl:output>
- <mime:content type="text/xml" part="TestPart"/>
- </wsdl:output>
- </wsdl:operation>
- </wsdl:binding>
<!-- ###################################### -->
<!-- POST tests-->
<!-- ###################################### -->
@@ -235,21 +220,6 @@
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="DummyServiceHttpBinding_post+whatever-content-type"
type="ns1:DummyServicePortType">
- <wsdl:documentation>
- shouldFail # Only application/x-www-form-urlencoded and text/xml
should be supported
- </wsdl:documentation>
- <http:binding verb="POST"/>
- <wsdl:operation name="hello">
- <http:operation location="DummyService/hello"/>
- <wsdl:input>
- <mime:content type="whatever-content-type" part="TestPart"/>
- </wsdl:input>
- <wsdl:output>
- <mime:content type="text/xml" part="TestPart"/>
- </wsdl:output>
- </wsdl:operation>
- </wsdl:binding>
<!-- ###################################### -->
<!-- GET tests-->
<!-- ###################################### -->
@@ -396,5 +366,71 @@
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
+
+ <!-- ###################################### -->
+ <!-- Content-Type tests-->
+ <!-- ###################################### -->
+ <wsdl:binding name="DummyServiceHttpBinding_put+whatever-content-type"
type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldFail # Only application/x-www-form-urlencoded and text/xml
should be supported
+ </wsdl:documentation>
+ <http:binding verb="PUT"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello"/>
+ <wsdl:input>
+ <mime:content type="whatever-content-type" part="TestPart"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="TestPart"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="DummyServiceHttpBinding_post+whatever-content-type"
type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldFail # Only application/x-www-form-urlencoded and text/xml
should be supported
+ </wsdl:documentation>
+ <http:binding verb="POST"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello"/>
+ <wsdl:input>
+ <mime:content type="whatever-content-type" part="TestPart"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="TestPart"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="DummyServiceHttpBinding_missing-content-type"
type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldFail # mime:content, type attribute is mandatory
+ </wsdl:documentation>
+ <http:binding verb="POST"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello"/>
+ <wsdl:input>
+ <mime:content part="TestPart"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content part="TestPart"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="DummyServiceHttpBinding_empty-content-type"
type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldFail # mime:content, type attribute cannot be empty
+ </wsdl:documentation>
+ <http:binding verb="POST"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello"/>
+ <wsdl:input>
+ <mime:content part="TestPart" type=""/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content part="TestPart" type=""/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+
<!-- no <service> tags needed -->
</wsdl:definitions>