/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Internal representation of the EPR.
*
* <p>
* Instances of this class are immutable and thread-safe.
*
* @author Kohsuke Kawaguchi
* @see AddressingVersion#anonymousEpr
*/
/**
* Version of the addressing spec.
*/
/**
* Marked Reference parameters inside this EPR.
*
* Parsed when the object is created. can be empty but never null.
* @see #parse()
*/
/**
* Creates from the spec version of {@link EndpointReference}.
*
* <p>
* This method performs the data conversion, so it's slow.
* Do not use this method in a performance critical path.
*/
try {
parse();
} catch (XMLStreamException e) {
}
}
/**
* Creates from the spec version of {@link EndpointReference}.
*
* <p>
* This method performs the data conversion, so it's slow.
* Do not use this method in a performance critical path.
*/
}
/**
* Creates a {@link WSEndpointReference} that wraps a given infoset.
*/
try {
parse();
} catch (XMLStreamException e) {
// this can never happen because XMLStreamBuffer never has underlying I/O error.
throw new AssertionError(e);
}
}
/**
* Creates a {@link WSEndpointReference} by parsing an infoset.
*/
public WSEndpointReference(InputStream infoset, AddressingVersion version) throws XMLStreamException {
}
/**
* Creates a {@link WSEndpointReference} from the given infoset.
* The {@link XMLStreamReader} must point to either a document or an element.
*/
public WSEndpointReference(XMLStreamReader in, AddressingVersion version) throws XMLStreamException {
}
/**
* @see #WSEndpointReference(String, AddressingVersion)
*/
}
/**
* @see #WSEndpointReference(String, AddressingVersion)
*/
}
/**
* Creates a {@link WSEndpointReference} that only has an address.
*/
this.referenceParameters = EMPTY_ARRAY;
}
try {
w.writeStartDocument();
w.writeEndElement();
w.writeEndElement();
w.writeEndDocument();
w.close();
return xsb;
} catch (XMLStreamException e) {
// can never happen because we are writing to XSB
throw new AssertionError(e);
}
}
/**
* Creates an EPR from individual components.
*
* <p>
* This version takes various information about metadata, and creates an EPR that has
* the necessary embedded WSDL.
*/
this(version, address, service, port, portType, metadata, wsdlAddress, null, referenceParameters, null, null);
}
/**
* Creates an EPR from individual components.
*
* <p>
* This version takes various information about metadata, and creates an EPR that has
* the necessary embedded WSDL.
*/
this(createBufferFromData(version, address, referenceParameters, service, port, portType, metadata, wsdlAddress, null, extns, attributes),
version );
}
/**
* Creates an EPR from individual components.
*
* <p>
* This version takes various information about metadata, and creates an EPR that has
* the necessary embedded WSDL.
* @since JAX-WS 2.2
*/
this(
createBufferFromData(version, address, referenceParameters, service, port, portType, metadata, wsdlAddress,wsdlTargetNamepsace, elements, attributes),
version );
}
private static XMLStreamBuffer createBufferFromData(AddressingVersion version, String address, List<Element> referenceParameters, QName service, QName port, QName portType,
List<Element> metadata, String wsdlAddress, String wsdlTargetNamespace, @Nullable List<Element> elements, @Nullable Map<QName, String> attributes) {
try {
//write extensibility elements in the EPR element
}
return writer.getXMLStreamBuffer();
} catch (XMLStreamException e) {
throw new WebServiceException(e);
}
}
private static XMLStreamBuffer createBufferFromData(AddressingVersion version, String address, List<Element> referenceParameters, QName service, QName port, QName portType,
List<Element> metadata, String wsdlAddress, String wsdlTargetNamespace, @Nullable Collection<EPRExtension> extns, @Nullable Map<QName, String> attributes) {
try {
//write extensibility elements in the EPR element
for (EPRExtension e : extns) {
XMLStreamReader r = e.readAsXMLStreamReader();
}
}
return writer.getXMLStreamBuffer();
} catch (XMLStreamException e) {
throw new WebServiceException(e);
}
}
private static void writePartialEPRInfoset(StreamWriterBufferCreator writer, AddressingVersion version, String address, List<Element> referenceParameters, QName service, QName port, QName portType,
List<Element> metadata, String wsdlAddress, String wsdlTargetNamespace, @Nullable Map<QName, String> attributes) throws XMLStreamException {
//add extensibile attributes on the EPR element
if (attributes != null) {
writer.writeAttribute(qname.getPrefix(), qname.getNamespaceURI(), qname.getLocalPart(), entry.getValue());
}
}
if (referenceParameters != null) {
for (Element e : referenceParameters)
}
switch (version) {
case W3C:
break;
case MEMBER:
if (wsdlAddress != null) {
//Inline the wsdl as extensibility element
//Write mex:Metadata wrapper
}
break;
}
}
//write wsdliLication as defined in WS-Addressing 1.0 Metadata spec
if(wsdlAddress != null)
//Write Interface info
//TODO check prefix again
portTypePrefix = "wsns";
}
}
//Write service and Port info
//TODO check prefix again
servicePrefix = "wsns";
}
}
}
}
/*
//Inline the wsdl
if (wsdlAddress != null) {
writeWsdl(writer, service, wsdlAddress);
}
*/
//Add the extra metadata Elements
}
}
/**
* @param writer the writer should be at the start of element.
* @param service Namespace URI of servcie is used as targetNamespace of wsdl if wsdlTargetNamespace is not null
* @param wsdlAddress wsdl location
* @param wsdlTargetNamespace targetnamespace of wsdl to be put in wsdliLocation
*
*/
private static void writeWsdliLocation(StreamWriterBufferCreator writer, QName service,String wsdlAddress,String wsdlTargetNamespace) throws XMLStreamException {
if(wsdlTargetNamespace != null) {
} else {
throw new WebServiceException("WSDL target Namespace cannot be resolved");
}
//writer.writeNamespace("wsdli","http://www.w3.org/ns/wsdl-instance");
}
// TODO: write ReferenceProperties
//TODO: write ReferenceParameters
//Write Interface info
//TODO check prefix again
portTypePrefix = "wsns";
}
}
//Write service and Port info
//TODO check prefix again
servicePrefix = "wsns";
}
port.getLocalPart());
}
}
}
}
private static void writeWsdl(StreamWriterBufferCreator writer, QName service, String wsdlAddress) throws XMLStreamException {
// Inline-wsdl
}
/**
* Converts from {@link EndpointReference}.
*
* This handles null {@link EndpointReference} correctly.
* Call {@link #WSEndpointReference(EndpointReference)} directly
* if you know it's not null.
*/
public static @Nullable
return new WSEndpointReference(epr);
else
return null;
}
/**
* @see #createWithAddress(String)
*/
}
/**
* @see #createWithAddress(String)
*/
}
/**
* Creates a new {@link WSEndpointReference} by replacing the address of this EPR
* to the new one.
*
* <p>
* The following example shows how you can use this to force an HTTPS EPR,
* when the endpoint can serve both HTTP and HTTPS requests.
* <pre>
* if(epr.getAddress().startsWith("http:"))
* epr = epr.createWithAddress("https:"+epr.getAddress().substring(5));
* </pre>
*
* @param newAddress
* This is a complete URL to be written inside <Adress> element of the EPR,
* such as "http://foo.bar/abc/def"
*/
private boolean inAddress = false;
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
inAddress = true;
}
if(!inAddress)
}
if(inAddress)
inAddress = false;
}
};
try {
} catch (SAXException e) {
throw new AssertionError(e); // impossible since we are writing from XSB to XSB.
}
}
/**
* Convert the EPR to the spec version. The actual type of
* {@link EndpointReference} to be returned depends on which version
* of the addressing spec this EPR conforms to.
*
* @throws WebServiceException
* if the conversion fails, which can happen if the EPR contains
* invalid infoset (wrong namespace URI, etc.)
*/
}
/**
* Converts the EPR to the specified spec version.
*
* If the {@link #getVersion() the addressing version in use} and
* the given class is different, then this may involve version conversion.
*/
}
/**
* Creates a proxy that can be used to talk to this EPR.
*
* <p>
* All the normal WS-Addressing processing happens automatically,
* such as setting the endpoint address to {@link #getAddress() the address},
* and sending the reference parameters associated with this EPR as
* headers, etc.
*/
WebServiceFeature... features) {
// TODO: implement it in a better way
}
/**
* Creates a {@link Dispatch} that can be used to talk to this EPR.
*
* <p>
* All the normal WS-Addressing processing happens automatically,
* such as setting the endpoint address to {@link #getAddress() the address},
* and sending the reference parameters associated with this EPR as
* headers, etc.
*/
WebServiceFeature... features) {
// TODO: implement it in a better way
}
/**
* Creates a {@link Dispatch} that can be used to talk to this EPR.
*
* <p>
* All the normal WS-Addressing processing happens automatically,
* such as setting the endpoint address to {@link #getAddress() the address},
* and sending the reference parameters associated with this EPR as
* headers, etc.
*/
WebServiceFeature... features) {
// TODO: implement it in a better way
}
/**
* Gets the addressing version of this EPR.
*/
return version;
}
/**
* The value of the <wsa:address> header.
*/
return address;
}
/**
* Returns true if this has anonymous URI as the {@link #getAddress() address}.
*/
public boolean isAnonymous() {
}
/**
* Returns true if this has {@link AddressingVersion#noneUri none URI}
* as the {@link #getAddress() address}.
*/
public boolean isNone() {
}
/**
* Parses inside EPR and mark all reference parameters.
*/
// TODO: validate the EPR structure.
// check for non-existent Address, that sort of things.
// parser should be either at the start element or the start document
// since often EPR doesn't have a reference parameter, create array lazily
// TODO: need a different header for member submission version
}
} else
throw new InvalidAddressingHeaderException(new QName(version.nsUri,rootLocalName),AddressingVersion.fault_duplicateAddressInEpr);
} else {
}
}
// hit to </EndpointReference> by now
this.referenceParameters = EMPTY_ARRAY;
} else {
}
throw new InvalidAddressingHeaderException(new QName(version.nsUri,rootLocalName),version.fault_missingAddressInEpr);
}
/**
* Reads this EPR as {@link XMLStreamReader}.
*
* @param localName
* EPR uses a different root tag name depending on the context.
* The returned {@link XMLStreamReader} will use the given local name
* for the root element name.
*/
return new StreamReaderBufferProcessor(infoset) {
if (_depth == 0)
}
};
}
/**
* Returns a {@link Source} that represents this EPR.
*
* @param localName
* EPR uses a different root tag name depending on the context.
* The returned {@link Source} will use the given local name
* for the root element name.
*/
}
/**
* Writes this EPR to the given {@link ContentHandler}.
*
* @param localName
* EPR uses a different root tag name depending on the context.
* The returned {@link Source} will use the given local name
* for the root element name.
* @param fragment
* If true, generate a fragment SAX events without start/endDocument callbacks.
* If false, generate a full XML document event.
*/
public void writeTo(@NotNull String localName, ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException {
}
/**
* Writes this EPR into the given writer.
*
* @param localName
* EPR uses a different root tag name depending on the context.
* The returned {@link Source} will use the given local name
*/
public void writeTo(final @NotNull String localName, @NotNull XMLStreamWriter w) throws XMLStreamException {
private boolean root=true;
public void writeStartDocument() throws XMLStreamException {
}
}
}
public void writeEndDocument() throws XMLStreamException {
}
if(root) {
root = false;
return localName;
}
return ln;
}
}
}
public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
}
},true/*write as fragment*/);
}
/**
* Returns a {@link Header} that wraps this {@link WSEndpointReference}.
*
* <p>
* The returned header is immutable too, and can be reused with
* many {@link Message}s.
*
* @param rootTagName
* The header tag name to be used, such as <ReplyTo> or <FaultTo>.
* (It's bit ugly that this method takes {@link QName} and not just local name,
* unlike other methods. If it's making the caller's life miserable, then
* we can talk.)
*/
return new EPRHeader(rootTagName,this);
}
/**
* Copies all the reference parameters in this EPR as headers
* to the given {@link HeaderList}.
*/
}
}
/**
* Dumps the EPR infoset in a human-readable string.
*/
try {
// debug convenience
} catch (TransformerException e) {
return e.toString();
}
}
/**
* Gets the QName of the EndpointReference element.
* @return
*/
return rootElement;
}
/**
* Filtering {@link SAXBufferProcessor} that replaces the root tag name.
*/
private boolean root=true;
super(infoset,false);
this.rootLocalName = rootLocalName;
}
if(root) {
root = false;
} else {
}
}
}
}
private static final OutboundReferenceParameterHeader[] EMPTY_ARRAY = new OutboundReferenceParameterHeader[0];
/**
* Represents an extensibility element inside an EndpointReference
*/
public static abstract class EPRExtension {
}
/**
* Returns the first extensibility element inside EPR root element with input QName.
*/
public @Nullable
if (rootEprExtensions == null)
}
if (rootEprExtensions == null)
return rootEprExtensions.values();
}
// parser should be either at the start element or the start document
// since often EPR doesn't have extensions, create array lazily
//EPR extensions do not use the same namespace of the Addressing Version.
//Not an extension - SKIP
} else {
}
}
// hit to </EndpointReference> by now
}
/**
* Parses the metadata inside this EPR and obtains it in a easy-to-process form.
*
* <p>
* See {@link Metadata} class for what's avaliable as "metadata".
*/
return new Metadata();
}
/**
* Parses the Metadata in an EPR and provides convenience methods to access
* the metadata.
*
*/
public class Metadata {
return serviceName;
}
return portName;
}
return portTypeName;
}
return wsdlSource;
}
return wsdliLocation;
}
private Metadata() {
try {
} catch (XMLStreamException e) {
throw new WebServiceException(e);
}
}
/**
* Parses the Metadata section of the EPR.
*/
// parser should be either at the start element or the start document
do {
//If the current element is metadata enclosure, look inside
if(serviceName != null)
throw new RuntimeException("More than one "+ version.eprType.serviceName +" element in EPR Metadata");
if(portTypeName != null)
throw new RuntimeException("More than one "+ version.eprType.portTypeName +" element in EPR Metadata");
} else {
}
}
} else {
//Skip is it is not root element
}
if(wsdliLocation != null) {
}
do {
//If the current element is metadata enclosure, look inside
} else {
}
}
}
} else {
//Skip is it is not root element
}
}
}
} else {
}
}
return null;
}
}
}