Class WSEndpointReference

java.lang.Object
com.sun.xml.ws.api.addressing.WSEndpointReference
All Implemented Interfaces:
WSDLExtension

public final class WSEndpointReference extends Object implements WSDLExtension
Internal representation of the EPR.

Instances of this class are immutable and thread-safe.

Author:
Kohsuke Kawaguchi, Rama Pulavarthi
See Also:
  • Constructor Details

  • Method Details

    • create

      @Nullable public static WSEndpointReference create(@Nullable jakarta.xml.ws.EndpointReference epr)
      Converts from EndpointReference. This handles null EndpointReference correctly. Call WSEndpointReference(EndpointReference) directly if you know it's not null.
    • createWithAddress

      @NotNull public WSEndpointReference createWithAddress(@NotNull URI newAddress)
      See Also:
    • createWithAddress

      @NotNull public WSEndpointReference createWithAddress(@NotNull URL newAddress)
      See Also:
    • createWithAddress

      @NotNull public WSEndpointReference createWithAddress(@NotNull String newAddress)
      Creates a new WSEndpointReference by replacing the address of this EPR to the new one.

      The following example shows how you can use this to force an HTTPS EPR, when the endpoint can serve both HTTP and HTTPS requests.

       if(epr.getAddress().startsWith("http:"))
         epr = epr.createWithAddress("https:"+epr.getAddress().substring(5));
       
      Parameters:
      newAddress - This is a complete URL to be written inside <Address> element of the EPR, such as "http://foo.bar/abc/def"
    • toSpec

      @NotNull public jakarta.xml.ws.EndpointReference toSpec()
      Convert the EPR to the spec version. The actual type of EndpointReference to be returned depends on which version of the addressing spec this EPR conforms to.
      Throws:
      jakarta.xml.ws.WebServiceException - if the conversion fails, which can happen if the EPR contains invalid infoset (wrong namespace URI, etc.)
    • toSpec

      @NotNull public <T extends jakarta.xml.ws.EndpointReference> T toSpec(Class<T> clazz)
      Converts the EPR to the specified spec version. If the the addressing version in use and the given class is different, then this may involve version conversion.
    • getPort

      @NotNull public <T> T getPort(@NotNull jakarta.xml.ws.Service jaxwsService, @NotNull Class<T> serviceEndpointInterface, jakarta.xml.ws.WebServiceFeature... features)
      Creates a proxy that can be used to talk to this EPR.

      All the normal WS-Addressing processing happens automatically, such as setting the endpoint address to the address, and sending the reference parameters associated with this EPR as headers, etc.

    • createDispatch

      @NotNull public <T> jakarta.xml.ws.Dispatch<T> createDispatch(@NotNull jakarta.xml.ws.Service jaxwsService, @NotNull Class<T> type, @NotNull jakarta.xml.ws.Service.Mode mode, jakarta.xml.ws.WebServiceFeature... features)
      Creates a Dispatch that can be used to talk to this EPR.

      All the normal WS-Addressing processing happens automatically, such as setting the endpoint address to the address, and sending the reference parameters associated with this EPR as headers, etc.

    • createDispatch

      @NotNull public jakarta.xml.ws.Dispatch<Object> createDispatch(@NotNull jakarta.xml.ws.Service jaxwsService, @NotNull jakarta.xml.bind.JAXBContext context, @NotNull jakarta.xml.ws.Service.Mode mode, jakarta.xml.ws.WebServiceFeature... features)
      Creates a Dispatch that can be used to talk to this EPR.

      All the normal WS-Addressing processing happens automatically, such as setting the endpoint address to the address, and sending the reference parameters associated with this EPR as headers, etc.

    • getVersion

      @NotNull public AddressingVersion getVersion()
      Gets the addressing version of this EPR.
    • getAddress

      @NotNull public String getAddress()
      The value of the <wsa:address> header.
    • isAnonymous

      public boolean isAnonymous()
      Returns true if this has anonymous URI as the address.
    • isNone

      public boolean isNone()
      Returns true if this has none URI as the address.
    • read

      public XMLStreamReader read(@NotNull String localName) throws XMLStreamException
      Reads this EPR as XMLStreamReader.
      Parameters:
      localName - EPR uses a different root tag name depending on the context. The returned XMLStreamReader will use the given local name for the root element name.
      Throws:
      XMLStreamException
    • asSource

      public Source asSource(@NotNull String localName)
      Returns a Source that represents this EPR.
      Parameters:
      localName - EPR uses a different root tag name depending on the context. The returned Source will use the given local name for the root element name.
    • writeTo

      public void writeTo(@NotNull String localName, ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException
      Writes this EPR to the given ContentHandler.
      Parameters:
      localName - EPR uses a different root tag name depending on the context. The returned Source will use the given local name for the root element name.
      fragment - If true, generate a fragment SAX events without start/endDocument callbacks. If false, generate a full XML document event.
      Throws:
      SAXException
    • writeTo

      public void writeTo(@NotNull String localName, @NotNull XMLStreamWriter w) throws XMLStreamException
      Writes this EPR into the given writer.
      Parameters:
      localName - EPR uses a different root tag name depending on the context. The returned Source will use the given local name
      Throws:
      XMLStreamException
    • createHeader

      public Header createHeader(QName rootTagName)
      Returns a Header that wraps this WSEndpointReference.

      The returned header is immutable too, and can be reused with many Messages.

      Parameters:
      rootTagName - The header tag name to be used, such as <ReplyTo> or <FaultTo>. (It's bit ugly that this method takes QName and not just local name, unlike other methods. If it's making the caller's life miserable, then we can talk.)
    • addReferenceParametersToList

      public void addReferenceParametersToList(HeaderList outbound)
      Deprecated.
      - use addReferenceParametersToList(MessageHeaders)
      Copies all the reference parameters in this EPR as headers to the given HeaderList.
    • addReferenceParametersToList

      public void addReferenceParametersToList(MessageHeaders outbound)
      Copies all the reference parameters in this EPR as headers to the given MessageHeaders.
    • addReferenceParameters

      public void addReferenceParameters(HeaderList headers)
      Copies all the reference parameters from the given HeaderList to this EPR
    • toString

      public String toString()
      Dumps the EPR infoset in a human-readable string.
      Overrides:
      toString in class Object
    • getName

      public QName getName()
      Gets the QName of the EndpointReference element.
      Specified by:
      getName in interface WSDLExtension
      Returns:
    • getEPRExtension

      @Nullable public WSEndpointReference.EPRExtension getEPRExtension(QName extnQName) throws XMLStreamException
      Returns the first extensibility element inside EPR root element with input QName.
      Throws:
      XMLStreamException
    • getEPRExtensions

      @NotNull public Collection<WSEndpointReference.EPRExtension> getEPRExtensions() throws XMLStreamException
      Throws:
      XMLStreamException
    • getMetaData

      @NotNull public WSEndpointReference.Metadata getMetaData()
      Parses the metadata inside this EPR and obtains it in a easy-to-process form.

      See WSEndpointReference.Metadata class for what's avaliable as "metadata".