325N/A/*
325N/A * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A */
325N/A
325N/Apackage javax.xml.ws;
325N/A
325N/Aimport javax.xml.bind.annotation.XmlTransient;
325N/Aimport javax.xml.transform.Result;
325N/Aimport javax.xml.transform.Source;
325N/Aimport javax.xml.transform.stream.StreamResult;
325N/Aimport javax.xml.ws.spi.Provider;
325N/Aimport javax.xml.ws.wsaddressing.W3CEndpointReference;
325N/Aimport java.io.StringWriter;
325N/A
325N/A/**
325N/A * This class represents an WS-Addressing EndpointReference
325N/A * which is a remote reference to a web service endpoint.
325N/A * See <a href="http://www.w3.org/TR/2006/REC-ws-addr-core-20060509/">
325N/A * Web Services Addressing 1.0 - Core</a>
325N/A * for more information on WS-Addressing EndpointReferences.
325N/A * <p>
325N/A * This class is immutable as the typical web service developer
325N/A * need not be concerned with its contents. The web service
325N/A * developer should use this class strictly as a mechanism to
325N/A * reference a remote web service endpoint. See the {@link Service} APIs
325N/A * that clients can use to that utilize an <code>EndpointReference</code>.
325N/A * See the {@link javax.xml.ws.Endpoint}, and
325N/A * {@link javax.xml.ws.BindingProvider} APIs on how
325N/A * <code>EndpointReferences</code> can be created for published
325N/A * endpoints.
325N/A * <p>
325N/A * Concrete implementations of this class will represent
325N/A * an <code>EndpointReference</code> for a particular version of Addressing.
325N/A * For example the {@link W3CEndpointReference} is for use
325N/A * with W3C Web Services Addressing 1.0 - Core Recommendation.
325N/A * If JAX-WS implementors need to support different versions
325N/A * of addressing, they should write their own
325N/A * <code>EndpointReference</code> subclass for that version.
325N/A * This will allow a JAX-WS implementation to create
325N/A * a vendor specific <code>EndpointReferences</code> that the
325N/A * vendor can use to flag a different version of
325N/A * addressing.
325N/A * <p>
325N/A * Web service developers that wish to pass or return
325N/A * <code>EndpointReference</code> in Java methods in an
325N/A * SEI should use
325N/A * concrete instances of an <code>EndpointReference</code> such
325N/A * as the <code>W3CEndpointReference</code>. This way the
325N/A * schema mapped from the SEI will be more descriptive of the
325N/A * type of endpoint reference being passed.
325N/A * <p>
325N/A * JAX-WS implementors are expected to extract the XML infoset
325N/A * from an <CODE>EndpointReferece</CODE> using the
325N/A * <code>{@link EndpointReference#writeTo}</code>
325N/A * method.
325N/A * <p>
325N/A * JAXB will bind this class to xs:anyType. If a better binding
325N/A * is desired, web services developers should use a concrete
325N/A * subclass such as {@link W3CEndpointReference}.
325N/A *
325N/A * @see W3CEndpointReference
325N/A * @see Service
325N/A * @since JAX-WS 2.1
325N/A */
325N/A@XmlTransient // to treat this class like Object as far as databinding is concerned (proposed JAXB 2.1 feature)
325N/Apublic abstract class EndpointReference {
325N/A //
325N/A //Default constructor to be only called by derived types.
325N/A //
325N/A protected EndpointReference(){}
325N/A
325N/A /**
325N/A * Factory method to read an EndpointReference from the infoset contained in
325N/A * <code>eprInfoset</code>. This method delegates to the vendor specific
325N/A * implementation of the {@link javax.xml.ws.spi.Provider#readEndpointReference} method.
325N/A *
325N/A * @param eprInfoset The <code>EndpointReference</code> infoset to be unmarshalled
325N/A *
325N/A * @return the EndpointReference unmarshalled from <code>eprInfoset</code>
325N/A * never <code>null</code>
325N/A * @throws WebServiceException
325N/A * if an error occurs while creating the
325N/A * <code>EndpointReference</code> from the <CODE>eprInfoset</CODE>
325N/A * @throws java.lang.IllegalArgumentException
325N/A * if the <code>null</code> <code>eprInfoset</code> value is given.
325N/A */
325N/A public static EndpointReference readFrom(Source eprInfoset) {
325N/A return Provider.provider().readEndpointReference(eprInfoset);
325N/A }
325N/A
325N/A /**
325N/A * write this <code>EndpointReference</code> to the specified infoset format
325N/A *
325N/A * @param result for writing infoset
325N/A * @throws WebServiceException
325N/A * if there is an error writing the
325N/A * <code>EndpointReference</code> to the specified <code>result</code>.
325N/A *
325N/A * @throws java.lang.IllegalArgumentException
325N/A * If the <code>null</code> <code>result</code> value is given.
325N/A */
325N/A public abstract void writeTo(Result result);
325N/A
325N/A
325N/A /**
325N/A * The <code>getPort</code> method returns a proxy. If there
325N/A * are any reference parameters in the
325N/A * <code>EndpointReference</code> instance, then those reference
325N/A * parameters MUST appear as SOAP headers, indicating them to be
325N/A * reference parameters, on all messages sent to the endpoint.
325N/A * The parameter <code>serviceEndpointInterface</code> specifies
325N/A * the service endpoint interface that is supported by the
325N/A * returned proxy.
325N/A * The <code>EndpointReference</code> instance specifies the
325N/A * endpoint that will be invoked by the returned proxy.
325N/A * In the implementation of this method, the JAX-WS
325N/A * runtime system takes the responsibility of selecting a protocol
325N/A * binding (and a port) and configuring the proxy accordingly from
325N/A * the WSDL Metadata from this <code>EndpointReference</code> or from
325N/A * annotations on the <code>serviceEndpointInterface</code>. For this method
325N/A * to successfully return a proxy, WSDL metadata MUST be available and the
325N/A * <code>EndpointReference</code> instance MUST contain an implementation understood
325N/A * <code>serviceName</code> metadata.
325N/A * <p>
325N/A * Because this port is not created from a <code>Service</code> object, handlers
325N/A * will not automatically be configured, and the <code>HandlerResolver</code>
325N/A * and <code>Executor</code> cannot be get or set for this port. The
325N/A * <code>BindingProvider().getBinding().setHandlerChain()</code>
325N/A * method can be used to manually configure handlers for this port.
325N/A *
325N/A *
325N/A * @param serviceEndpointInterface Service endpoint interface
325N/A * @param features An array of <code>WebServiceFeatures</code> to configure on the
325N/A * proxy. Supported features not in the <code>features
325N/A * </code> parameter will have their default values.
325N/A * @return Object Proxy instance that supports the
325N/A * specified service endpoint interface
325N/A * @throws WebServiceException
325N/A * <UL>
325N/A * <LI>If there is an error during creation
325N/A * of the proxy
325N/A * <LI>If there is any missing WSDL metadata
325N/A * as required by this method
325N/A * <LI>If this
325N/A * <code>endpointReference</code>
325N/A * is invalid
325N/A * <LI>If an illegal
325N/A * <code>serviceEndpointInterface</code>
325N/A * is specified
325N/A * <LI>If a feature is enabled that is not compatible with
325N/A * this port or is unsupported.
325N/A * </UL>
325N/A *
325N/A * @see java.lang.reflect.Proxy
325N/A * @see WebServiceFeature
325N/A **/
325N/A public <T> T getPort(Class<T> serviceEndpointInterface,
325N/A WebServiceFeature... features) {
325N/A return Provider.provider().getPort(this, serviceEndpointInterface,
325N/A features);
325N/A }
325N/A
325N/A /**
325N/A * Displays EPR infoset for debugging convenience.
325N/A */
325N/A public String toString() {
325N/A StringWriter w = new StringWriter();
325N/A writeTo(new StreamResult(w));
325N/A return w.toString();
325N/A }
325N/A}