in modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java [91:198]
private boolean validateWSDLBindingType() {
boolean isBindingValid = false;
//Get the binding type from the annotation
String bindingType = endpointDesc.getBindingType();
// The wsdl binding type that we now receive has been previously mapped to the expected
// SOAP and HTTP bindings. So, there is now limited validation to perform.
//
// IMPORTANT NOTE: The value returned is NOT the WSDL Binding Type value; it has been
// normalized to be the value corresponding to the JAXWS BindingType annotations.
// That means when we log this value below we need to un-normalize it so the value
// is one that actuall appears in the WSDL. This isn't an issue for SOAP11 because
// the values are the same; but it IS an issue for SOAP12.
String wsdlBindingType = endpointDescWSDL.getWSDLBindingType();
if (bindingType == null) {
// I don't think this can happen; the Description layer should provide a default
addValidationFailure(this,
"Annotation binding type is null and did not have a default");
isBindingValid = false;
}
// Validate that the annotation value specified is valid.
else if (!SOAPBinding.SOAP11HTTP_BINDING.equals(bindingType) &&
!SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(bindingType) &&
!SOAPBinding.SOAP12HTTP_BINDING.equals(bindingType) &&
!SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(bindingType) &&
!MDQConstants.SOAP11JMS_BINDING.equals(bindingType) &&
!MDQConstants.SOAP11JMS_MTOM_BINDING.equals(bindingType) &&
!MDQConstants.SOAP12JMS_BINDING.equals(bindingType) &&
!MDQConstants.SOAP12JMS_MTOM_BINDING.equals(bindingType) &&
!HTTPBinding.HTTP_BINDING.equals(bindingType) &&
!MDQConstants.SOAP_HTTP_BINDING.equals(bindingType)) {
addValidationFailure(this,
"Invalid annotation binding value specified: " + bindingType);
isBindingValid = false;
}
else if(bindingType.equals(MDQConstants.SOAP_HTTP_BINDING) && endpointDesc.isEndpointBased()){
addValidationFailure(this,
"A SOAP_HTTP_BINDING was found on a @Bindingtype SEI based Endpoint." +
" SOAP_HTTP_BINDING is supported on Provider Endpoints only.");
isBindingValid = false;
}
// If there's no WSDL, then there will be no WSDL Binding Type to validate against
else if (wsdlBindingType == null) {
isBindingValid = true;
}
// Validate that the WSDL value is valid
else if (!SOAPBinding.SOAP11HTTP_BINDING.equals(wsdlBindingType)
&& !SOAPBinding.SOAP12HTTP_BINDING.equals(wsdlBindingType)
&& !jakarta.xml.ws.http.HTTPBinding.HTTP_BINDING.equals(wsdlBindingType)
&& !MDQConstants.SOAP11JMS_BINDING.equals(wsdlBindingType)
&& !MDQConstants.SOAP12JMS_BINDING.equals(wsdlBindingType)) {
addValidationFailure(this, "Invalid wsdl binding value specified: "
+ DescriptionUtils.mapBindingTypeAnnotationToWsdl(wsdlBindingType));
isBindingValid = false;
}
// Validate that the WSDL and annotations values indicate the same type of binding
else if (wsdlBindingType.equals(SOAPBinding.SOAP11HTTP_BINDING)
&& (bindingType.equals(SOAPBinding.SOAP11HTTP_BINDING) ||
bindingType.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING))) {
isBindingValid = true;
} else if (wsdlBindingType.equals(SOAPBinding.SOAP12HTTP_BINDING)
&& (bindingType.equals(SOAPBinding.SOAP12HTTP_BINDING) ||
bindingType.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING))) {
isBindingValid = true;
} else if (wsdlBindingType.equals(HTTPBinding.HTTP_BINDING)
&& bindingType.equals(HTTPBinding.HTTP_BINDING)) {
isBindingValid = true;
}
else if (wsdlBindingType.equals(MDQConstants.SOAP11JMS_BINDING)&& bindingType.startsWith(MDQConstants.SOAP11JMS_BINDING)) {
isBindingValid = true;
}
else if (wsdlBindingType.equals(MDQConstants.SOAP12JMS_BINDING)&& bindingType.startsWith(MDQConstants.SOAP12JMS_BINDING)) {
isBindingValid = true;
}
// The HTTP binding is not valid on a Java Bean SEI-based endpoint; only on a Provider based one.
else if (wsdlBindingType.equals(HTTPBinding.HTTP_BINDING) &&
endpointDesc.isEndpointBased()) {
addValidationFailure(this,
"An HTTPBinding was found on an @WebService SEI based endpoint. " +
"This is not supported. " +
"An HTTPBinding must use an @WebServiceProvider endpoint.");
isBindingValid = false;
}
// If wsdl binding is not HTTP binding and BindingType annotation is SOAP_HTTP_BINDING then
// wsdl is valid and JAX-WS needs to support both soap 11 and soap 12 on Provider endpoints.
else if(!wsdlBindingType.equals(HTTPBinding.HTTP_BINDING)
&& bindingType.equals(MDQConstants.SOAP_HTTP_BINDING) && endpointDesc.isProviderBased()){
isBindingValid = true;
}
else {
// Mismatched bindings
String wsdlInsert = "[" + bindingHumanReadableDescription(wsdlBindingType) + "]" +
"namespace = {" + DescriptionUtils.mapBindingTypeAnnotationToWsdl(wsdlBindingType) +"}";
String annotationInsert = "[" + bindingHumanReadableDescription(bindingType) + "]" +
"namespace = {" + bindingType +"}";
String message = Messages.getMessage("endpointDescriptionValidation",
wsdlInsert, annotationInsert);
addValidationFailure(this, message);
isBindingValid = false;
}
return isBindingValid;
}