Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxws/src/share/jaxws_classes/javax/xml/ws/EndpointReference.java
38890 views
/*1* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.xml.ws;2627import javax.xml.bind.annotation.XmlTransient;28import javax.xml.transform.Result;29import javax.xml.transform.Source;30import javax.xml.transform.stream.StreamResult;31import javax.xml.ws.spi.Provider;32import javax.xml.ws.wsaddressing.W3CEndpointReference;33import java.io.StringWriter;3435/**36* This class represents an WS-Addressing EndpointReference37* which is a remote reference to a web service endpoint.38* See <a href="http://www.w3.org/TR/2006/REC-ws-addr-core-20060509/">39* Web Services Addressing 1.0 - Core</a>40* for more information on WS-Addressing EndpointReferences.41* <p>42* This class is immutable as the typical web service developer43* need not be concerned with its contents. The web service44* developer should use this class strictly as a mechanism to45* reference a remote web service endpoint. See the {@link Service} APIs46* that clients can use to that utilize an <code>EndpointReference</code>.47* See the {@link javax.xml.ws.Endpoint}, and48* {@link javax.xml.ws.BindingProvider} APIs on how49* <code>EndpointReferences</code> can be created for published50* endpoints.51* <p>52* Concrete implementations of this class will represent53* an <code>EndpointReference</code> for a particular version of Addressing.54* For example the {@link W3CEndpointReference} is for use55* with W3C Web Services Addressing 1.0 - Core Recommendation.56* If JAX-WS implementors need to support different versions57* of addressing, they should write their own58* <code>EndpointReference</code> subclass for that version.59* This will allow a JAX-WS implementation to create60* a vendor specific <code>EndpointReferences</code> that the61* vendor can use to flag a different version of62* addressing.63* <p>64* Web service developers that wish to pass or return65* <code>EndpointReference</code> in Java methods in an66* SEI should use67* concrete instances of an <code>EndpointReference</code> such68* as the <code>W3CEndpointReference</code>. This way the69* schema mapped from the SEI will be more descriptive of the70* type of endpoint reference being passed.71* <p>72* JAX-WS implementors are expected to extract the XML infoset73* from an <CODE>EndpointReferece</CODE> using the74* <code>{@link EndpointReference#writeTo}</code>75* method.76* <p>77* JAXB will bind this class to xs:anyType. If a better binding78* is desired, web services developers should use a concrete79* subclass such as {@link W3CEndpointReference}.80*81* @see W3CEndpointReference82* @see Service83* @since JAX-WS 2.184*/85@XmlTransient // to treat this class like Object as far as databinding is concerned (proposed JAXB 2.1 feature)86public abstract class EndpointReference {87//88//Default constructor to be only called by derived types.89//90protected EndpointReference(){}9192/**93* Factory method to read an EndpointReference from the infoset contained in94* <code>eprInfoset</code>. This method delegates to the vendor specific95* implementation of the {@link javax.xml.ws.spi.Provider#readEndpointReference} method.96*97* @param eprInfoset The <code>EndpointReference</code> infoset to be unmarshalled98*99* @return the EndpointReference unmarshalled from <code>eprInfoset</code>100* never <code>null</code>101* @throws WebServiceException102* if an error occurs while creating the103* <code>EndpointReference</code> from the <CODE>eprInfoset</CODE>104* @throws java.lang.IllegalArgumentException105* if the <code>null</code> <code>eprInfoset</code> value is given.106*/107public static EndpointReference readFrom(Source eprInfoset) {108return Provider.provider().readEndpointReference(eprInfoset);109}110111/**112* write this <code>EndpointReference</code> to the specified infoset format113*114* @param result for writing infoset115* @throws WebServiceException116* if there is an error writing the117* <code>EndpointReference</code> to the specified <code>result</code>.118*119* @throws java.lang.IllegalArgumentException120* If the <code>null</code> <code>result</code> value is given.121*/122public abstract void writeTo(Result result);123124125/**126* The <code>getPort</code> method returns a proxy. If there127* are any reference parameters in the128* <code>EndpointReference</code> instance, then those reference129* parameters MUST appear as SOAP headers, indicating them to be130* reference parameters, on all messages sent to the endpoint.131* The parameter <code>serviceEndpointInterface</code> specifies132* the service endpoint interface that is supported by the133* returned proxy.134* The <code>EndpointReference</code> instance specifies the135* endpoint that will be invoked by the returned proxy.136* In the implementation of this method, the JAX-WS137* runtime system takes the responsibility of selecting a protocol138* binding (and a port) and configuring the proxy accordingly from139* the WSDL Metadata from this <code>EndpointReference</code> or from140* annotations on the <code>serviceEndpointInterface</code>. For this method141* to successfully return a proxy, WSDL metadata MUST be available and the142* <code>EndpointReference</code> instance MUST contain an implementation understood143* <code>serviceName</code> metadata.144* <p>145* Because this port is not created from a <code>Service</code> object, handlers146* will not automatically be configured, and the <code>HandlerResolver</code>147* and <code>Executor</code> cannot be get or set for this port. The148* <code>BindingProvider().getBinding().setHandlerChain()</code>149* method can be used to manually configure handlers for this port.150*151*152* @param serviceEndpointInterface Service endpoint interface153* @param features An array of <code>WebServiceFeatures</code> to configure on the154* proxy. Supported features not in the <code>features155* </code> parameter will have their default values.156* @return Object Proxy instance that supports the157* specified service endpoint interface158* @throws WebServiceException159* <UL>160* <LI>If there is an error during creation161* of the proxy162* <LI>If there is any missing WSDL metadata163* as required by this method164* <LI>If this165* <code>endpointReference</code>166* is invalid167* <LI>If an illegal168* <code>serviceEndpointInterface</code>169* is specified170* <LI>If a feature is enabled that is not compatible with171* this port or is unsupported.172* </UL>173*174* @see java.lang.reflect.Proxy175* @see WebServiceFeature176**/177public <T> T getPort(Class<T> serviceEndpointInterface,178WebServiceFeature... features) {179return Provider.provider().getPort(this, serviceEndpointInterface,180features);181}182183/**184* Displays EPR infoset for debugging convenience.185*/186public String toString() {187StringWriter w = new StringWriter();188writeTo(new StreamResult(w));189return w.toString();190}191}192193194