com.sun.xml.ws.api.addressing
Class WSEndpointReference

java.lang.Object
  extended by com.sun.xml.ws.api.addressing.WSEndpointReference

public final class WSEndpointReference
extends Object

Internal representation of the EPR.

Instances of this class are immutable and thread-safe.

See Also:
AddressingVersion.anonymousEpr

Nested Class Summary
 class WSEndpointReference.Metadata
          Parses the Metadata in an EPR and provides convenience methods to access the metadata.
(package private)  class WSEndpointReference.SAXBufferProcessorImpl
          Filtering SAXBufferProcessor that replaces the root tag name.
 
Constructor Summary
WSEndpointReference(AddressingVersion version, String address, QName service, QName port, QName portType, List<Element> metadata, String wsdlAddress, List<Element> referenceParameters)
          Creates an EPR from individual components.
WSEndpointReference(javax.xml.ws.EndpointReference epr)
          Creates from the spec version of EndpointReference.
WSEndpointReference(javax.xml.ws.EndpointReference epr, AddressingVersion version)
          Creates from the spec version of EndpointReference.
WSEndpointReference(InputStream infoset, AddressingVersion version)
          Creates a WSEndpointReference by parsing an infoset.
WSEndpointReference(String address, AddressingVersion version)
          Creates a WSEndpointReference that only has an address.
WSEndpointReference(URI address, AddressingVersion version)
           
WSEndpointReference(URL address, AddressingVersion version)
           
WSEndpointReference(com.sun.xml.stream.buffer.XMLStreamBuffer infoset, AddressingVersion version)
          Creates a WSEndpointReference that wraps a given infoset.
WSEndpointReference(javax.xml.stream.XMLStreamReader in, AddressingVersion version)
          Creates a WSEndpointReference from the given infoset.
 
Method Summary
 void addReferenceParameters(HeaderList outbound)
          Copies all the reference parameters in this EPR as headers to the given HeaderList.
 Source asSource(String localName)
          Returns a Source that represents this EPR.
static WSEndpointReference create(javax.xml.ws.EndpointReference epr)
          Converts from EndpointReference.
<T> javax.xml.ws.Dispatch<T>
createDispatch(javax.xml.ws.Service jaxwsService, Class<T> type, javax.xml.ws.Service.Mode mode, javax.xml.ws.WebServiceFeature... features)
          Creates a Dispatch that can be used to talk to this EPR.
 javax.xml.ws.Dispatch<Object> createDispatch(javax.xml.ws.Service jaxwsService, JAXBContext context, javax.xml.ws.Service.Mode mode, javax.xml.ws.WebServiceFeature... features)
          Creates a Dispatch that can be used to talk to this EPR.
 Header createHeader(QName rootTagName)
          Returns a Header that wraps this WSEndpointReference.
 WSEndpointReference createWithAddress(String newAddress)
          Creates a new WSEndpointReference by replacing the address of this EPR to the new one.
 WSEndpointReference createWithAddress(URI newAddress)
           
 WSEndpointReference createWithAddress(URL newAddress)
           
 String getAddress()
          The value of the <wsa:address> header.
 WSEndpointReference.Metadata getMetaData()
          Parses the metadata inside this EPR and obtains it in a easy-to-process form.
<T> T
getPort(javax.xml.ws.Service jaxwsService, Class<T> serviceEndpointInterface, javax.xml.ws.WebServiceFeature... features)
          Creates a proxy that can be used to talk to this EPR.
 AddressingVersion getVersion()
          Gets the addressing version of this EPR.
 boolean isAnonymous()
          Returns true if this has anonymous URI as the address.
 boolean isNone()
          Returns true if this has none URI as the address.
 javax.xml.stream.XMLStreamReader read(String localName)
          Reads this EPR as XMLStreamReader.
 javax.xml.ws.EndpointReference toSpec()
          Convert the EPR to the spec version.
