Beispiel #1
0
  /**
   * Creates an instance of {@code AppliesTo} using the specified endpoint address.
   *
   * @param endpointURI a {@code String} representing the endpoint URI.
   * @return the constructed {@code AppliesTo} instance.
   */
  public static AppliesTo createAppliesTo(String endpointURI) {
    AttributedURIType attributedURI = new AttributedURIType();
    attributedURI.setValue(endpointURI);
    EndpointReferenceType reference = new EndpointReferenceType();
    reference.setAddress(attributedURI);
    AppliesTo appliesTo = new AppliesTo();
    appliesTo.addAny(reference);

    return appliesTo;
  }
Beispiel #2
0
  /**
   * 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;
  }