/** * Parses the contents of the {@code AppliesTo} element and returns the address the uniquely * identify the service provider. * * @param appliesTo the {@code AppliesTo} instance to be parsed. * @return the address of the service provider. */ public static String parseAppliesTo(AppliesTo appliesTo) { EndpointReferenceType reference = null; for (Object obj : appliesTo.getAny()) { if (obj instanceof EndpointReferenceType) reference = (EndpointReferenceType) obj; else if (obj instanceof JAXBElement) { JAXBElement<?> element = (JAXBElement<?>) obj; if (element.getName().getLocalPart().equalsIgnoreCase("EndpointReference")) reference = (EndpointReferenceType) element.getValue(); } if (reference != null && reference.getAddress() != null) return reference.getAddress().getValue(); } return null; }
public void write(EndpointReferenceType endpointReference) throws ProcessingException { StaxUtil.writeStartElement(writer, WSA_PREFIX, ENDPOINT_REFERENCE, WSA_NS); StaxUtil.writeNameSpace(writer, WSA_PREFIX, WSA_NS); AttributedURIType attributedURI = endpointReference.getAddress(); if (attributedURI != null) { String value = attributedURI.getValue(); StaxUtil.writeStartElement(writer, WSA_PREFIX, ADDRESS, WSA_NS); StaxUtil.writeCharacters(writer, value); StaxUtil.writeEndElement(writer); } StaxUtil.writeEndElement(writer); StaxUtil.flush(writer); }