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:
AddressingVersion.anonymousEpr
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WSEndpointReference.EPRExtension
Represents an extensibility element inside an EndpointReferenceclass
WSEndpointReference.Metadata
Parses the Metadata in an EPR and provides convenience methods to access the metadata.
-
Constructor Summary
Constructors Constructor Description WSEndpointReference(XMLStreamBuffer infoset, AddressingVersion version)
Creates aWSEndpointReference
that wraps a given infoset.WSEndpointReference(AddressingVersion version, String address, QName service, QName port, QName portType, List<Element> metadata, String wsdlAddress, String wsdlTargetNamepsace, List<Element> referenceParameters, List<Element> elements, Map<QName,String> attributes)
Creates an EPR from individual components.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(AddressingVersion version, String address, QName service, QName port, QName portType, List<Element> metadata, String wsdlAddress, List<Element> referenceParameters, Collection<WSEndpointReference.EPRExtension> extns, Map<QName,String> attributes)
Creates an EPR from individual components.WSEndpointReference(jakarta.xml.ws.EndpointReference epr)
Creates from the spec version ofEndpointReference
.WSEndpointReference(jakarta.xml.ws.EndpointReference epr, AddressingVersion version)
Creates from the spec version ofEndpointReference
.WSEndpointReference(InputStream infoset, AddressingVersion version)
Creates aWSEndpointReference
by parsing an infoset.WSEndpointReference(String address, AddressingVersion version)
Creates aWSEndpointReference
that only has an address.WSEndpointReference(URI address, AddressingVersion version)
WSEndpointReference(URL address, AddressingVersion version)
WSEndpointReference(XMLStreamReader in, AddressingVersion version)
Creates aWSEndpointReference
from the given infoset.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addReferenceParameters(HeaderList headers)
Copies all the reference parameters from the givenHeaderList
to this EPRvoid
addReferenceParametersToList(HeaderList outbound)
Deprecated.- use addReferenceParametersToList(MessageHeaders)void
addReferenceParametersToList(MessageHeaders outbound)
Copies all the reference parameters in this EPR as headers to the givenMessageHeaders
.Source
asSource(String localName)
Returns aSource
that represents this EPR.static WSEndpointReference
create(jakarta.xml.ws.EndpointReference epr)
Converts fromEndpointReference
.jakarta.xml.ws.Dispatch<Object>
createDispatch(jakarta.xml.ws.Service jaxwsService, jakarta.xml.bind.JAXBContext context, jakarta.xml.ws.Service.Mode mode, jakarta.xml.ws.WebServiceFeature... features)
Creates aDispatch
that can be used to talk to this EPR.<T> jakarta.xml.ws.Dispatch<T>
createDispatch(jakarta.xml.ws.Service jaxwsService, Class<T> type, jakarta.xml.ws.Service.Mode mode, jakarta.xml.ws.WebServiceFeature... features)
Creates aDispatch
that can be used to talk to this EPR.Header
createHeader(QName rootTagName)
Returns aHeader
that wraps thisWSEndpointReference
.WSEndpointReference
createWithAddress(String newAddress)
Creates a newWSEndpointReference
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.EPRExtension
getEPRExtension(QName extnQName)
Returns the first extensibility element inside EPR root element with input QName.Collection<WSEndpointReference.EPRExtension>
getEPRExtensions()
WSEndpointReference.Metadata
getMetaData()
Parses the metadata inside this EPR and obtains it in a easy-to-process form.QName
getName()
Gets the QName of the EndpointReference element.<T> T
getPort(jakarta.xml.ws.Service jaxwsService, Class<T> serviceEndpointInterface, jakarta.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 theaddress
.boolean
isNone()
XMLStreamReader
read(String localName)
Reads this EPR asXMLStreamReader
.jakarta.xml.ws.EndpointReference
toSpec()
Convert the EPR to the spec version.<T extends jakarta.xml.ws.EndpointReference>
TtoSpec(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, XMLStreamWriter w)
Writes this EPR into the given writer.void
writeTo(String localName, ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment)
Writes this EPR to the givenContentHandler
.
-
-
-
Constructor Detail
-
WSEndpointReference
public WSEndpointReference(jakarta.xml.ws.EndpointReference epr, AddressingVersion version)
Creates from the spec version ofEndpointReference
.This method performs the data conversion, so it's slow. Do not use this method in a performance critical path.
-
WSEndpointReference
public WSEndpointReference(jakarta.xml.ws.EndpointReference epr)
Creates from the spec version ofEndpointReference
.This method performs the data conversion, so it's slow. Do not use this method in a performance critical path.
-
WSEndpointReference
public WSEndpointReference(XMLStreamBuffer infoset, AddressingVersion version)
Creates aWSEndpointReference
that wraps a given infoset.
-
WSEndpointReference
public WSEndpointReference(InputStream infoset, AddressingVersion version) throws XMLStreamException
Creates aWSEndpointReference
by parsing an infoset.- Throws:
XMLStreamException
-
WSEndpointReference
public WSEndpointReference(XMLStreamReader in, AddressingVersion version) throws XMLStreamException
Creates aWSEndpointReference
from the given infoset. TheXMLStreamReader
must point to either a document or an element.- Throws:
XMLStreamException
-
WSEndpointReference
public WSEndpointReference(URL address, AddressingVersion version)
-
WSEndpointReference
public WSEndpointReference(URI address, AddressingVersion version)
-
WSEndpointReference
public WSEndpointReference(String address, AddressingVersion version)
Creates aWSEndpointReference
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.
-
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, @Nullable Collection<WSEndpointReference.EPRExtension> extns, @Nullable Map<QName,String> attributes)
Creates an EPR from individual components.This version takes various information about metadata, and creates an EPR that has the necessary embedded WSDL.
-
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 String wsdlTargetNamepsace, @Nullable List<Element> referenceParameters, @Nullable List<Element> elements, @Nullable Map<QName,String> attributes)
Creates an EPR from individual components.This version takes various information about metadata, and creates an EPR that has the necessary embedded WSDL.
- Since:
- JAX-WS 2.2
-
-
Method Detail
-
create
@Nullable public static WSEndpointReference create(@Nullable jakarta.xml.ws.EndpointReference epr)
Converts fromEndpointReference
. This handles nullEndpointReference
correctly. CallWSEndpointReference(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 newWSEndpointReference
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 jakarta.xml.ws.EndpointReference toSpec()
Convert the EPR to the spec version. The actual type ofEndpointReference
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 thethe 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 aDispatch
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 aDispatch
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 theaddress
.
-
isNone
public boolean isNone()
-
read
public XMLStreamReader read(@NotNull String localName) throws XMLStreamException
Reads this EPR asXMLStreamReader
.- Parameters:
localName
- EPR uses a different root tag name depending on the context. The returnedXMLStreamReader
will use the given local name for the root element name.- Throws:
XMLStreamException
-
asSource
public Source asSource(@NotNull String localName)
Returns aSource
that represents this EPR.- Parameters:
localName
- EPR uses a different root tag name depending on the context. The returnedSource
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 givenContentHandler
.- Parameters:
localName
- EPR uses a different root tag name depending on the context. The returnedSource
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 returnedSource
will use the given local name- Throws:
XMLStreamException
-
createHeader
public Header createHeader(QName rootTagName)
Returns aHeader
that wraps thisWSEndpointReference
.The returned header is immutable too, and can be reused with many
Message
s.- Parameters:
rootTagName
- The header tag name to be used, such as <ReplyTo> or <FaultTo>. (It's bit ugly that this method takesQName
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 givenHeaderList
.
-
addReferenceParametersToList
public void addReferenceParametersToList(MessageHeaders outbound)
Copies all the reference parameters in this EPR as headers to the givenMessageHeaders
.
-
addReferenceParameters
public void addReferenceParameters(HeaderList headers)
Copies all the reference parameters from the givenHeaderList
to this EPR
-
toString
public String toString()
Dumps the EPR infoset in a human-readable string.
-
getName
public QName getName()
Gets the QName of the EndpointReference element.- Specified by:
getName
in interfaceWSDLExtension
- 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".
-
-