* Gets the port name of the provided endpoint reference.
* @param ref the endpoint reference.
* @return the port name.
*/
public static String getPortName(EndpointReferenceType ref) {
MetadataType metadata = ref.getMetadata();
if (metadata != null) {
for (Object obj : metadata.getAny()) {
if (obj instanceof Element) {
Node node = (Element)obj;
if (node.getNamespaceURI().equals("http://www.w3.org/2005/08/addressing/wsdl")
&& node.getNodeName().contains("ServiceName")) {
return node.getAttributes().getNamedItem("EndpointName").getTextContent();