<T extends javax.xml.ws.EndpointReference>
T
toSpec(Class<T> clazz)
          Converts the EPR to the specified spec version.
 String toString()
          Dumps the EPR infoset in a human-readable string.
 void writeTo(String localName, ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment)
          Writes this EPR to the given ContentHandler.
 void writeTo(String localName, javax.xml.stream.XMLStreamWriter w)
          Writes this EPR into the given writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WSEndpointReference

public WSEndpointReference(javax.xml.ws.EndpointReference epr,
                           AddressingVersion version)
Creates from the spec version of EndpointReference.

This method performs the data conversion, so it's slow. Do not use this method in a performance critical path.


WSEndpointReference

public WSEndpointReference(javax.xml.ws.EndpointReference epr)
Creates from the spec version of EndpointReference.

This method performs the data conversion, so it's slow. Do not use this method in a performance critical path.


WSEndpointReference

public WSEndpointReference(com.sun.xml.stream.buffer.XMLStreamBuffer infoset,
                           AddressingVersion version)
Creates a WSEndpointReference that wraps a given infoset.


WSEndpointReference

public WSEndpointReference(InputStream infoset,
                           AddressingVersion version)
                    throws javax.xml.stream.XMLStreamException
Creates a WSEndpointReference by parsing an infoset.

Throws:
javax.xml.stream.XMLStreamException

WSEndpointReference

public WSEndpointReference(javax.xml.stream.XMLStreamReader in,
                           AddressingVersion version)
                    throws javax.xml.stream.XMLStreamException
Creates a WSEndpointReference from the given infoset. The XMLStreamReader must point to either a document or an element.

Throws:
javax.xml.stream.XMLStreamException

WSEndpointReference

public WSEndpointReference(URL address,
                           AddressingVersion version)
See Also:
WSEndpointReference(String, AddressingVersion)

WSEndpointReference

public WSEndpointReference(URI address,
                           AddressingVersion version)
See Also:
WSEndpointReference(String, AddressingVersion)

WSEndpointReference

public WSEndpointReference(String address,
                           AddressingVersion version)
Creates a WSEndpointReference that only has an address.


WSEndpointReference

public WSEndpointReference(@NotNull
                           AddressingVersion version,
                           @NotNull
                           String address,
                           @Nullable
                           QName service,
                           @Nullable
                           QName port,
                           @Nullable
                           QName portType,
                           @Nullable
                           List<Element> metadata,
                           @Nullable
                           String wsdlAddress,
                           @Nullable
                           List<Element> referenceParameters)
Creates an EPR from individual components.

This version takes various information about metadata, and creates an EPR that has the necessary embedded WSDL.

Method Detail

create

@Nullable
public static WSEndpointReference create(@Nullable
                                                  javax.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(String)

createWithAddress

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

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 <Adress> element of the EPR, such as "http://foo.bar/abc/def"

toSpec

@NotNull
public javax.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:
javax.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 javax.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
                             javax.xml.ws.Service jaxwsService,
                             @NotNull
                             Class<T> serviceEndpointInterface,
                             javax.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> javax.xml.ws.Dispatch<T> createDispatch(@NotNull
                                                           javax.xml.ws.Service jaxwsService,
                                                           @NotNull
                                                           Class<T> type,
                                                           @NotNull
                                                           javax.xml.ws.Service.Mode mode,
                                                           javax.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 javax.xml.ws.Dispatch<Object> createDispatch(@NotNull
                                                            javax.xml.ws.Service jaxwsService,
                                                            @NotNull
                                                            JAXBContext context,
                                                            @NotNull
                                                            javax.xml.ws.Service.Mode mode,
                                                            javax.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 javax.xml.stream.XMLStreamReader read(@NotNull
                                             String localName)
                                      throws javax.xml.stream.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:
javax.xml.stream.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
                    javax.xml.stream.XMLStreamWriter w)
             throws javax.xml.stream.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:
javax.xml.stream.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.)

addReferenceParameters

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


toString

public String toString()
Dumps the EPR infoset in a human-readable string.

Overrides:
toString in class Object

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".