@SuppressWarnings("unchecked")
public WsdlInterface importBinding(WsdlProject project, WsdlContext wsdlContext, Binding binding) throws Exception {
String name = project.getSettings().getBoolean(WsdlSettings.NAME_WITH_BINDING) ? binding.getQName()
.getLocalPart() : binding.getPortType().getQName().getLocalPart();
WsdlInterface iface = (WsdlInterface) project.addNewInterface(name, WsdlInterfaceFactory.WSDL_TYPE);
iface.setBindingName(binding.getQName());
iface.setSoapVersion(SoapVersion.Soap11);
String[] endpoints = WsdlUtils.getEndpointsForBinding(wsdlContext.getDefinition(), binding);
for (int i = 0; i < endpoints.length; i++) {
log.info("importing endpoint " + endpoints[i]);
iface.addEndpoint(endpoints[i]);
}
List<BindingOperation> list = binding.getBindingOperations();
Collections.sort(list, new BindingOperationComparator());
for (Iterator<BindingOperation> iter = list.iterator(); iter.hasNext(); ) {
BindingOperation operation = iter.next();
// sanity check
if (operation.getOperation() == null || operation.getOperation().isUndefined()) {
log.error("BindingOperation [" + operation.getName() + "] is missing or referring to an invalid operation");
} else {
log.info("importing operation " + operation.getName());
iface.addNewOperation(operation);
}
}
// PolicyUtils.getPolicies(wsdlContext);
initWsAddressing(binding, iface, wsdlContext.getDefinition());