}
// add port refs
final Map<QName, PortRefMetaData> portsByQName = new HashMap<QName, PortRefMetaData>();
for (final PortRefData portRef : serviceRef.getPortRefs()) {
final PortRefMetaData portRefMetaData = new PortRefMetaData();
portRefMetaData.setQName(portRef.getQName());
portRefMetaData.setServiceEndpointInterface(portRef.getServiceEndpointInterface());
portRefMetaData.setEnableMtom(portRef.isEnableMtom());
portRefMetaData.getProperties().putAll(portRef.getProperties());
portRefMetaData.getAddresses().addAll(portRef.getAddresses());
if (portRef.getQName() != null) {
portsByQName.put(portRef.getQName(), portRefMetaData);
}
serviceMetaData.getPortRefs().add(portRefMetaData);
}
// add PortRefMetaData for any portAddress not added above
for (final PortAddress portAddress : portAddresses) {
PortRefMetaData portRefMetaData = portsByQName.get(portAddress.getPortQName());
if (portRefMetaData == null) {
portRefMetaData = new PortRefMetaData();
portRefMetaData.setQName(portAddress.getPortQName());
portRefMetaData.setServiceEndpointInterface(portAddress.getServiceEndpointInterface());
portRefMetaData.getAddresses().add(portAddress.getAddress());
serviceMetaData.getPortRefs().add(portRefMetaData);
} else {
portRefMetaData.getAddresses().add(portAddress.getAddress());
if (portRefMetaData.getServiceEndpointInterface() == null) {
portRefMetaData.setServiceEndpointInterface(portAddress.getServiceEndpointInterface());
}
}
}
res.setResponseCode(ResponseCodes.JNDI_WEBSERVICE);