use of org.apache.woden.wsdl20.extensions.soap.SOAPBindingOperationExtensions in project axis-axis2-java-core by apache.
the class WSDL20ToAxisServiceBuilder method processSOAPBindingExtention.
private void processSOAPBindingExtention(Binding binding, AxisBinding axisBinding, Interface serviceInterface) throws AxisFault {
// Capture all the binding specific properties
// Set a comparator so tha httpLocations are stored in decending order
Map httpLocationTable = new TreeMap(new Comparator() {
public int compare(Object o1, Object o2) {
return (-1 * ((Comparable) o1).compareTo(o2));
}
});
SOAPBindingExtensions soapBindingExtensions;
try {
soapBindingExtensions = (SOAPBindingExtensions) binding.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_SOAP));
} catch (URISyntaxException e) {
throw new AxisFault("Soap Binding Extention not found");
}
String soapVersion;
if ((soapVersion = soapBindingExtensions.getSoapVersion()) != null) {
if (soapVersion.equals(WSDL2Constants.SOAP_VERSION_1_1)) {
axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
} else {
axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
}
} else {
// Set the default to soap 1.2
axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION, WSDL20DefaultValueHolder.getDefaultValue(WSDL2Constants.ATTR_WSOAP_VERSION));
}
URI soapUnderlyingProtocol = soapBindingExtensions.getSoapUnderlyingProtocol();
if (soapUnderlyingProtocol != null) {
axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_PROTOCOL, soapUnderlyingProtocol.toString());
}
URI soapMepDefault = soapBindingExtensions.getSoapMepDefault();
if (soapMepDefault != null) {
axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_MEP, soapMepDefault.toString());
}
axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING, soapBindingExtensions.getHttpContentEncodingDefault());
axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE, createSoapModules(soapBindingExtensions.getSoapModules()));
axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, soapBindingExtensions.getHttpQueryParameterSeparatorDefault());
// Capture all the fault specific properties
BindingFault[] bindingFaults = binding.getBindingFaults();
for (int i = 0; i < bindingFaults.length; i++) {
BindingFault bindingFault = bindingFaults[i];
InterfaceFault interfaceFault = serviceInterface.getFromAllInterfaceFaults(((BindingFaultElement) bindingFault).getRef());
AxisBindingMessage axisBindingFault = new AxisBindingMessage();
axisBindingFault.setFault(true);
axisBindingFault.setName(interfaceFault.getName().getLocalPart());
axisBindingFault.setParent(axisBinding);
addDocumentation(axisBindingFault, interfaceFault.toElement());
SOAPBindingFaultExtensions soapBindingFaultExtensions;
try {
soapBindingFaultExtensions = (SOAPBindingFaultExtensions) bindingFault.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_SOAP));
} catch (URISyntaxException e) {
throw new AxisFault("Soap Binding Extention not found");
}
axisBindingFault.setProperty(WSDL2Constants.ATTR_WHTTP_HEADER, createHttpHeaders(soapBindingFaultExtensions.getHttpHeaders()));
axisBindingFault.setProperty(WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING, soapBindingFaultExtensions.getHttpContentEncoding());
axisBindingFault.setProperty(WSDL2Constants.ATTR_WSOAP_CODE, soapBindingFaultExtensions.getSoapFaultCode());
axisBindingFault.setProperty(WSDL2Constants.ATTR_WSOAP_SUBCODES, soapBindingFaultExtensions.getSoapFaultSubcodes());
axisBindingFault.setProperty(WSDL2Constants.ATTR_WSOAP_HEADER, createSoapHeaders(soapBindingFaultExtensions.getSoapHeaders()));
axisBindingFault.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE, createSoapModules(soapBindingFaultExtensions.getSoapModules()));
axisBinding.addFault(axisBindingFault);
}
// Capture all the binding operation specific properties
BindingOperation[] bindingOperations = binding.getBindingOperations();
for (int i = 0; i < bindingOperations.length; i++) {
BindingOperation bindingOperation = bindingOperations[i];
AxisBindingOperation axisBindingOperation = new AxisBindingOperation();
InterfaceOperation interfaceOperation = serviceInterface.getFromAllInterfaceOperations(((BindingOperationElement) bindingOperation).getRef());
AxisOperation axisOperation = axisService.getOperation(interfaceOperation.getName());
axisBindingOperation.setAxisOperation(axisOperation);
axisBindingOperation.setParent(axisBinding);
axisBindingOperation.setName(axisOperation.getName());
addDocumentation(axisBindingOperation, bindingOperation.toElement());
SOAPBindingOperationExtensions soapBindingOperationExtensions;
try {
soapBindingOperationExtensions = ((SOAPBindingOperationExtensions) bindingOperation.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_SOAP)));
} catch (URISyntaxException e) {
throw new AxisFault("Soap Binding Extention not found");
}
URI soapAction = soapBindingOperationExtensions.getSoapAction();
if (soapAction != null && !"\"\"".equals(soapAction.toString())) {
axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_ACTION, soapAction.toString());
}
axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE, createSoapModules(soapBindingOperationExtensions.getSoapModules()));
URI soapMep = soapBindingOperationExtensions.getSoapMep();
if (soapMep != null) {
axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_MEP, soapMep.toString());
}
HTTPLocation httpLocation = soapBindingOperationExtensions.getHttpLocation();
// If httpLocation is not null we should extract a constant part from it and add its value and the
// corresponding AxisOperation to a map in order to dispatch rest messages. If httpLocation is null we add
// the operation name into this map.
String httpLocationString = null;
if (httpLocation != null) {
String httpLocationTemplete = httpLocation.getOriginalLocation();
axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocationTemplete);
httpLocationString = WSDLUtil.getConstantFromHTTPLocation(httpLocationTemplete, HTTPConstants.HEADER_POST);
}
if (httpLocationString != null) {
// this map is used to dispatch operation based on request URI , in the HTTPLocationBasedDispatcher
httpLocationTable.put(httpLocationString, axisOperation);
}
axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING, soapBindingOperationExtensions.getHttpContentEncodingDefault());
axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, soapBindingOperationExtensions.getHttpQueryParameterSeparator());
BindingMessageReference[] bindingMessageReferences = bindingOperation.getBindingMessageReferences();
for (int j = 0; j < bindingMessageReferences.length; j++) {
BindingMessageReference bindingMessageReference = bindingMessageReferences[j];
AxisBindingMessage axisBindingMessage = new AxisBindingMessage();
axisBindingMessage.setParent(axisBindingOperation);
addDocumentation(axisBindingMessage, bindingMessageReference.toElement());
AxisMessage axisMessage = axisOperation.getMessage(bindingMessageReference.getInterfaceMessageReference().getMessageLabel().toString());
axisBindingMessage.setAxisMessage(axisMessage);
axisBindingMessage.setName(axisMessage.getName());
axisBindingMessage.setDirection(axisMessage.getDirection());
SOAPBindingMessageReferenceExtensions soapBindingMessageReferenceExtensions;
try {
soapBindingMessageReferenceExtensions = (SOAPBindingMessageReferenceExtensions) bindingMessageReference.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_SOAP));
} catch (URISyntaxException e) {
throw new AxisFault("Soap Binding Extention not found");
}
axisBindingMessage.setProperty(WSDL2Constants.ATTR_WHTTP_HEADER, createHttpHeaders(soapBindingMessageReferenceExtensions.getHttpHeaders()));
axisBindingMessage.setProperty(WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING, soapBindingMessageReferenceExtensions.getHttpContentEncoding());
axisBindingMessage.setProperty(WSDL2Constants.ATTR_WSOAP_HEADER, createSoapHeaders(soapBindingMessageReferenceExtensions.getSoapHeaders()));
axisBindingMessage.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE, createSoapModules(soapBindingMessageReferenceExtensions.getSoapModules()));
axisBindingOperation.addChild(axisMessage.getDirection(), axisBindingMessage);
}
BindingFaultReference[] bindingFaultReferences = bindingOperation.getBindingFaultReferences();
for (int j = 0; j < bindingFaultReferences.length; j++) {
BindingFaultReference bindingFaultReference = bindingFaultReferences[j];
AxisBindingMessage axisBindingMessageFault = new AxisBindingMessage();
addDocumentation(axisBindingMessageFault, bindingFaultReference.toElement());
axisBindingMessageFault.setParent(axisBindingOperation);
axisBindingMessageFault.setFault(true);
axisBindingMessageFault.setName(bindingFaultReference.getInterfaceFaultReference().getInterfaceFault().getName().getLocalPart());
SOAPBindingFaultReferenceExtensions soapBindingFaultReferenceExtensions;
try {
soapBindingFaultReferenceExtensions = (SOAPBindingFaultReferenceExtensions) bindingFaultReference.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_SOAP));
} catch (URISyntaxException e) {
throw new AxisFault("Soap Binding Extention not found");
}
axisBindingMessageFault.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE, createSoapModules(soapBindingFaultReferenceExtensions.getSoapModules()));
axisBindingOperation.addFault(axisBindingMessageFault);
}
axisBinding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
axisBinding.addChild(axisBindingOperation.getName(), axisBindingOperation);
}
}
Aggregations