feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
61
jdkSrc/jdk8/com/sun/xml/internal/ws/Closeable.java
Normal file
61
jdkSrc/jdk8/com/sun/xml/internal/ws/Closeable.java
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.Dispatch;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Closeable JAX-WS proxy object.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @since JAX-WS 2.0.2
|
||||
*/
|
||||
// this interface is exposed to applications.
|
||||
public interface Closeable extends java.io.Closeable {
|
||||
/**
|
||||
* Closes this object and cleans up any resources
|
||||
* it holds, such as network connections.
|
||||
*
|
||||
* <p>
|
||||
* This interface is implemented by a port proxy
|
||||
* or {@link Dispatch}. In particular, this signals
|
||||
* the implementation of certain specs (like WS-ReliableMessaging
|
||||
* and WS-SecureConversation) to terminate sessions that they
|
||||
* create during the life time of a proxy object.
|
||||
*
|
||||
* <p>
|
||||
* This is not a mandatory operation, so the application
|
||||
* does not have to call this method.
|
||||
*
|
||||
*
|
||||
* @throws WebServiceException
|
||||
* If clean up fails unexpectedly, this exception
|
||||
* will be thrown (instead of {@link IOException}.
|
||||
*/
|
||||
public void close() throws WebServiceException;
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import com.sun.xml.internal.ws.api.server.*;
|
||||
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory;
|
||||
import com.sun.xml.internal.ws.util.xml.XMLStreamWriterFilter;
|
||||
import com.sun.xml.internal.ws.util.xml.XMLStreamReaderToXMLStreamWriter;
|
||||
import com.sun.xml.internal.ws.server.WSEndpointImpl;
|
||||
import com.sun.xml.internal.ws.wsdl.parser.WSDLConstants;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* This class acts as a filter for the Extension elements in the wsa:EndpointReference in the wsdl.
|
||||
* In addition to filtering the EPR extensions from WSDL, it adds the extensions configured by the JAX-WS runtime
|
||||
* specifc to an endpoint.
|
||||
*
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public class EPRSDDocumentFilter implements SDDocumentFilter {
|
||||
private final WSEndpointImpl<?> endpoint;
|
||||
//initialize lazily
|
||||
List<BoundEndpoint> beList;
|
||||
public EPRSDDocumentFilter(@NotNull WSEndpointImpl<?> endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
private @Nullable WSEndpointImpl<?> getEndpoint(String serviceName, String portName) {
|
||||
if (serviceName == null || portName == null)
|
||||
return null;
|
||||
if (endpoint.getServiceName().getLocalPart().equals(serviceName) && endpoint.getPortName().getLocalPart().equals(portName))
|
||||
return endpoint;
|
||||
|
||||
if(beList == null) {
|
||||
//check if it is run in a Java EE Container and get hold of other endpoints in the application
|
||||
Module module = endpoint.getContainer().getSPI(Module.class);
|
||||
if (module != null) {
|
||||
beList = module.getBoundEndpoints();
|
||||
} else {
|
||||
beList = Collections.<BoundEndpoint>emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
for (BoundEndpoint be : beList) {
|
||||
WSEndpoint wse = be.getEndpoint();
|
||||
if (wse.getServiceName().getLocalPart().equals(serviceName) && wse.getPortName().getLocalPart().equals(portName)) {
|
||||
return (WSEndpointImpl) wse;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public XMLStreamWriter filter(SDDocument doc, XMLStreamWriter w) throws XMLStreamException, IOException {
|
||||
if (!doc.isWSDL()) {
|
||||
return w;
|
||||
}
|
||||
|
||||
return new XMLStreamWriterFilter(w) {
|
||||
private boolean eprExtnFilterON = false; //when true, all writer events are filtered out
|
||||
|
||||
private boolean portHasEPR = false;
|
||||
private int eprDepth = -1; // -1 -> outside wsa:epr, 0 -> on wsa:epr start/end , > 0 inside wsa:epr
|
||||
|
||||
private String serviceName = null; //non null when inside wsdl:service scope
|
||||
private boolean onService = false; //flag to get service name when on wsdl:service element start
|
||||
private int serviceDepth = -1; // -1 -> outside wsdl:service, 0 -> on wsdl:service start/end , > 0 inside wsdl:service
|
||||
|
||||
private String portName = null; //non null when inside wsdl:port scope
|
||||
private boolean onPort = false; //flag to get port name when on wsdl:port element start
|
||||
private int portDepth = -1; // -1 -> outside wsdl:port, 0 -> on wsdl:port start/end , > 0 inside wsdl:port
|
||||
|
||||
private String portAddress; // when a complete epr is written, endpoint address is used as epr address
|
||||
private boolean onPortAddress = false; //flag to get endpoint address when on soap:address element start
|
||||
|
||||
private void handleStartElement(String localName, String namespaceURI) throws XMLStreamException {
|
||||
resetOnElementFlags();
|
||||
if (serviceDepth >= 0) {
|
||||
serviceDepth++;
|
||||
}
|
||||
if (portDepth >= 0) {
|
||||
portDepth++;
|
||||
}
|
||||
if (eprDepth >= 0) {
|
||||
eprDepth++;
|
||||
}
|
||||
|
||||
if (namespaceURI.equals(WSDLConstants.QNAME_SERVICE.getNamespaceURI()) && localName.equals(WSDLConstants.QNAME_SERVICE.getLocalPart())) {
|
||||
onService = true;
|
||||
serviceDepth = 0;
|
||||
} else if (namespaceURI.equals(WSDLConstants.QNAME_PORT.getNamespaceURI()) && localName.equals(WSDLConstants.QNAME_PORT.getLocalPart())) {
|
||||
if (serviceDepth >= 1) {
|
||||
onPort = true;
|
||||
portDepth = 0;
|
||||
}
|
||||
} else if (namespaceURI.equals(W3CAddressingConstants.WSA_NAMESPACE_NAME) && localName.equals("EndpointReference")) {
|
||||
if (serviceDepth >= 1 && portDepth >= 1) {
|
||||
portHasEPR = true;
|
||||
eprDepth = 0;
|
||||
}
|
||||
} else if ((namespaceURI.equals(WSDLConstants.NS_SOAP_BINDING_ADDRESS.getNamespaceURI()) || namespaceURI.equals(WSDLConstants.NS_SOAP12_BINDING_ADDRESS.getNamespaceURI()))
|
||||
&& localName.equals("address") && portDepth ==1) {
|
||||
onPortAddress = true;
|
||||
}
|
||||
WSEndpoint endpoint = getEndpoint(serviceName,portName);
|
||||
//filter epr for only for the port corresponding to this endpoint
|
||||
//if (service.getLocalPart().equals(serviceName) && port.getLocalPart().equals(portName)) {
|
||||
if ( endpoint != null) {
|
||||
if ((eprDepth == 1) && !namespaceURI.equals(W3CAddressingConstants.WSA_NAMESPACE_NAME)) {
|
||||
//epr extension element
|
||||
eprExtnFilterON = true;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
if (eprExtnFilterON) {
|
||||
writeEPRExtensions();
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
private void resetOnElementFlags() {
|
||||
if (onService) {
|
||||
onService = false;
|
||||
}
|
||||
if (onPort) {
|
||||
onPort = false;
|
||||
}
|
||||
if (onPortAddress) {
|
||||
onPortAddress = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void writeEPRExtensions(Collection<WSEndpointReference.EPRExtension> eprExtns) throws XMLStreamException {
|
||||
if (eprExtns != null) {
|
||||
for (WSEndpointReference.EPRExtension e : eprExtns) {
|
||||
XMLStreamReaderToXMLStreamWriter c = new XMLStreamReaderToXMLStreamWriter();
|
||||
XMLStreamReader r = e.readAsXMLStreamReader();
|
||||
c.bridge(r, writer);
|
||||
XMLStreamReaderFactory.recycle(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
|
||||
handleStartElement(localName, namespaceURI);
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeStartElement(prefix, localName, namespaceURI);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException {
|
||||
handleStartElement(localName, namespaceURI);
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeStartElement(namespaceURI, localName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartElement(String localName) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeStartElement(localName);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEndElement() throws XMLStreamException {
|
||||
resetOnElementFlags();
|
||||
//End of wsdl:port, write complete EPR if not present.
|
||||
if (portDepth == 0) {
|
||||
|
||||
if (!portHasEPR && getEndpoint(serviceName,portName) != null) {
|
||||
|
||||
//write the complete EPR with address.
|
||||
writer.writeStartElement(AddressingVersion.W3C.getPrefix(),"EndpointReference", AddressingVersion.W3C.nsUri );
|
||||
writer.writeNamespace(AddressingVersion.W3C.getPrefix(), AddressingVersion.W3C.nsUri);
|
||||
writer.writeStartElement(AddressingVersion.W3C.getPrefix(), AddressingVersion.W3C.eprType.address, AddressingVersion.W3C.nsUri);
|
||||
writer.writeCharacters(portAddress);
|
||||
writer.writeEndElement();
|
||||
writeEPRExtensions(getEndpoint(serviceName, portName).getEndpointReferenceExtensions());
|
||||
writer.writeEndElement();
|
||||
|
||||
}
|
||||
}
|
||||
//End of wsa:EndpointReference, write EPR extension elements
|
||||
if (eprDepth == 0) {
|
||||
if (portHasEPR && getEndpoint(serviceName,portName) != null) {
|
||||
writeEPRExtensions(getEndpoint(serviceName, portName).getEndpointReferenceExtensions());
|
||||
}
|
||||
eprExtnFilterON = false;
|
||||
}
|
||||
|
||||
if(serviceDepth >= 0 ) {
|
||||
serviceDepth--;
|
||||
}
|
||||
if(portDepth >= 0) {
|
||||
portDepth--;
|
||||
}
|
||||
if(eprDepth >=0) {
|
||||
eprDepth--;
|
||||
}
|
||||
|
||||
if (serviceDepth == -1) {
|
||||
serviceName = null;
|
||||
}
|
||||
if (portDepth == -1) {
|
||||
portHasEPR = false;
|
||||
portAddress = null;
|
||||
portName = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEndElement() throws XMLStreamException {
|
||||
handleEndElement();
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAttribute(String localName, String value) {
|
||||
if (localName.equals("name")) {
|
||||
if (onService) {
|
||||
serviceName = value;
|
||||
onService = false;
|
||||
} else if (onPort) {
|
||||
portName = value;
|
||||
onPort = false;
|
||||
}
|
||||
}
|
||||
if (localName.equals("location") && onPortAddress) {
|
||||
portAddress = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAttribute(String prefix, String namespaceURI, String localName, String value) throws XMLStreamException {
|
||||
handleAttribute(localName, value);
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeAttribute(prefix, namespaceURI, localName, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException {
|
||||
handleAttribute(localName, value);
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeAttribute(namespaceURI, localName, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAttribute(String localName, String value) throws XMLStreamException {
|
||||
handleAttribute(localName, value);
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeAttribute(localName, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeEmptyElement(namespaceURI, localName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeNamespace(prefix, namespaceURI);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNamespaceContext(NamespaceContext context) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.setNamespaceContext(context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultNamespace(String uri) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.setDefaultNamespace(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrefix(String prefix, String uri) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.setPrefix(prefix, uri);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeProcessingInstruction(String target, String data) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeProcessingInstruction(target, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeEmptyElement(prefix, localName, namespaceURI);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCData(String data) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeCData(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCharacters(String text) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeCharacters(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeComment(String data) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeComment(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDTD(String dtd) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeDTD(dtd);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDefaultNamespace(String namespaceURI) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeDefaultNamespace(namespaceURI);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEmptyElement(String localName) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeEmptyElement(localName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityRef(String name) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeEntityRef(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeProcessingInstruction(String target) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeProcessingInstruction(target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeCharacters(char[] text, int start, int len) throws XMLStreamException {
|
||||
if (!eprExtnFilterON) {
|
||||
super.writeCharacters(text, start, len);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,411 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.stream.buffer.XMLStreamBufferSource;
|
||||
import com.sun.xml.internal.stream.buffer.stax.StreamWriterBufferCreator;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionEndpointReference;
|
||||
import com.sun.xml.internal.ws.util.DOMUtil;
|
||||
import com.sun.xml.internal.ws.util.xml.XmlUtil;
|
||||
import com.sun.xml.internal.ws.wsdl.parser.WSDLConstants;
|
||||
import com.sun.xml.internal.ws.addressing.v200408.MemberSubmissionAddressingConstants;
|
||||
import org.w3c.dom.*;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
import javax.xml.ws.EndpointReference;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
|
||||
public class EndpointReferenceUtil {
|
||||
/**
|
||||
* Gives the EPR based on the clazz. It may need to perform tranformation from
|
||||
* W3C EPR to MS EPR or vise-versa.
|
||||
*/
|
||||
public static <T extends EndpointReference> T transform(Class<T> clazz, @NotNull EndpointReference epr) {
|
||||
assert epr != null;
|
||||
if (clazz.isAssignableFrom(W3CEndpointReference.class)) {
|
||||
if (epr instanceof W3CEndpointReference) {
|
||||
return (T) epr;
|
||||
} else if (epr instanceof MemberSubmissionEndpointReference) {
|
||||
return (T) toW3CEpr((MemberSubmissionEndpointReference) epr);
|
||||
}
|
||||
} else if (clazz.isAssignableFrom(MemberSubmissionEndpointReference.class)) {
|
||||
if (epr instanceof W3CEndpointReference) {
|
||||
return (T) toMSEpr((W3CEndpointReference) epr);
|
||||
} else if (epr instanceof MemberSubmissionEndpointReference) {
|
||||
return (T) epr;
|
||||
}
|
||||
}
|
||||
|
||||
//This must be an EPR that we dont know
|
||||
throw new WebServiceException("Unknwon EndpointReference: " + epr.getClass());
|
||||
}
|
||||
|
||||
//TODO: bit of redundency on writes of w3c epr, should modularize it
|
||||
private static W3CEndpointReference toW3CEpr(MemberSubmissionEndpointReference msEpr) {
|
||||
StreamWriterBufferCreator writer = new StreamWriterBufferCreator();
|
||||
w3cMetadataWritten = false;
|
||||
try {
|
||||
writer.writeStartDocument();
|
||||
writer.writeStartElement(AddressingVersion.W3C.getPrefix(),
|
||||
"EndpointReference", AddressingVersion.W3C.nsUri);
|
||||
writer.writeNamespace(AddressingVersion.W3C.getPrefix(),
|
||||
AddressingVersion.W3C.nsUri);
|
||||
//write wsa:Address
|
||||
writer.writeStartElement(AddressingVersion.W3C.getPrefix(),
|
||||
AddressingVersion.W3C.eprType.address
|
||||
, AddressingVersion.W3C.nsUri);
|
||||
writer.writeCharacters(msEpr.addr.uri);
|
||||
writer.writeEndElement();
|
||||
//TODO: write extension attributes on wsa:Address
|
||||
if ((msEpr.referenceProperties != null && msEpr.referenceProperties.elements.size() > 0) ||
|
||||
(msEpr.referenceParameters != null && msEpr.referenceParameters.elements.size() > 0)) {
|
||||
|
||||
writer.writeStartElement(AddressingVersion.W3C.getPrefix(), "ReferenceParameters", AddressingVersion.W3C.nsUri);
|
||||
|
||||
//write ReferenceProperties
|
||||
if (msEpr.referenceProperties != null) {
|
||||
for (Element e : msEpr.referenceProperties.elements) {
|
||||
DOMUtil.serializeNode(e, writer);
|
||||
}
|
||||
}
|
||||
//write referenceParameters
|
||||
if (msEpr.referenceParameters != null) {
|
||||
for (Element e : msEpr.referenceParameters.elements) {
|
||||
DOMUtil.serializeNode(e, writer);
|
||||
}
|
||||
}
|
||||
writer.writeEndElement();
|
||||
}
|
||||
// Supress writing ServiceName and EndpointName in W3CEPR,
|
||||
// Until the ns for those metadata elements is resolved.
|
||||
/*
|
||||
//Write Interface info
|
||||
if (msEpr.portTypeName != null) {
|
||||
writeW3CMetadata(writer);
|
||||
writer.writeStartElement(AddressingVersion.W3C.getWsdlPrefix(),
|
||||
AddressingVersion.W3C.eprType.portTypeName ,
|
||||
AddressingVersion.W3C.wsdlNsUri);
|
||||
writer.writeNamespace(AddressingVersion.W3C.getWsdlPrefix(),
|
||||
AddressingVersion.W3C.wsdlNsUri);
|
||||
String portTypePrefix = fixNull(msEpr.portTypeName.name.getPrefix());
|
||||
writer.writeNamespace(portTypePrefix, msEpr.portTypeName.name.getNamespaceURI());
|
||||
if (portTypePrefix.equals(""))
|
||||
writer.writeCharacters(msEpr.portTypeName.name.getLocalPart());
|
||||
else
|
||||
writer.writeCharacters(portTypePrefix + ":" + msEpr.portTypeName.name.getLocalPart());
|
||||
writer.writeEndElement();
|
||||
}
|
||||
if (msEpr.serviceName != null) {
|
||||
writeW3CMetadata(writer);
|
||||
//Write service and Port info
|
||||
writer.writeStartElement(AddressingVersion.W3C.getWsdlPrefix(),
|
||||
AddressingVersion.W3C.eprType.serviceName ,
|
||||
AddressingVersion.W3C.wsdlNsUri);
|
||||
writer.writeNamespace(AddressingVersion.W3C.getWsdlPrefix(),
|
||||
AddressingVersion.W3C.wsdlNsUri);
|
||||
|
||||
String servicePrefix = fixNull(msEpr.serviceName.name.getPrefix());
|
||||
if (msEpr.serviceName.portName != null)
|
||||
writer.writeAttribute(AddressingVersion.W3C.eprType.portName,
|
||||
msEpr.serviceName.portName);
|
||||
|
||||
writer.writeNamespace(servicePrefix, msEpr.serviceName.name.getNamespaceURI());
|
||||
if (servicePrefix.length() > 0)
|
||||
writer.writeCharacters(servicePrefix + ":" + msEpr.serviceName.name.getLocalPart());
|
||||
else
|
||||
writer.writeCharacters(msEpr.serviceName.name.getLocalPart());
|
||||
writer.writeEndElement();
|
||||
}
|
||||
*/
|
||||
//TODO: revisit this
|
||||
Element wsdlElement = null;
|
||||
//Check for wsdl in extension elements
|
||||
if ((msEpr.elements != null) && (msEpr.elements.size() > 0)) {
|
||||
for (Element e : msEpr.elements) {
|
||||
if(e.getNamespaceURI().equals(MemberSubmissionAddressingConstants.MEX_METADATA.getNamespaceURI()) &&
|
||||
e.getLocalName().equals(MemberSubmissionAddressingConstants.MEX_METADATA.getLocalPart())) {
|
||||
NodeList nl = e.getElementsByTagNameNS(WSDLConstants.NS_WSDL,
|
||||
WSDLConstants.QNAME_DEFINITIONS.getLocalPart());
|
||||
if(nl != null) {
|
||||
wsdlElement = (Element) nl.item(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//write WSDL
|
||||
if (wsdlElement != null) {
|
||||
DOMUtil.serializeNode(wsdlElement, writer);
|
||||
}
|
||||
|
||||
if (w3cMetadataWritten) {
|
||||
writer.writeEndElement();
|
||||
}
|
||||
//TODO revisit this
|
||||
//write extension elements
|
||||
if ((msEpr.elements != null) && (msEpr.elements.size() > 0)) {
|
||||
for (Element e : msEpr.elements) {
|
||||
if (e.getNamespaceURI().equals(WSDLConstants.NS_WSDL) &&
|
||||
e.getLocalName().equals(WSDLConstants.QNAME_DEFINITIONS.getLocalPart())) {
|
||||
// Don't write it as this is written already in Metadata
|
||||
}
|
||||
DOMUtil.serializeNode(e, writer);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO:write extension attributes
|
||||
|
||||
//</EndpointReference>
|
||||
writer.writeEndElement();
|
||||
writer.writeEndDocument();
|
||||
writer.flush();
|
||||
} catch (XMLStreamException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
return new W3CEndpointReference(new XMLStreamBufferSource(writer.getXMLStreamBuffer()));
|
||||
}
|
||||
|
||||
private static boolean w3cMetadataWritten = false;
|
||||
|
||||
// private static void writeW3CMetadata(StreamWriterBufferCreator writer) throws XMLStreamException {
|
||||
// if (!w3cMetadataWritten) {
|
||||
// writer.writeStartElement(AddressingVersion.W3C.getPrefix(), AddressingVersion.W3C.eprType.wsdlMetadata.getLocalPart(), AddressingVersion.W3C.nsUri);
|
||||
// w3cMetadataWritten = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
private static MemberSubmissionEndpointReference toMSEpr(W3CEndpointReference w3cEpr) {
|
||||
DOMResult result = new DOMResult();
|
||||
w3cEpr.writeTo(result);
|
||||
Node eprNode = result.getNode();
|
||||
Element e = DOMUtil.getFirstElementChild(eprNode);
|
||||
if (e == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MemberSubmissionEndpointReference msEpr = new MemberSubmissionEndpointReference();
|
||||
|
||||
NodeList nodes = e.getChildNodes();
|
||||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
|
||||
Element child = (Element) nodes.item(i);
|
||||
if (child.getNamespaceURI().equals(AddressingVersion.W3C.nsUri) &&
|
||||
child.getLocalName().equals(AddressingVersion.W3C.eprType.address)) {
|
||||
if (msEpr.addr == null) {
|
||||
msEpr.addr = new MemberSubmissionEndpointReference.Address();
|
||||
}
|
||||
msEpr.addr.uri = XmlUtil.getTextForNode(child);
|
||||
|
||||
} else if (child.getNamespaceURI().equals(AddressingVersion.W3C.nsUri) &&
|
||||
child.getLocalName().equals("ReferenceParameters")) {
|
||||
NodeList refParams = child.getChildNodes();
|
||||
for (int j = 0; j < refParams.getLength(); j++) {
|
||||
if (refParams.item(j).getNodeType() == Node.ELEMENT_NODE) {
|
||||
if (msEpr.referenceParameters == null) {
|
||||
msEpr.referenceParameters = new MemberSubmissionEndpointReference.Elements();
|
||||
msEpr.referenceParameters.elements = new ArrayList<Element>();
|
||||
}
|
||||
msEpr.referenceParameters.elements.add((Element) refParams.item(j));
|
||||
}
|
||||
}
|
||||
} else if (child.getNamespaceURI().equals(AddressingVersion.W3C.nsUri) &&
|
||||
child.getLocalName().equals(AddressingVersion.W3C.eprType.wsdlMetadata.getLocalPart())) {
|
||||
NodeList metadata = child.getChildNodes();
|
||||
String wsdlLocation = child.getAttributeNS(W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_NAMESPACE,
|
||||
W3CAddressingMetadataConstants.WSAM_WSDLI_ATTRIBUTE_LOCALNAME);
|
||||
Element wsdlDefinitions = null;
|
||||
for (int j = 0; j < metadata.getLength(); j++) {
|
||||
Node node = metadata.item(j);
|
||||
if (node.getNodeType() != Node.ELEMENT_NODE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Element elm = (Element) node;
|
||||
if ((elm.getNamespaceURI().equals(AddressingVersion.W3C.wsdlNsUri) ||
|
||||
elm.getNamespaceURI().equals(W3CAddressingMetadataConstants.WSAM_NAMESPACE_NAME)) &&
|
||||
elm.getLocalName().equals(AddressingVersion.W3C.eprType.serviceName)) {
|
||||
msEpr.serviceName = new MemberSubmissionEndpointReference.ServiceNameType();
|
||||
msEpr.serviceName.portName = elm.getAttribute(AddressingVersion.W3C.eprType.portName);
|
||||
|
||||
String service = elm.getTextContent();
|
||||
String prefix = XmlUtil.getPrefix(service);
|
||||
String name = XmlUtil.getLocalPart(service);
|
||||
|
||||
//if there is no service name then its not a valid EPR but lets continue as its optional anyway
|
||||
if (name == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prefix != null) {
|
||||
String ns = elm.lookupNamespaceURI(prefix);
|
||||
if (ns != null) {
|
||||
msEpr.serviceName.name = new QName(ns, name, prefix);
|
||||
}
|
||||
} else {
|
||||
msEpr.serviceName.name = new QName(null, name);
|
||||
}
|
||||
msEpr.serviceName.attributes = getAttributes(elm);
|
||||
} else if ((elm.getNamespaceURI().equals(AddressingVersion.W3C.wsdlNsUri) ||
|
||||
elm.getNamespaceURI().equals(W3CAddressingMetadataConstants.WSAM_NAMESPACE_NAME)) &&
|
||||
elm.getLocalName().equals(AddressingVersion.W3C.eprType.portTypeName)) {
|
||||
msEpr.portTypeName = new MemberSubmissionEndpointReference.AttributedQName();
|
||||
|
||||
String portType = elm.getTextContent();
|
||||
String prefix = XmlUtil.getPrefix(portType);
|
||||
String name = XmlUtil.getLocalPart(portType);
|
||||
|
||||
//if there is no portType name then its not a valid EPR but lets continue as its optional anyway
|
||||
if (name == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prefix != null) {
|
||||
String ns = elm.lookupNamespaceURI(prefix);
|
||||
if (ns != null) {
|
||||
msEpr.portTypeName.name = new QName(ns, name, prefix);
|
||||
}
|
||||
} else {
|
||||
msEpr.portTypeName.name = new QName(null, name);
|
||||
}
|
||||
msEpr.portTypeName.attributes = getAttributes(elm);
|
||||
} else if(elm.getNamespaceURI().equals(WSDLConstants.NS_WSDL) &&
|
||||
elm.getLocalName().equals(WSDLConstants.QNAME_DEFINITIONS.getLocalPart())) {
|
||||
wsdlDefinitions = elm;
|
||||
} else {
|
||||
//TODO : Revisit this
|
||||
//its extensions in META-DATA and should be copied to extensions in MS EPR
|
||||
if (msEpr.elements == null) {
|
||||
msEpr.elements = new ArrayList<Element>();
|
||||
}
|
||||
msEpr.elements.add(elm);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Document doc = DOMUtil.createDom();
|
||||
Element mexEl = doc.createElementNS(MemberSubmissionAddressingConstants.MEX_METADATA.getNamespaceURI(),
|
||||
MemberSubmissionAddressingConstants.MEX_METADATA.getPrefix() + ":"
|
||||
+ MemberSubmissionAddressingConstants.MEX_METADATA.getLocalPart());
|
||||
Element metadataEl = doc.createElementNS(MemberSubmissionAddressingConstants.MEX_METADATA_SECTION.getNamespaceURI(),
|
||||
MemberSubmissionAddressingConstants.MEX_METADATA_SECTION.getPrefix() + ":"
|
||||
+ MemberSubmissionAddressingConstants.MEX_METADATA_SECTION.getLocalPart());
|
||||
metadataEl.setAttribute(MemberSubmissionAddressingConstants.MEX_METADATA_DIALECT_ATTRIBUTE,
|
||||
MemberSubmissionAddressingConstants.MEX_METADATA_DIALECT_VALUE);
|
||||
if (wsdlDefinitions == null && wsdlLocation != null && !wsdlLocation.equals("")) {
|
||||
wsdlLocation = wsdlLocation.trim();
|
||||
String wsdlTns = wsdlLocation.substring(0, wsdlLocation.indexOf(' '));
|
||||
wsdlLocation = wsdlLocation.substring(wsdlLocation.indexOf(' ') + 1);
|
||||
Element wsdlEl = doc.createElementNS(WSDLConstants.NS_WSDL,
|
||||
WSDLConstants.PREFIX_NS_WSDL + ":"
|
||||
+ WSDLConstants.QNAME_DEFINITIONS.getLocalPart());
|
||||
Element wsdlImportEl = doc.createElementNS(WSDLConstants.NS_WSDL,
|
||||
WSDLConstants.PREFIX_NS_WSDL + ":"
|
||||
+ WSDLConstants.QNAME_IMPORT.getLocalPart());
|
||||
wsdlImportEl.setAttribute("namespace", wsdlTns);
|
||||
wsdlImportEl.setAttribute("location", wsdlLocation);
|
||||
wsdlEl.appendChild(wsdlImportEl);
|
||||
metadataEl.appendChild(wsdlEl);
|
||||
} else if(wsdlDefinitions != null){
|
||||
metadataEl.appendChild(wsdlDefinitions);
|
||||
}
|
||||
mexEl.appendChild(metadataEl);
|
||||
|
||||
if (msEpr.elements == null) {
|
||||
msEpr.elements = new ArrayList<Element>();
|
||||
}
|
||||
msEpr.elements.add(mexEl);
|
||||
|
||||
|
||||
} else {
|
||||
//its extensions
|
||||
if (msEpr.elements == null) {
|
||||
msEpr.elements = new ArrayList<Element>();
|
||||
}
|
||||
msEpr.elements.add((Element) child);
|
||||
|
||||
}
|
||||
} else if (nodes.item(i).getNodeType() == Node.ATTRIBUTE_NODE) {
|
||||
Node n = nodes.item(i);
|
||||
if (msEpr.attributes == null) {
|
||||
msEpr.attributes = new HashMap<QName, String>();
|
||||
String prefix = fixNull(n.getPrefix());
|
||||
String ns = fixNull(n.getNamespaceURI());
|
||||
String localName = n.getLocalName();
|
||||
msEpr.attributes.put(new QName(ns, localName, prefix), n.getNodeValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return msEpr;
|
||||
}
|
||||
|
||||
private static Map<QName, String> getAttributes(Node node) {
|
||||
Map<QName, String> attribs = null;
|
||||
|
||||
NamedNodeMap nm = node.getAttributes();
|
||||
for (int i = 0; i < nm.getLength(); i++) {
|
||||
if (attribs == null) {
|
||||
attribs = new HashMap<QName, String>();
|
||||
}
|
||||
Node n = nm.item(i);
|
||||
String prefix = fixNull(n.getPrefix());
|
||||
String ns = fixNull(n.getNamespaceURI());
|
||||
String localName = n.getLocalName();
|
||||
if (prefix.equals("xmlns") || prefix.length() == 0 && localName.equals("xmlns")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//exclude some attributes
|
||||
if (!localName.equals(AddressingVersion.W3C.eprType.portName)) {
|
||||
attribs.put(new QName(ns, localName, prefix), n.getNodeValue());
|
||||
}
|
||||
}
|
||||
return attribs;
|
||||
}
|
||||
|
||||
private static
|
||||
@NotNull
|
||||
String fixNull(@Nullable String s) {
|
||||
if (s == null) {
|
||||
return "";
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import com.sun.xml.internal.ws.addressing.W3CAddressingConstants;
|
||||
|
||||
/**
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
@XmlRootElement(name="ProblemAction", namespace= W3CAddressingConstants.WSA_NAMESPACE_NAME)
|
||||
public class ProblemAction {
|
||||
|
||||
@XmlElement(name="Action", namespace=W3CAddressingConstants.WSA_NAMESPACE_NAME)
|
||||
private String action;
|
||||
|
||||
@XmlElement(name="SoapAction", namespace=W3CAddressingConstants.WSA_NAMESPACE_NAME)
|
||||
private String soapAction;
|
||||
|
||||
/** Creates a new instance of ProblemAction */
|
||||
public ProblemAction() {
|
||||
}
|
||||
|
||||
public ProblemAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public ProblemAction(String action, String soapAction) {
|
||||
this.action = action;
|
||||
this.soapAction = soapAction;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public String getSoapAction() {
|
||||
return soapAction;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlValue;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import static com.sun.xml.internal.ws.addressing.W3CAddressingConstants.WSA_NAMESPACE_NAME;
|
||||
|
||||
/**
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
@XmlRootElement(name="ProblemHeaderQName", namespace= WSA_NAMESPACE_NAME)
|
||||
public class ProblemHeaderQName {
|
||||
@XmlValue
|
||||
private QName value;
|
||||
|
||||
/** Creates a new instance of ProblemHeaderQName */
|
||||
public ProblemHeaderQName() {
|
||||
}
|
||||
|
||||
public ProblemHeaderQName(QName name) {
|
||||
this.value = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
|
||||
/**
|
||||
* Constants for W3C WS-Addressing version
|
||||
*
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
public interface W3CAddressingConstants {
|
||||
public static final String WSA_NAMESPACE_NAME = "http://www.w3.org/2005/08/addressing";
|
||||
public static final String WSA_NAMESPACE_WSDL_NAME = "http://www.w3.org/2006/05/addressing/wsdl";
|
||||
|
||||
public static final String WSAW_SERVICENAME_NAME = "ServiceName";
|
||||
public static final String WSAW_INTERFACENAME_NAME = "InterfaceName";
|
||||
public static final String WSAW_ENDPOINTNAME_NAME = "EndpointName";
|
||||
|
||||
public static final String WSA_REFERENCEPROPERTIES_NAME = "ReferenceParameters";
|
||||
public static final QName WSA_REFERENCEPROPERTIES_QNAME = new QName(WSA_NAMESPACE_NAME, WSA_REFERENCEPROPERTIES_NAME);
|
||||
|
||||
public static final String WSA_REFERENCEPARAMETERS_NAME = "ReferenceParameters";
|
||||
public static final QName WSA_REFERENCEPARAMETERS_QNAME = new QName(WSA_NAMESPACE_NAME, WSA_REFERENCEPARAMETERS_NAME);
|
||||
|
||||
public static final String WSA_METADATA_NAME = "Metadata";
|
||||
public static final QName WSA_METADATA_QNAME = new QName(WSA_NAMESPACE_NAME, WSA_METADATA_NAME);
|
||||
|
||||
public static final String WSA_ADDRESS_NAME = "Address";
|
||||
public static final QName WSA_ADDRESS_QNAME = new QName(WSA_NAMESPACE_NAME, WSA_ADDRESS_NAME);
|
||||
|
||||
public static final String WSA_ANONYMOUS_ADDRESS = WSA_NAMESPACE_NAME + "/anonymous";
|
||||
public static final String WSA_NONE_ADDRESS = WSA_NAMESPACE_NAME + "/none";
|
||||
|
||||
public static final String WSA_DEFAULT_FAULT_ACTION = WSA_NAMESPACE_NAME + "/fault";
|
||||
|
||||
public static final String WSA_EPR_NAME = "EndpointReference";
|
||||
public static final QName WSA_EPR_QNAME = new QName(WSA_NAMESPACE_NAME, WSA_EPR_NAME);
|
||||
|
||||
|
||||
public static final String WSAW_USING_ADDRESSING_NAME = "UsingAddressing";
|
||||
public static final QName WSAW_USING_ADDRESSING_QNAME = new QName(WSA_NAMESPACE_WSDL_NAME, WSAW_USING_ADDRESSING_NAME);
|
||||
|
||||
public static final QName INVALID_MAP_QNAME = new QName(WSA_NAMESPACE_NAME, "InvalidAddressingHeader");
|
||||
public static final QName MAP_REQUIRED_QNAME = new QName(WSA_NAMESPACE_NAME, "MessageAddressingHeaderRequired");
|
||||
public static final QName DESTINATION_UNREACHABLE_QNAME = new QName(WSA_NAMESPACE_NAME, "DestinationUnreachable");
|
||||
public static final QName ACTION_NOT_SUPPORTED_QNAME = new QName(WSA_NAMESPACE_NAME, "ActionNotSupported");
|
||||
public static final QName ENDPOINT_UNAVAILABLE_QNAME = new QName(WSA_NAMESPACE_NAME, "EndpointUnavailable");
|
||||
|
||||
public static final String ACTION_NOT_SUPPORTED_TEXT = "The \"%s\" cannot be processed at the receiver";
|
||||
public static final String DESTINATION_UNREACHABLE_TEXT = "No route can be determined to reach %s";
|
||||
public static final String ENDPOINT_UNAVAILABLE_TEXT = "The endpoint is unable to process the message at this time";
|
||||
public static final String INVALID_MAP_TEXT = "A header representing a Message Addressing Property is not valid and the message cannot be processed";
|
||||
public static final String MAP_REQUIRED_TEXT = "A required header representing a Message Addressing Property is not present";
|
||||
|
||||
public static final QName PROBLEM_ACTION_QNAME = new QName(WSA_NAMESPACE_NAME, "ProblemAction");
|
||||
public static final QName PROBLEM_HEADER_QNAME_QNAME = new QName(WSA_NAMESPACE_NAME, "ProblemHeaderQName");
|
||||
public static final QName FAULT_DETAIL_QNAME = new QName(WSA_NAMESPACE_NAME, "FaultDetail");
|
||||
|
||||
// Fault subsubcode when an invalid address is specified.
|
||||
public static final QName INVALID_ADDRESS_SUBCODE = new QName(WSA_NAMESPACE_NAME, "InvalidAddress",
|
||||
AddressingVersion.W3C.getPrefix());
|
||||
|
||||
// Fault subsubcode when an invalid header was expected to be EndpointReference but was not valid.
|
||||
public static final QName INVALID_EPR = new QName(WSA_NAMESPACE_NAME, "InvalidEPR", AddressingVersion.W3C.getPrefix());
|
||||
|
||||
// Fault subsubcode when greater than expected number of the specified header is received.
|
||||
public static final QName INVALID_CARDINALITY = new QName(WSA_NAMESPACE_NAME, "InvalidCardinality",
|
||||
AddressingVersion.W3C.getPrefix());
|
||||
|
||||
// Fault subsubcode when an invalid header was expected to be EndpointReference but did not contain address.
|
||||
public static final QName MISSING_ADDRESS_IN_EPR = new QName(WSA_NAMESPACE_NAME, "MissingAddressInEPR",
|
||||
AddressingVersion.W3C.getPrefix());
|
||||
|
||||
// Fault subsubcode when a header contains a message id that was a duplicate of one already received.
|
||||
public static final QName DUPLICATE_MESSAGEID = new QName(WSA_NAMESPACE_NAME, "DuplicateMessageID",
|
||||
AddressingVersion.W3C.getPrefix());
|
||||
|
||||
// Fault subsubcode when <code>Action</code> and <code>SOAPAction</code> for the mesage did not match.
|
||||
public static final QName ACTION_MISMATCH = new QName(WSA_NAMESPACE_NAME, "ActionMismatch",
|
||||
AddressingVersion.W3C.getPrefix());
|
||||
|
||||
// Fault subsubcode when the only address supported is the anonymous address.
|
||||
public static final QName ONLY_ANONYMOUS_ADDRESS_SUPPORTED = new QName(WSA_NAMESPACE_NAME, "OnlyAnonymousAddressSupported",
|
||||
AddressingVersion.W3C.getPrefix());
|
||||
|
||||
//Fault subsubcode when anonymous address is not supported.
|
||||
public static final QName ONLY_NON_ANONYMOUS_ADDRESS_SUPPORTED = new QName(WSA_NAMESPACE_NAME, "OnlyNonAnonymousAddressSupported",
|
||||
AddressingVersion.W3C.getPrefix());
|
||||
|
||||
public static final String ANONYMOUS_EPR = "<EndpointReference xmlns=\"http://www.w3.org/2005/08/addressing\">\n" +
|
||||
" <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>\n" +
|
||||
"</EndpointReference>";
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* Constants for W3C Addressing Metadata specification
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public class W3CAddressingMetadataConstants {
|
||||
public static final String WSAM_NAMESPACE_NAME = "http://www.w3.org/2007/05/addressing/metadata";
|
||||
public static final String WSAM_PREFIX_NAME = "wsam";
|
||||
public static final QName WSAM_ACTION_QNAME = new QName(WSAM_NAMESPACE_NAME,"Action",WSAM_PREFIX_NAME);
|
||||
|
||||
public static final String WSAM_ADDRESSING_ASSERTION_NAME="Addressing";
|
||||
public static final String WSAM_ANONYMOUS_NESTED_ASSERTION_NAME="AnonymousResponses";
|
||||
public static final String WSAM_NONANONYMOUS_NESTED_ASSERTION_NAME="NonAnonymousResponses";
|
||||
|
||||
public static final QName WSAM_ADDRESSING_ASSERTION = new QName(WSAM_NAMESPACE_NAME,
|
||||
WSAM_ADDRESSING_ASSERTION_NAME, WSAM_PREFIX_NAME );
|
||||
|
||||
public static final QName WSAM_ANONYMOUS_NESTED_ASSERTION = new QName(WSAM_NAMESPACE_NAME,
|
||||
WSAM_ANONYMOUS_NESTED_ASSERTION_NAME, WSAM_PREFIX_NAME );
|
||||
|
||||
public static final QName WSAM_NONANONYMOUS_NESTED_ASSERTION = new QName(WSAM_NAMESPACE_NAME,
|
||||
WSAM_NONANONYMOUS_NESTED_ASSERTION_NAME, WSAM_PREFIX_NAME );
|
||||
|
||||
public static final String WSAM_WSDLI_ATTRIBUTE_NAMESPACE="http://www.w3.org/ns/wsdl-instance";
|
||||
public static final String WSAM_WSDLI_ATTRIBUTE_PREFIX="wsdli";
|
||||
public static final String WSAM_WSDLI_ATTRIBUTE_LOCALNAME="wsdlLocation";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.message.AddressingUtils;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.pipe.Tube;
|
||||
import com.sun.xml.internal.ws.api.pipe.TubeCloner;
|
||||
import com.sun.xml.internal.ws.addressing.model.MissingAddressingHeaderException;
|
||||
|
||||
/**
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public class W3CWsaClientTube extends WsaClientTube {
|
||||
public W3CWsaClientTube(WSDLPort wsdlPort, WSBinding binding, Tube next) {
|
||||
super(wsdlPort, binding, next);
|
||||
}
|
||||
|
||||
public W3CWsaClientTube(WsaClientTube that, TubeCloner cloner) {
|
||||
super(that, cloner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public W3CWsaClientTube copy(TubeCloner cloner) {
|
||||
return new W3CWsaClientTube(this, cloner);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkMandatoryHeaders(Packet packet, boolean foundAction, boolean foundTo, boolean foundReplyTo,
|
||||
boolean foundFaultTo, boolean foundMessageID, boolean foundRelatesTo) {
|
||||
super.checkMandatoryHeaders(packet, foundAction, foundTo, foundReplyTo, foundFaultTo, foundMessageID, foundRelatesTo);
|
||||
|
||||
// if it is not one-way, response must contain wsa:RelatesTo
|
||||
// RelatesTo required as per
|
||||
// Table 5-3 of http://www.w3.org/TR/2006/WD-ws-addr-wsdl-20060216/#wsdl11requestresponse
|
||||
if (expectReply && (packet.getMessage() != null) && !foundRelatesTo) {
|
||||
String action = AddressingUtils.getAction(packet.getMessage().getHeaders(), addressingVersion, soapVersion);
|
||||
// Don't check for AddressingFaults as
|
||||
// Faults for requests with duplicate MessageId will have no wsa:RelatesTo
|
||||
if (!packet.getMessage().isFault() || !action.equals(addressingVersion.getDefaultFaultAction())) {
|
||||
throw new MissingAddressingHeaderException(addressingVersion.relatesToTag,packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.pipe.Tube;
|
||||
import com.sun.xml.internal.ws.api.pipe.TubeCloner;
|
||||
import com.sun.xml.internal.ws.addressing.model.MissingAddressingHeaderException;
|
||||
import com.sun.xml.internal.ws.addressing.model.InvalidAddressingHeaderException;
|
||||
import static com.sun.xml.internal.ws.addressing.W3CAddressingConstants.ONLY_NON_ANONYMOUS_ADDRESS_SUPPORTED;
|
||||
import static com.sun.xml.internal.ws.addressing.W3CAddressingConstants.ONLY_ANONYMOUS_ADDRESS_SUPPORTED;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
|
||||
import javax.xml.ws.soap.AddressingFeature;
|
||||
|
||||
/**
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public class W3CWsaServerTube extends WsaServerTube{
|
||||
private final AddressingFeature af;
|
||||
|
||||
public W3CWsaServerTube(WSEndpoint endpoint, @NotNull WSDLPort wsdlPort, WSBinding binding, Tube next) {
|
||||
super(endpoint, wsdlPort, binding, next);
|
||||
af = binding.getFeature(AddressingFeature.class);
|
||||
}
|
||||
|
||||
public W3CWsaServerTube(W3CWsaServerTube that, TubeCloner cloner) {
|
||||
super(that, cloner);
|
||||
this.af = that.af;
|
||||
}
|
||||
|
||||
@Override
|
||||
public W3CWsaServerTube copy(TubeCloner cloner) {
|
||||
return new W3CWsaServerTube(this, cloner);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkMandatoryHeaders(
|
||||
Packet packet, boolean foundAction, boolean foundTo, boolean foundReplyTo,
|
||||
boolean foundFaultTo, boolean foundMessageId, boolean foundRelatesTo) {
|
||||
super.checkMandatoryHeaders(packet, foundAction, foundTo, foundReplyTo,
|
||||
foundFaultTo, foundMessageId, foundRelatesTo);
|
||||
|
||||
// find Req/Response or Oneway using WSDLModel(if it is availabe)
|
||||
WSDLBoundOperation wbo = getWSDLBoundOperation(packet);
|
||||
// Taking care of protocol messages as they do not have any corresponding operations
|
||||
if (wbo != null) {
|
||||
// if two-way and no wsa:MessageID is found
|
||||
if (!wbo.getOperation().isOneWay() && !foundMessageId) {
|
||||
throw new MissingAddressingHeaderException(addressingVersion.messageIDTag,packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAnonymousRequired(@Nullable WSDLBoundOperation wbo) {
|
||||
return getResponseRequirement(wbo) == WSDLBoundOperation.ANONYMOUS.required;
|
||||
}
|
||||
|
||||
private WSDLBoundOperation.ANONYMOUS getResponseRequirement(@Nullable WSDLBoundOperation wbo) {
|
||||
try {
|
||||
if (af.getResponses() == AddressingFeature.Responses.ANONYMOUS) {
|
||||
return WSDLBoundOperation.ANONYMOUS.required;
|
||||
} else if (af.getResponses() == AddressingFeature.Responses.NON_ANONYMOUS) {
|
||||
return WSDLBoundOperation.ANONYMOUS.prohibited;
|
||||
}
|
||||
} catch (NoSuchMethodError e) {
|
||||
//Ignore error, defaut to optional
|
||||
}
|
||||
//wsaw wsdl binding case will have some value set on wbo
|
||||
return wbo != null ? wbo.getAnonymous() : WSDLBoundOperation.ANONYMOUS.optional;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkAnonymousSemantics(WSDLBoundOperation wbo, WSEndpointReference replyTo, WSEndpointReference faultTo) {
|
||||
String replyToValue = null;
|
||||
String faultToValue = null;
|
||||
|
||||
if (replyTo != null)
|
||||
replyToValue = replyTo.getAddress();
|
||||
|
||||
if (faultTo != null)
|
||||
faultToValue = faultTo.getAddress();
|
||||
WSDLBoundOperation.ANONYMOUS responseRequirement = getResponseRequirement(wbo);
|
||||
|
||||
switch (responseRequirement) {
|
||||
case prohibited:
|
||||
if (replyToValue != null && replyToValue.equals(addressingVersion.anonymousUri))
|
||||
throw new InvalidAddressingHeaderException(addressingVersion.replyToTag, ONLY_NON_ANONYMOUS_ADDRESS_SUPPORTED);
|
||||
|
||||
if (faultToValue != null && faultToValue.equals(addressingVersion.anonymousUri))
|
||||
throw new InvalidAddressingHeaderException(addressingVersion.faultToTag, ONLY_NON_ANONYMOUS_ADDRESS_SUPPORTED);
|
||||
break;
|
||||
case required:
|
||||
if (replyToValue != null && !replyToValue.equals(addressingVersion.anonymousUri))
|
||||
throw new InvalidAddressingHeaderException(addressingVersion.replyToTag, ONLY_ANONYMOUS_ADDRESS_SUPPORTED);
|
||||
|
||||
if (faultToValue != null && !faultToValue.equals(addressingVersion.anonymousUri))
|
||||
throw new InvalidAddressingHeaderException(addressingVersion.faultToTag, ONLY_ANONYMOUS_ADDRESS_SUPPORTED);
|
||||
break;
|
||||
default:
|
||||
// ALL: no check
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import com.sun.xml.internal.stream.buffer.XMLStreamBuffer;
|
||||
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
|
||||
/**
|
||||
* Implementation backed by XMLStreamBuffer
|
||||
*
|
||||
* @author Rama.Pulavarthi@sun.com
|
||||
*/
|
||||
public class WSEPRExtension extends WSEndpointReference.EPRExtension {
|
||||
XMLStreamBuffer xsb;
|
||||
final QName qname;
|
||||
|
||||
public WSEPRExtension(XMLStreamBuffer xsb, QName qname) {
|
||||
this.xsb = xsb;
|
||||
this.qname = qname;
|
||||
}
|
||||
|
||||
|
||||
public XMLStreamReader readAsXMLStreamReader() throws XMLStreamException {
|
||||
return xsb.readAsXMLStreamReader();
|
||||
}
|
||||
|
||||
public QName getQName() {
|
||||
return qname;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import com.sun.xml.internal.ws.api.model.CheckedException;
|
||||
import com.sun.xml.internal.ws.api.model.JavaMethod;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public class WsaActionUtil {
|
||||
|
||||
@SuppressWarnings("FinalStaticMethod")
|
||||
public static final String getDefaultFaultAction(JavaMethod method, CheckedException ce) {
|
||||
String tns = method.getOwner().getTargetNamespace();
|
||||
String delim = getDelimiter(tns);
|
||||
if (tns.endsWith(delim)) {
|
||||
tns = tns.substring(0, tns.length() - 1);
|
||||
}
|
||||
|
||||
return new StringBuilder(tns).append(delim).append(
|
||||
method.getOwner().getPortTypeName().getLocalPart()).append(
|
||||
delim).append(method.getOperationName()).append(delim).append("Fault").append(delim).append(ce.getExceptionClass().getSimpleName()).toString();
|
||||
}
|
||||
|
||||
private static String getDelimiter(String tns) {
|
||||
String delim = "/";
|
||||
// TODO: is this the correct way to find the separator ?
|
||||
try {
|
||||
URI uri = new URI(tns);
|
||||
if ((uri.getScheme() != null) && uri.getScheme().equalsIgnoreCase("urn")) {
|
||||
delim = ":";
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
LOGGER.warning("TargetNamespace of WebService is not a valid URI");
|
||||
}
|
||||
return delim;
|
||||
}
|
||||
private static final Logger LOGGER =
|
||||
Logger.getLogger(WsaActionUtil.class.getName());
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.ws.addressing.model.ActionNotSupportedException;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.message.AddressingUtils;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.pipe.NextAction;
|
||||
import com.sun.xml.internal.ws.api.pipe.Tube;
|
||||
import com.sun.xml.internal.ws.api.pipe.TubeCloner;
|
||||
import com.sun.xml.internal.ws.resources.AddressingMessages;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* WsaClientTube appears in the Tubeline only if addressing is enabled.
|
||||
* This tube checks the validity of addressing headers in the incoming messages
|
||||
* based on the WSDL model.
|
||||
* @author Rama Pulavarthi
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
public class WsaClientTube extends WsaTube {
|
||||
// capture if the request expects a reply so that it can be used to
|
||||
// determine if its oneway for response validation.
|
||||
protected boolean expectReply = true;
|
||||
public WsaClientTube(WSDLPort wsdlPort, WSBinding binding, Tube next) {
|
||||
super(wsdlPort, binding, next);
|
||||
}
|
||||
|
||||
public WsaClientTube(WsaClientTube that, TubeCloner cloner) {
|
||||
super(that, cloner);
|
||||
}
|
||||
|
||||
public WsaClientTube copy(TubeCloner cloner) {
|
||||
return new WsaClientTube(this, cloner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull NextAction processRequest(Packet request) {
|
||||
expectReply = request.expectReply;
|
||||
return doInvoke(next,request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull NextAction processResponse(Packet response) {
|
||||
// if one-way then, no validation
|
||||
if (response.getMessage() != null) {
|
||||
response = validateInboundHeaders(response);
|
||||
response.addSatellite(new WsaPropertyBag(addressingVersion,soapVersion,response));
|
||||
String msgId = AddressingUtils.
|
||||
getMessageID(response.getMessage().getHeaders(),
|
||||
addressingVersion, soapVersion);
|
||||
response.put(WsaPropertyBag.WSA_MSGID_FROM_REQUEST, msgId);
|
||||
}
|
||||
|
||||
return doReturnWith(response);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void validateAction(Packet packet) {
|
||||
//There may not be a WSDL operation. There may not even be a WSDL.
|
||||
//For instance this may be a RM CreateSequence message.
|
||||
WSDLBoundOperation wbo = getWSDLBoundOperation(packet);
|
||||
|
||||
if (wbo == null) return;
|
||||
|
||||
String gotA = AddressingUtils.getAction(
|
||||
packet.getMessage().getHeaders(),
|
||||
addressingVersion, soapVersion);
|
||||
if (gotA == null)
|
||||
throw new WebServiceException(AddressingMessages.VALIDATION_CLIENT_NULL_ACTION());
|
||||
|
||||
String expected = helper.getOutputAction(packet);
|
||||
|
||||
if (expected != null && !gotA.equals(expected))
|
||||
throw new ActionNotSupportedException(gotA);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import com.oracle.webservices.internal.api.message.BasePropertySet;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
|
||||
import com.sun.xml.internal.ws.api.message.AddressingUtils;
|
||||
import com.sun.xml.internal.ws.api.message.Header;
|
||||
import com.sun.xml.internal.ws.api.message.Message;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.developer.JAXWSProperties;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
|
||||
|
||||
/**
|
||||
* Provides access to the Addressing headers.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @author Rama Pulavarthi
|
||||
* @since 2.1.3
|
||||
*/
|
||||
public class WsaPropertyBag extends BasePropertySet {
|
||||
|
||||
public static final String WSA_REPLYTO_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.ReplyToFromRequest";
|
||||
public static final String WSA_FAULTTO_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.FaultToFromRequest";
|
||||
public static final String WSA_MSGID_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.MessageIdFromRequest";
|
||||
public static final String WSA_TO = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.To";
|
||||
|
||||
private final @NotNull AddressingVersion addressingVersion;
|
||||
private final @NotNull SOAPVersion soapVersion;
|
||||
/**
|
||||
* We can't store {@link Message} here as those may get replaced as
|
||||
* the packet travels through the pipeline.
|
||||
*/
|
||||
private final @NotNull Packet packet;
|
||||
|
||||
public WsaPropertyBag(AddressingVersion addressingVersion, SOAPVersion soapVersion, Packet packet) {
|
||||
this.addressingVersion = addressingVersion;
|
||||
this.soapVersion = soapVersion;
|
||||
this.packet = packet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <tt>wsa:To</tt> header.
|
||||
*
|
||||
* @return
|
||||
* null if the incoming SOAP message didn't have the header.
|
||||
*/
|
||||
@Property(JAXWSProperties.ADDRESSING_TO)
|
||||
public String getTo() throws XMLStreamException {
|
||||
if (packet.getMessage() == null) {
|
||||
return null;
|
||||
}
|
||||
Header h = packet.getMessage().getHeaders().get(addressingVersion.toTag, false);
|
||||
if(h==null) return null;
|
||||
return h.getStringContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <tt>wsa:To</tt> header.
|
||||
*
|
||||
* @return
|
||||
* null if the incoming SOAP message didn't have the header.
|
||||
*/
|
||||
@Property(WSA_TO)
|
||||
public WSEndpointReference getToAsReference() throws XMLStreamException {
|
||||
if (packet.getMessage() == null) {
|
||||
return null;
|
||||
}
|
||||
Header h = packet.getMessage().getHeaders().get(addressingVersion.toTag, false);
|
||||
if(h==null) return null;
|
||||
return new WSEndpointReference(h.getStringContent(),addressingVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <tt>wsa:From</tt> header.
|
||||
*
|
||||
* @return
|
||||
* null if the incoming SOAP message didn't have the header.
|
||||
*/
|
||||
@Property(JAXWSProperties.ADDRESSING_FROM)
|
||||
public WSEndpointReference getFrom() throws XMLStreamException {
|
||||
return getEPR(addressingVersion.fromTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <tt>wsa:Action</tt> header content as String.
|
||||
*
|
||||
* @return
|
||||
* null if the incoming SOAP message didn't have the header.
|
||||
*/
|
||||
@Property(JAXWSProperties.ADDRESSING_ACTION)
|
||||
public String getAction() {
|
||||
if (packet.getMessage() == null) {
|
||||
return null;
|
||||
}
|
||||
Header h = packet.getMessage().getHeaders().get(addressingVersion.actionTag, false);
|
||||
if(h==null) return null;
|
||||
return h.getStringContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <tt>wsa:MessageID</tt> header content as String.
|
||||
*
|
||||
* @return
|
||||
* null if the incoming SOAP message didn't have the header.
|
||||
*/
|
||||
// WsaServerTube.REQUEST_MESSAGE_ID is exposed for backward compatibility with 2.1
|
||||
@Property({JAXWSProperties.ADDRESSING_MESSAGEID,WsaServerTube.REQUEST_MESSAGE_ID})
|
||||
public String getMessageID() {
|
||||
if (packet.getMessage() == null) {
|
||||
return null;
|
||||
}
|
||||
return AddressingUtils.getMessageID(packet.getMessage().getHeaders(), addressingVersion,soapVersion);
|
||||
}
|
||||
|
||||
private WSEndpointReference getEPR(QName tag) throws XMLStreamException {
|
||||
if (packet.getMessage() == null) {
|
||||
return null;
|
||||
}
|
||||
Header h = packet.getMessage().getHeaders().get(tag, false);
|
||||
if(h==null) return null;
|
||||
return h.readAsEPR(addressingVersion);
|
||||
}
|
||||
|
||||
protected PropertyMap getPropertyMap() {
|
||||
return model;
|
||||
}
|
||||
|
||||
private static final PropertyMap model;
|
||||
static {
|
||||
model = parse(WsaPropertyBag.class);
|
||||
}
|
||||
|
||||
private WSEndpointReference _replyToFromRequest = null;
|
||||
|
||||
@Property(WSA_REPLYTO_FROM_REQUEST)
|
||||
public WSEndpointReference getReplyToFromRequest() {
|
||||
return _replyToFromRequest;
|
||||
}
|
||||
|
||||
public void setReplyToFromRequest(WSEndpointReference ref) {
|
||||
_replyToFromRequest = ref;
|
||||
}
|
||||
|
||||
private WSEndpointReference _faultToFromRequest = null;
|
||||
|
||||
@Property(WSA_FAULTTO_FROM_REQUEST)
|
||||
public WSEndpointReference getFaultToFromRequest() {
|
||||
return _faultToFromRequest;
|
||||
}
|
||||
|
||||
public void setFaultToFromRequest(WSEndpointReference ref) {
|
||||
_faultToFromRequest = ref;
|
||||
}
|
||||
|
||||
private String _msgIdFromRequest = null;
|
||||
|
||||
@Property(WSA_MSGID_FROM_REQUEST)
|
||||
public String getMessageIdFromRequest() {
|
||||
return _msgIdFromRequest;
|
||||
}
|
||||
|
||||
public void setMessageIdFromRequest(String id) {
|
||||
_msgIdFromRequest = id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,371 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.addressing.model.ActionNotSupportedException;
|
||||
import com.sun.xml.internal.ws.addressing.model.InvalidAddressingHeaderException;
|
||||
import com.sun.xml.internal.ws.api.EndpointAddress;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.addressing.NonAnonymousResponseProcessor;
|
||||
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
|
||||
import com.sun.xml.internal.ws.api.message.AddressingUtils;
|
||||
import com.sun.xml.internal.ws.api.message.Message;
|
||||
import com.sun.xml.internal.ws.api.message.MessageHeaders;
|
||||
import com.sun.xml.internal.ws.api.message.Messages;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.pipe.*;
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
import com.sun.xml.internal.ws.client.Stub;
|
||||
import com.sun.xml.internal.ws.developer.JAXWSProperties;
|
||||
import com.sun.xml.internal.ws.fault.SOAPFaultBuilder;
|
||||
import com.sun.xml.internal.ws.message.FaultDetailHeader;
|
||||
import com.sun.xml.internal.ws.resources.AddressingMessages;
|
||||
|
||||
import javax.xml.soap.SOAPFault;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import java.net.URI;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Handles WS-Addressing for the server.
|
||||
*
|
||||
* @author Rama Pulavarthi
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
public class WsaServerTube extends WsaTube {
|
||||
private WSEndpoint endpoint;
|
||||
// store the replyTo/faultTo of the message currently being processed.
|
||||
// both will be set to non-null in processRequest
|
||||
private WSEndpointReference replyTo;
|
||||
private WSEndpointReference faultTo;
|
||||
private boolean isAnonymousRequired = false;
|
||||
// Used by subclasses to avoid this class closing the transport back
|
||||
// channel based on the ReplyTo/FaultTo addrs being non-anonymous. False
|
||||
// can be useful in cases where special back-channel handling is required.
|
||||
protected boolean isEarlyBackchannelCloseAllowed = true;
|
||||
|
||||
/**
|
||||
* WSDLBoundOperation calculated on the Request payload.
|
||||
* Used for determining ReplyTo or Fault Action for non-anonymous responses *
|
||||
*/
|
||||
private WSDLBoundOperation wbo;
|
||||
public WsaServerTube(WSEndpoint endpoint, @NotNull WSDLPort wsdlPort, WSBinding binding, Tube next) {
|
||||
super(wsdlPort, binding, next);
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
public WsaServerTube(WsaServerTube that, TubeCloner cloner) {
|
||||
super(that, cloner);
|
||||
endpoint = that.endpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WsaServerTube copy(TubeCloner cloner) {
|
||||
return new WsaServerTube(this, cloner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull NextAction processRequest(Packet request) {
|
||||
Message msg = request.getMessage();
|
||||
if (msg == null) {
|
||||
return doInvoke(next,request);
|
||||
} // hmm?
|
||||
|
||||
// expose bunch of addressing related properties for advanced applications
|
||||
request.addSatellite(new WsaPropertyBag(addressingVersion,soapVersion,request));
|
||||
|
||||
// Store request ReplyTo and FaultTo in requestPacket.invocationProperties
|
||||
// so that they can be used after responsePacket is received.
|
||||
// These properties are used if a fault is thrown from the subsequent Pipe/Tubes.
|
||||
|
||||
MessageHeaders hl = request.getMessage().getHeaders();
|
||||
String msgId;
|
||||
try {
|
||||
replyTo = AddressingUtils.getReplyTo(hl, addressingVersion, soapVersion);
|
||||
faultTo = AddressingUtils.getFaultTo(hl, addressingVersion, soapVersion);
|
||||
msgId = AddressingUtils.getMessageID(hl, addressingVersion, soapVersion);
|
||||
} catch (InvalidAddressingHeaderException e) {
|
||||
|
||||
LOGGER.log(Level.WARNING, addressingVersion.getInvalidMapText()+", Problem header:" + e.getProblemHeader()+ ", Reason: "+ e.getSubsubcode(),e);
|
||||
|
||||
// problematic header must be removed since it can fail during Fault message processing
|
||||
hl.remove(e.getProblemHeader());
|
||||
|
||||
SOAPFault soapFault = helper.createInvalidAddressingHeaderFault(e, addressingVersion);
|
||||
// WS-A fault processing for one-way methods
|
||||
if ((wsdlPort!=null) && request.getMessage().isOneWay(wsdlPort)) {
|
||||
Packet response = request.createServerResponse(null, wsdlPort, null, binding);
|
||||
return doReturnWith(response);
|
||||
}
|
||||
|
||||
Message m = Messages.create(soapFault);
|
||||
if (soapVersion == SOAPVersion.SOAP_11) {
|
||||
FaultDetailHeader s11FaultDetailHeader = new FaultDetailHeader(addressingVersion, addressingVersion.problemHeaderQNameTag.getLocalPart(), e.getProblemHeader());
|
||||
m.getHeaders().add(s11FaultDetailHeader);
|
||||
}
|
||||
|
||||
Packet response = request.createServerResponse(m, wsdlPort, null, binding);
|
||||
return doReturnWith(response);
|
||||
}
|
||||
|
||||
// defaulting
|
||||
if (replyTo == null) {
|
||||
replyTo = addressingVersion.anonymousEpr;
|
||||
}
|
||||
if (faultTo == null) {
|
||||
faultTo = replyTo;
|
||||
}
|
||||
|
||||
// Save a copy into the packet such that we can save it with that
|
||||
// packet if we're going to deliver the response at a later time
|
||||
// (async from the request).
|
||||
request.put(WsaPropertyBag.WSA_REPLYTO_FROM_REQUEST, replyTo);
|
||||
request.put(WsaPropertyBag.WSA_FAULTTO_FROM_REQUEST, faultTo);
|
||||
request.put(WsaPropertyBag.WSA_MSGID_FROM_REQUEST, msgId);
|
||||
|
||||
wbo = getWSDLBoundOperation(request);
|
||||
isAnonymousRequired = isAnonymousRequired(wbo);
|
||||
|
||||
Packet p = validateInboundHeaders(request);
|
||||
// if one-way message and WS-A header processing fault has occurred,
|
||||
// then do no further processing
|
||||
if (p.getMessage() == null) {
|
||||
return doReturnWith(p);
|
||||
}
|
||||
|
||||
// if we find an error in addressing header, just turn around the direction here
|
||||
if (p.getMessage().isFault()) {
|
||||
// close the transportBackChannel if we know that
|
||||
// we'll never use them
|
||||
if (isEarlyBackchannelCloseAllowed &&
|
||||
!(isAnonymousRequired) &&
|
||||
!faultTo.isAnonymous() && request.transportBackChannel != null) {
|
||||
request.transportBackChannel.close();
|
||||
}
|
||||
return processResponse(p);
|
||||
}
|
||||
// close the transportBackChannel if we know that
|
||||
// we'll never use them
|
||||
if (isEarlyBackchannelCloseAllowed &&
|
||||
!(isAnonymousRequired) &&
|
||||
!replyTo.isAnonymous() && !faultTo.isAnonymous() &&
|
||||
request.transportBackChannel != null) {
|
||||
request.transportBackChannel.close();
|
||||
}
|
||||
return doInvoke(next,p);
|
||||
}
|
||||
|
||||
protected boolean isAnonymousRequired(@Nullable WSDLBoundOperation wbo) {
|
||||
//this requirement can only be specified in W3C case, Override this in W3C case.
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void checkAnonymousSemantics(WSDLBoundOperation wbo, WSEndpointReference replyTo, WSEndpointReference faultTo) {
|
||||
//this requirement can only be specified in W3C case, Override this in W3C case.
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull NextAction processException(Throwable t) {
|
||||
final Packet response = Fiber.current().getPacket();
|
||||
ThrowableContainerPropertySet tc = response.getSatellite(ThrowableContainerPropertySet.class);
|
||||
if (tc == null) {
|
||||
tc = new ThrowableContainerPropertySet(t);
|
||||
response.addSatellite(tc);
|
||||
} else if (t != tc.getThrowable()) {
|
||||
// This is a pathological case where an exception happens after a previous exception.
|
||||
// Make sure you report the latest one.
|
||||
tc.setThrowable(t);
|
||||
}
|
||||
return processResponse(response.endpoint.createServiceResponseForException(tc, response, soapVersion, wsdlPort,
|
||||
response.endpoint.getSEIModel(),
|
||||
binding));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull NextAction processResponse(Packet response) {
|
||||
Message msg = response.getMessage();
|
||||
if (msg ==null) {
|
||||
return doReturnWith(response);
|
||||
} // one way message. Nothing to see here. Move on.
|
||||
|
||||
String to = AddressingUtils.getTo(msg.getHeaders(),
|
||||
addressingVersion, soapVersion);
|
||||
if (to != null) {
|
||||
replyTo = faultTo = new WSEndpointReference(to, addressingVersion);
|
||||
}
|
||||
|
||||
if (replyTo == null) {
|
||||
// This is an async response or we're not processing the response in
|
||||
// the same tube instance as we processed the request. Get the ReplyTo
|
||||
// now, from the properties we stored into the request packet. We
|
||||
// assume anyone that interrupted the request->response flow will have
|
||||
// saved the ReplyTo and put it back into the packet for our use.
|
||||
replyTo = (WSEndpointReference)response.
|
||||
get(WsaPropertyBag.WSA_REPLYTO_FROM_REQUEST);
|
||||
}
|
||||
|
||||
if (faultTo == null) {
|
||||
// This is an async response or we're not processing the response in
|
||||
// the same tube instance as we processed the request. Get the FaultTo
|
||||
// now, from the properties we stored into the request packet. We
|
||||
// assume anyone that interrupted the request->response flow will have
|
||||
// saved the FaultTo and put it back into the packet for our use.
|
||||
faultTo = (WSEndpointReference)response.
|
||||
get(WsaPropertyBag.WSA_FAULTTO_FROM_REQUEST);
|
||||
}
|
||||
|
||||
WSEndpointReference target = msg.isFault() ? faultTo : replyTo;
|
||||
if (target == null && response.proxy instanceof Stub) {
|
||||
target = ((Stub) response.proxy).getWSEndpointReference();
|
||||
}
|
||||
if (target == null || target.isAnonymous() || isAnonymousRequired) {
|
||||
return doReturnWith(response);
|
||||
}
|
||||
if (target.isNone()) {
|
||||
// the caller doesn't want to hear about it, so proceed like one-way
|
||||
response.setMessage(null);
|
||||
return doReturnWith(response);
|
||||
}
|
||||
|
||||
if ((wsdlPort!=null) && response.getMessage().isOneWay(wsdlPort)) {
|
||||
// one way message but with replyTo. I believe this is a hack for WS-TX - KK.
|
||||
LOGGER.fine(AddressingMessages.NON_ANONYMOUS_RESPONSE_ONEWAY());
|
||||
return doReturnWith(response);
|
||||
}
|
||||
|
||||
// MTU: If we're not sending a response that corresponds to a WSDL op,
|
||||
// then take whatever soapAction is set on the packet (as allowing
|
||||
// helper.getOutputAction() will only result in a bogus 'unset'
|
||||
// action value.
|
||||
if (wbo != null || response.soapAction == null) {
|
||||
String action = response.getMessage().isFault() ?
|
||||
helper.getFaultAction(wbo, response) :
|
||||
helper.getOutputAction(wbo);
|
||||
//set the SOAPAction, as its got to be same as wsa:Action
|
||||
if (response.soapAction == null ||
|
||||
(action != null &&
|
||||
!action.equals(AddressingVersion.UNSET_OUTPUT_ACTION))) {
|
||||
response.soapAction = action;
|
||||
}
|
||||
}
|
||||
response.expectReply = false;
|
||||
|
||||
EndpointAddress adrs;
|
||||
try {
|
||||
adrs = new EndpointAddress(URI.create(target.getAddress()));
|
||||
} catch (NullPointerException e) {
|
||||
throw new WebServiceException(e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
|
||||
response.endpointAddress = adrs;
|
||||
|
||||
if (response.isAdapterDeliversNonAnonymousResponse) {
|
||||
return doReturnWith(response);
|
||||
}
|
||||
|
||||
return doReturnWith(NonAnonymousResponseProcessor.getDefault().process(response));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateAction(Packet packet) {
|
||||
//There may not be a WSDL operation. There may not even be a WSDL.
|
||||
//For instance this may be a RM CreateSequence message.
|
||||
WSDLBoundOperation wsdlBoundOperation = getWSDLBoundOperation(packet);
|
||||
|
||||
if (wsdlBoundOperation == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String gotA = AddressingUtils.getAction(
|
||||
packet.getMessage().getHeaders(),
|
||||
addressingVersion, soapVersion);
|
||||
|
||||
if (gotA == null) {
|
||||
throw new WebServiceException(AddressingMessages.VALIDATION_SERVER_NULL_ACTION());
|
||||
}
|
||||
|
||||
String expected = helper.getInputAction(packet);
|
||||
String soapAction = helper.getSOAPAction(packet);
|
||||
if (helper.isInputActionDefault(packet) && (soapAction != null && !soapAction.equals(""))) {
|
||||
expected = soapAction;
|
||||
}
|
||||
|
||||
if (expected != null && !gotA.equals(expected)) {
|
||||
throw new ActionNotSupportedException(gotA);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkMessageAddressingProperties(Packet packet) {
|
||||
super.checkMessageAddressingProperties(packet);
|
||||
|
||||
// wsaw:Anonymous validation
|
||||
WSDLBoundOperation wsdlBoundOperation = getWSDLBoundOperation(packet);
|
||||
checkAnonymousSemantics(wsdlBoundOperation, replyTo, faultTo);
|
||||
// check if addresses are valid
|
||||
checkNonAnonymousAddresses(replyTo,faultTo);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResultOfObjectAllocationIgnored")
|
||||
private void checkNonAnonymousAddresses(WSEndpointReference replyTo, WSEndpointReference faultTo) {
|
||||
if (!replyTo.isAnonymous()) {
|
||||
try {
|
||||
new EndpointAddress(URI.create(replyTo.getAddress()));
|
||||
} catch (Exception e) {
|
||||
throw new InvalidAddressingHeaderException(addressingVersion.replyToTag, addressingVersion.invalidAddressTag);
|
||||
}
|
||||
}
|
||||
//for now only validate ReplyTo
|
||||
/*
|
||||
if (!faultTo.isAnonymous()) {
|
||||
try {
|
||||
new EndpointAddress(URI.create(faultTo.getAddress()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new InvalidAddressingHeaderException(addressingVersion.faultToTag, addressingVersion.invalidAddressTag);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link JAXWSProperties#ADDRESSING_MESSAGEID}.
|
||||
*/
|
||||
public static final String REQUEST_MESSAGE_ID = "com.sun.xml.internal.ws.addressing.request.messageID";
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(WsaServerTube.class.getName());
|
||||
}
|
||||
405
jdkSrc/jdk8/com/sun/xml/internal/ws/addressing/WsaTube.java
Normal file
405
jdkSrc/jdk8/com/sun/xml/internal/ws/addressing/WsaTube.java
Normal file
@@ -0,0 +1,405 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.ws.addressing.model.InvalidAddressingHeaderException;
|
||||
import com.sun.xml.internal.ws.addressing.model.MissingAddressingHeaderException;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.message.AddressingUtils;
|
||||
import com.sun.xml.internal.ws.api.message.Header;
|
||||
import com.sun.xml.internal.ws.api.message.Message;
|
||||
import com.sun.xml.internal.ws.api.message.Messages;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.pipe.NextAction;
|
||||
import com.sun.xml.internal.ws.api.pipe.Tube;
|
||||
import com.sun.xml.internal.ws.api.pipe.TubeCloner;
|
||||
import com.sun.xml.internal.ws.api.pipe.helper.AbstractFilterTubeImpl;
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature;
|
||||
import com.sun.xml.internal.ws.message.FaultDetailHeader;
|
||||
import com.sun.xml.internal.ws.resources.AddressingMessages;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPFault;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.soap.AddressingFeature;
|
||||
import javax.xml.ws.soap.SOAPBinding;
|
||||
import java.util.Iterator;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* WS-Addressing processing code shared between client and server.
|
||||
*
|
||||
* <p>
|
||||
* This tube is used only when WS-Addressing is enabled.
|
||||
*
|
||||
* @author Rama Pulavarthi
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
abstract class WsaTube extends AbstractFilterTubeImpl {
|
||||
/**
|
||||
* Port that we are processing.
|
||||
*/
|
||||
protected final @NotNull WSDLPort wsdlPort;
|
||||
protected final WSBinding binding;
|
||||
final WsaTubeHelper helper;
|
||||
protected final @NotNull AddressingVersion addressingVersion;
|
||||
protected final SOAPVersion soapVersion;
|
||||
|
||||
/**
|
||||
* True if the addressing headers are mandatory.
|
||||
*/
|
||||
private final boolean addressingRequired;
|
||||
|
||||
public WsaTube(WSDLPort wsdlPort, WSBinding binding, Tube next) {
|
||||
super(next);
|
||||
this.wsdlPort = wsdlPort;
|
||||
this.binding = binding;
|
||||
addKnownHeadersToBinding(binding);
|
||||
addressingVersion = binding.getAddressingVersion();
|
||||
soapVersion = binding.getSOAPVersion();
|
||||
helper = getTubeHelper();
|
||||
addressingRequired = AddressingVersion.isRequired(binding);
|
||||
}
|
||||
|
||||
public WsaTube(WsaTube that, TubeCloner cloner) {
|
||||
super(that, cloner);
|
||||
this.wsdlPort = that.wsdlPort;
|
||||
this.binding = that.binding;
|
||||
this.helper = that.helper;
|
||||
addressingVersion = that.addressingVersion;
|
||||
soapVersion = that.soapVersion;
|
||||
addressingRequired = that.addressingRequired;
|
||||
}
|
||||
|
||||
private void addKnownHeadersToBinding(WSBinding binding) {
|
||||
for (AddressingVersion addrVersion: AddressingVersion.values()) {
|
||||
binding.addKnownHeader(addrVersion.actionTag);
|
||||
binding.addKnownHeader(addrVersion.faultDetailTag);
|
||||
binding.addKnownHeader(addrVersion.faultToTag);
|
||||
binding.addKnownHeader(addrVersion.fromTag);
|
||||
binding.addKnownHeader(addrVersion.messageIDTag);
|
||||
binding.addKnownHeader(addrVersion.relatesToTag);
|
||||
binding.addKnownHeader(addrVersion.replyToTag);
|
||||
binding.addKnownHeader(addrVersion.toTag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull NextAction processException(Throwable t) {
|
||||
return super.processException(t);
|
||||
}
|
||||
|
||||
protected WsaTubeHelper getTubeHelper() {
|
||||
if(binding.isFeatureEnabled(AddressingFeature.class)) {
|
||||
return new WsaTubeHelperImpl(wsdlPort, null, binding);
|
||||
} else if(binding.isFeatureEnabled(MemberSubmissionAddressingFeature.class)) {
|
||||
//seiModel is null as it is not needed.
|
||||
return new com.sun.xml.internal.ws.addressing.v200408.WsaTubeHelperImpl(wsdlPort, null, binding);
|
||||
} else {
|
||||
// Addressing is not enabled, WsaTube should not be included in the pipeline
|
||||
throw new WebServiceException(AddressingMessages.ADDRESSING_NOT_ENABLED(this.getClass().getSimpleName()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the inbound message. If an error is found, create
|
||||
* a fault message and returns that. Otherwise
|
||||
* it will pass through the parameter 'packet' object to the return value.
|
||||
*/
|
||||
protected Packet validateInboundHeaders(Packet packet) {
|
||||
SOAPFault soapFault;
|
||||
FaultDetailHeader s11FaultDetailHeader;
|
||||
|
||||
try {
|
||||
checkMessageAddressingProperties(packet);
|
||||
return packet;
|
||||
} catch (InvalidAddressingHeaderException e) {
|
||||
LOGGER.log(Level.WARNING,
|
||||
addressingVersion.getInvalidMapText()+", Problem header:" + e.getProblemHeader()+ ", Reason: "+ e.getSubsubcode(),e);
|
||||
soapFault = helper.createInvalidAddressingHeaderFault(e, addressingVersion);
|
||||
s11FaultDetailHeader = new FaultDetailHeader(addressingVersion, addressingVersion.problemHeaderQNameTag.getLocalPart(), e.getProblemHeader());
|
||||
} catch (MissingAddressingHeaderException e) {
|
||||
LOGGER.log(Level.WARNING,addressingVersion.getMapRequiredText()+", Problem header:"+ e.getMissingHeaderQName(),e);
|
||||
soapFault = helper.newMapRequiredFault(e);
|
||||
s11FaultDetailHeader = new FaultDetailHeader(addressingVersion, addressingVersion.problemHeaderQNameTag.getLocalPart(), e.getMissingHeaderQName());
|
||||
}
|
||||
|
||||
if (soapFault != null) {
|
||||
// WS-A fault processing for one-way methods
|
||||
if ((wsdlPort !=null) && packet.getMessage().isOneWay(wsdlPort)) {
|
||||
return packet.createServerResponse(null, wsdlPort, null, binding);
|
||||
}
|
||||
|
||||
Message m = Messages.create(soapFault);
|
||||
if (soapVersion == SOAPVersion.SOAP_11) {
|
||||
m.getHeaders().add(s11FaultDetailHeader);
|
||||
}
|
||||
|
||||
return packet.createServerResponse(m, wsdlPort, null, binding);
|
||||
}
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks all the WS-Addressing headers are valid and as per the spec definded rules.
|
||||
* Mainly it checks the cardinality of the WSA headers and checks that mandatory headers exist.
|
||||
* It also checks if the SOAPAction is equal to wsa:Action value when non-empty.
|
||||
*
|
||||
* Override this method if you need to additional checking of headers other than just existence of the headers.
|
||||
* For ex: On server-side, check Anonymous and Non-Anonymous semantics in addition to checking cardinality.
|
||||
*
|
||||
* Override checkMandatoryHeaders(Packet p) to have different validation rules for different versions
|
||||
*
|
||||
* @param packet
|
||||
*/
|
||||
protected void checkMessageAddressingProperties(Packet packet) {
|
||||
checkCardinality(packet);
|
||||
}
|
||||
|
||||
final boolean isAddressingEngagedOrRequired(Packet packet, WSBinding binding) {
|
||||
if (AddressingVersion.isRequired(binding))
|
||||
return true;
|
||||
|
||||
if (packet == null)
|
||||
return false;
|
||||
|
||||
if (packet.getMessage() == null)
|
||||
return false;
|
||||
|
||||
if (packet.getMessage().getHeaders() != null)
|
||||
return false;
|
||||
|
||||
String action = AddressingUtils.getAction(
|
||||
packet.getMessage().getHeaders(),
|
||||
addressingVersion, soapVersion);
|
||||
if (action == null)
|
||||
return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the cardinality of WS-Addressing headers on an inbound {@link Packet}. This method
|
||||
* checks for the cardinality if WS-Addressing is engaged (detected by the presence of wsa:Action
|
||||
* header) or wsdl:required=true.
|
||||
*
|
||||
* @param packet The inbound packet.
|
||||
* @throws WebServiceException if:
|
||||
* <ul>
|
||||
* <li>there is an error reading ReplyTo or FaultTo</li>
|
||||
* <li>WS-Addressing is required and {@link Message} within <code>packet</code> is null</li>
|
||||
* <li>WS-Addressing is required and no headers are found in the {@link Message}</li>
|
||||
* <li>an uknown WS-Addressing header is present</li>
|
||||
* </ul>
|
||||
*/
|
||||
protected void checkCardinality(Packet packet) {
|
||||
Message message = packet.getMessage();
|
||||
if (message == null) {
|
||||
if (addressingRequired)
|
||||
throw new WebServiceException(AddressingMessages.NULL_MESSAGE());
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<Header> hIter = message.getHeaders().getHeaders(addressingVersion.nsUri, true);
|
||||
|
||||
if (!hIter.hasNext()) {
|
||||
// no WS-A headers are found
|
||||
if (addressingRequired)
|
||||
// if WS-A is required, then throw an exception looking for wsa:Action header
|
||||
throw new MissingAddressingHeaderException(addressingVersion.actionTag,packet);
|
||||
else
|
||||
// else no need to process
|
||||
return;
|
||||
}
|
||||
|
||||
boolean foundFrom = false;
|
||||
boolean foundTo = false;
|
||||
boolean foundReplyTo = false;
|
||||
boolean foundFaultTo = false;
|
||||
boolean foundAction = false;
|
||||
boolean foundMessageId = false;
|
||||
boolean foundRelatesTo = false;
|
||||
QName duplicateHeader = null;
|
||||
|
||||
while (hIter.hasNext()) {
|
||||
Header h = hIter.next();
|
||||
|
||||
// check if the Header is in current role
|
||||
if (!isInCurrentRole(h, binding)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String local = h.getLocalPart();
|
||||
if (local.equals(addressingVersion.fromTag.getLocalPart())) {
|
||||
if (foundFrom) {
|
||||
duplicateHeader = addressingVersion.fromTag;
|
||||
break;
|
||||
}
|
||||
foundFrom = true;
|
||||
} else if (local.equals(addressingVersion.toTag.getLocalPart())) {
|
||||
if (foundTo) {
|
||||
duplicateHeader = addressingVersion.toTag;
|
||||
break;
|
||||
}
|
||||
foundTo = true;
|
||||
} else if (local.equals(addressingVersion.replyToTag.getLocalPart())) {
|
||||
if (foundReplyTo) {
|
||||
duplicateHeader = addressingVersion.replyToTag;
|
||||
break;
|
||||
}
|
||||
foundReplyTo = true;
|
||||
try { // verify that the header is in a good shape
|
||||
h.readAsEPR(addressingVersion);
|
||||
} catch (XMLStreamException e) {
|
||||
throw new WebServiceException(AddressingMessages.REPLY_TO_CANNOT_PARSE(), e);
|
||||
}
|
||||
} else if (local.equals(addressingVersion.faultToTag.getLocalPart())) {
|
||||
if (foundFaultTo) {
|
||||
duplicateHeader = addressingVersion.faultToTag;
|
||||
break;
|
||||
}
|
||||
foundFaultTo = true;
|
||||
try { // verify that the header is in a good shape
|
||||
h.readAsEPR(addressingVersion);
|
||||
} catch (XMLStreamException e) {
|
||||
throw new WebServiceException(AddressingMessages.FAULT_TO_CANNOT_PARSE(), e);
|
||||
}
|
||||
} else if (local.equals(addressingVersion.actionTag.getLocalPart())) {
|
||||
if (foundAction) {
|
||||
duplicateHeader = addressingVersion.actionTag;
|
||||
break;
|
||||
}
|
||||
foundAction = true;
|
||||
} else if (local.equals(addressingVersion.messageIDTag.getLocalPart())) {
|
||||
if (foundMessageId) {
|
||||
duplicateHeader = addressingVersion.messageIDTag;
|
||||
break;
|
||||
}
|
||||
foundMessageId = true;
|
||||
} else if (local.equals(addressingVersion.relatesToTag.getLocalPart())) {
|
||||
foundRelatesTo = true;
|
||||
} else if (local.equals(addressingVersion.faultDetailTag.getLocalPart())) {
|
||||
// TODO: should anything be done here ?
|
||||
// TODO: fault detail element - only for SOAP 1.1
|
||||
} else {
|
||||
System.err.println(AddressingMessages.UNKNOWN_WSA_HEADER());
|
||||
}
|
||||
}
|
||||
|
||||
// check for invalid cardinality first before checking for mandatory headers
|
||||
if (duplicateHeader != null) {
|
||||
throw new InvalidAddressingHeaderException(duplicateHeader, addressingVersion.invalidCardinalityTag);
|
||||
}
|
||||
|
||||
// WS-A is engaged if wsa:Action header is found
|
||||
boolean engaged = foundAction;
|
||||
|
||||
// check for mandatory set of headers only if:
|
||||
// 1. WS-A is engaged or
|
||||
// 2. wsdl:required=true
|
||||
// Both wsa:Action and wsa:To MUST be present on request (for oneway MEP) and
|
||||
// response messages (for oneway and request/response MEP only)
|
||||
if (engaged || addressingRequired) {
|
||||
// Check for mandatory headers always (even for Protocol messages).
|
||||
// If it breaks any interop scenarios, Remove the comments.
|
||||
/*
|
||||
WSDLBoundOperation wbo = getWSDLBoundOperation(packet);
|
||||
// no need to check for for non-application messages
|
||||
if (wbo == null)
|
||||
return;
|
||||
*/
|
||||
checkMandatoryHeaders(packet, foundAction, foundTo, foundReplyTo,
|
||||
foundFaultTo, foundMessageId, foundRelatesTo);
|
||||
}
|
||||
}
|
||||
|
||||
final boolean isInCurrentRole(Header header, WSBinding binding) {
|
||||
// TODO: binding will be null for protocol messages
|
||||
// TODO: returning true assumes that protocol messages are
|
||||
// TODO: always in current role, this may not to be fixed.
|
||||
if (binding == null)
|
||||
return true;
|
||||
return ((SOAPBinding)binding).getRoles().contains(header.getRole(soapVersion));
|
||||
|
||||
}
|
||||
|
||||
protected final WSDLBoundOperation getWSDLBoundOperation(Packet packet) {
|
||||
//we can find Req/Response or Oneway only with WSDLModel
|
||||
if(wsdlPort == null)
|
||||
return null;
|
||||
QName opName = packet.getWSDLOperation();
|
||||
if(opName != null)
|
||||
return wsdlPort.getBinding().get(opName);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void validateSOAPAction(Packet packet) {
|
||||
String gotA = AddressingUtils.getAction(
|
||||
packet.getMessage().getHeaders(),
|
||||
addressingVersion, soapVersion);
|
||||
if (gotA == null)
|
||||
throw new WebServiceException(AddressingMessages.VALIDATION_SERVER_NULL_ACTION());
|
||||
if(packet.soapAction != null && !packet.soapAction.equals("\"\"") && !packet.soapAction.equals("\""+gotA+"\"")) {
|
||||
throw new InvalidAddressingHeaderException(addressingVersion.actionTag, addressingVersion.actionMismatchTag);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void validateAction(Packet packet);
|
||||
|
||||
/**
|
||||
* This should be called only when Addressing is engaged.
|
||||
*
|
||||
* Checks only for presence of wsa:Action and validates that wsa:Action
|
||||
* equals SOAPAction header when non-empty
|
||||
* Should be overridden if other wsa headers need to be checked based on version.
|
||||
*
|
||||
* @param packet
|
||||
* @param foundAction
|
||||
* @param foundTo
|
||||
* @param foundReplyTo
|
||||
* @param foundFaultTo
|
||||
* @param foundMessageId
|
||||
* @param foundRelatesTo
|
||||
*/
|
||||
protected void checkMandatoryHeaders(
|
||||
Packet packet, boolean foundAction, boolean foundTo, boolean foundReplyTo,
|
||||
boolean foundFaultTo, boolean foundMessageId, boolean foundRelatesTo) {
|
||||
// if no wsa:Action header is found
|
||||
if (!foundAction)
|
||||
throw new MissingAddressingHeaderException(addressingVersion.actionTag,packet);
|
||||
validateSOAPAction(packet);
|
||||
}
|
||||
private static final Logger LOGGER = Logger.getLogger(WsaTube.class.getName());
|
||||
}
|
||||
@@ -0,0 +1,360 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import com.sun.xml.internal.ws.addressing.model.InvalidAddressingHeaderException;
|
||||
import com.sun.xml.internal.ws.addressing.model.MissingAddressingHeaderException;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.message.AddressingUtils;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLFault;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLOperation;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.model.SEIModel;
|
||||
import com.sun.xml.internal.ws.api.model.JavaMethod;
|
||||
import com.sun.xml.internal.ws.api.model.WSDLOperationMapping;
|
||||
import com.sun.xml.internal.ws.model.JavaMethodImpl;
|
||||
import com.sun.xml.internal.ws.model.CheckedExceptionImpl;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.Detail;
|
||||
import javax.xml.soap.SOAPConstants;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPFactory;
|
||||
import javax.xml.soap.SOAPFault;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* @author Rama Pulavarthi
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
public abstract class WsaTubeHelper {
|
||||
|
||||
public WsaTubeHelper(WSBinding binding, SEIModel seiModel, WSDLPort wsdlPort) {
|
||||
this.binding = binding;
|
||||
this.wsdlPort = wsdlPort;
|
||||
this.seiModel = seiModel;
|
||||
this.soapVer = binding.getSOAPVersion();
|
||||
this.addVer = binding.getAddressingVersion();
|
||||
|
||||
}
|
||||
|
||||
public String getFaultAction(Packet requestPacket, Packet responsePacket) {
|
||||
String action = null;
|
||||
if(seiModel != null) {
|
||||
action = getFaultActionFromSEIModel(requestPacket,responsePacket);
|
||||
}
|
||||
if (action != null) {
|
||||
return action;
|
||||
} else {
|
||||
action = addVer.getDefaultFaultAction();
|
||||
}
|
||||
if (wsdlPort != null) {
|
||||
WSDLOperationMapping wsdlOp = requestPacket.getWSDLOperationMapping();
|
||||
if (wsdlOp != null) {
|
||||
WSDLBoundOperation wbo = wsdlOp.getWSDLBoundOperation();
|
||||
return getFaultAction(wbo, responsePacket);
|
||||
}
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
String getFaultActionFromSEIModel(Packet requestPacket, Packet responsePacket) {
|
||||
String action = null;
|
||||
if (seiModel == null || wsdlPort == null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
try {
|
||||
SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage();
|
||||
if (sm == null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
if (sm.getSOAPBody() == null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
if (sm.getSOAPBody().getFault() == null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
Detail detail = sm.getSOAPBody().getFault().getDetail();
|
||||
if (detail == null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
String ns = detail.getFirstChild().getNamespaceURI();
|
||||
String name = detail.getFirstChild().getLocalName();
|
||||
|
||||
WSDLOperationMapping wsdlOp = requestPacket.getWSDLOperationMapping();
|
||||
JavaMethodImpl jm = (wsdlOp != null) ? (JavaMethodImpl)wsdlOp.getJavaMethod() : null;
|
||||
if (jm != null) {
|
||||
for (CheckedExceptionImpl ce : jm.getCheckedExceptions()) {
|
||||
if (ce.getDetailType().tagName.getLocalPart().equals(name) &&
|
||||
ce.getDetailType().tagName.getNamespaceURI().equals(ns)) {
|
||||
return ce.getFaultAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
return action;
|
||||
} catch (SOAPException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
String getFaultAction(@Nullable WSDLBoundOperation wbo, Packet responsePacket) {
|
||||
String action = AddressingUtils.getAction(responsePacket.getMessage().getHeaders(), addVer, soapVer);
|
||||
if (action != null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
action = addVer.getDefaultFaultAction();
|
||||
if (wbo == null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
try {
|
||||
SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage();
|
||||
if (sm == null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
if (sm.getSOAPBody() == null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
if (sm.getSOAPBody().getFault() == null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
Detail detail = sm.getSOAPBody().getFault().getDetail();
|
||||
if (detail == null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
String ns = detail.getFirstChild().getNamespaceURI();
|
||||
String name = detail.getFirstChild().getLocalName();
|
||||
|
||||
WSDLOperation o = wbo.getOperation();
|
||||
|
||||
WSDLFault fault = o.getFault(new QName(ns, name));
|
||||
if (fault == null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
action = fault.getAction();
|
||||
|
||||
return action;
|
||||
} catch (SOAPException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getInputAction(Packet packet) {
|
||||
String action = null;
|
||||
|
||||
if (wsdlPort != null) {
|
||||
WSDLOperationMapping wsdlOp = packet.getWSDLOperationMapping();
|
||||
if (wsdlOp != null) {
|
||||
WSDLBoundOperation wbo = wsdlOp.getWSDLBoundOperation();
|
||||
WSDLOperation op = wbo.getOperation();
|
||||
action = op.getInput().getAction();
|
||||
}
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gives the Input addressing Action for a message.
|
||||
* It gives the Action set in the wsdl operation for the corresponding payload.
|
||||
* If it is not explicitly set, it gives the soapAction
|
||||
* @param packet
|
||||
* @return input Action
|
||||
*/
|
||||
public String getEffectiveInputAction(Packet packet) {
|
||||
//non-default SOAPAction beomes wsa:action
|
||||
if(packet.soapAction != null && !packet.soapAction.equals("")) {
|
||||
return packet.soapAction;
|
||||
}
|
||||
String action;
|
||||
|
||||
if (wsdlPort != null) {
|
||||
WSDLOperationMapping wsdlOp = packet.getWSDLOperationMapping();
|
||||
if (wsdlOp != null) {
|
||||
WSDLBoundOperation wbo = wsdlOp.getWSDLBoundOperation();
|
||||
WSDLOperation op = wbo.getOperation();
|
||||
action = op.getInput().getAction();
|
||||
} else {
|
||||
action = packet.soapAction;
|
||||
}
|
||||
} else {
|
||||
action = packet.soapAction;
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
public boolean isInputActionDefault(Packet packet) {
|
||||
if (wsdlPort == null) {
|
||||
return false;
|
||||
}
|
||||
WSDLOperationMapping wsdlOp = packet.getWSDLOperationMapping();
|
||||
if(wsdlOp == null) {
|
||||
return false;
|
||||
}
|
||||
WSDLBoundOperation wbo = wsdlOp.getWSDLBoundOperation();
|
||||
WSDLOperation op = wbo.getOperation();
|
||||
return op.getInput().isDefaultAction();
|
||||
|
||||
}
|
||||
|
||||
public String getSOAPAction(Packet packet) {
|
||||
String action = "";
|
||||
|
||||
if (packet == null || packet.getMessage() == null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
if (wsdlPort == null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
WSDLOperationMapping wsdlOp = packet.getWSDLOperationMapping();
|
||||
if (wsdlOp == null) {
|
||||
return action;
|
||||
}
|
||||
|
||||
WSDLBoundOperation op = wsdlOp.getWSDLBoundOperation();
|
||||
action = op.getSOAPAction();
|
||||
return action;
|
||||
}
|
||||
|
||||
public String getOutputAction(Packet packet) {
|
||||
//String action = AddressingVersion.UNSET_OUTPUT_ACTION;
|
||||
String action = null;
|
||||
WSDLOperationMapping wsdlOp = packet.getWSDLOperationMapping();
|
||||
if (wsdlOp != null) {
|
||||
JavaMethod javaMethod = wsdlOp.getJavaMethod();
|
||||
if (javaMethod != null) {
|
||||
JavaMethodImpl jm = (JavaMethodImpl) javaMethod;
|
||||
if (jm != null && jm.getOutputAction() != null && !jm.getOutputAction().equals("")) {
|
||||
return jm.getOutputAction();
|
||||
}
|
||||
}
|
||||
WSDLBoundOperation wbo = wsdlOp.getWSDLBoundOperation();
|
||||
if (wbo != null) return getOutputAction(wbo);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
String getOutputAction(@Nullable WSDLBoundOperation wbo) {
|
||||
String action = AddressingVersion.UNSET_OUTPUT_ACTION;
|
||||
if (wbo != null) {
|
||||
WSDLOutput op = wbo.getOperation().getOutput();
|
||||
if (op != null) {
|
||||
action = op.getAction();
|
||||
}
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
public SOAPFault createInvalidAddressingHeaderFault(InvalidAddressingHeaderException e, AddressingVersion av) {
|
||||
QName name = e.getProblemHeader();
|
||||
QName subsubcode = e.getSubsubcode();
|
||||
QName subcode = av.invalidMapTag;
|
||||
String faultstring = String.format(av.getInvalidMapText(), name, subsubcode);
|
||||
|
||||
try {
|
||||
SOAPFactory factory;
|
||||
SOAPFault fault;
|
||||
if (soapVer == SOAPVersion.SOAP_12) {
|
||||
factory = SOAPVersion.SOAP_12.getSOAPFactory();
|
||||
fault = factory.createFault();
|
||||
fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
|
||||
fault.appendFaultSubcode(subcode);
|
||||
fault.appendFaultSubcode(subsubcode);
|
||||
getInvalidMapDetail(name, fault.addDetail());
|
||||
} else {
|
||||
factory = SOAPVersion.SOAP_11.getSOAPFactory();
|
||||
fault = factory.createFault();
|
||||
fault.setFaultCode(subsubcode);
|
||||
}
|
||||
|
||||
fault.setFaultString(faultstring);
|
||||
|
||||
return fault;
|
||||
} catch (SOAPException se) {
|
||||
throw new WebServiceException(se);
|
||||
}
|
||||
}
|
||||
|
||||
public SOAPFault newMapRequiredFault(MissingAddressingHeaderException e) {
|
||||
QName subcode = addVer.mapRequiredTag;
|
||||
QName subsubcode = addVer.mapRequiredTag;
|
||||
String faultstring = addVer.getMapRequiredText();
|
||||
|
||||
try {
|
||||
SOAPFactory factory;
|
||||
SOAPFault fault;
|
||||
if (soapVer == SOAPVersion.SOAP_12) {
|
||||
factory = SOAPVersion.SOAP_12.getSOAPFactory();
|
||||
fault = factory.createFault();
|
||||
fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
|
||||
fault.appendFaultSubcode(subcode);
|
||||
fault.appendFaultSubcode(subsubcode);
|
||||
getMapRequiredDetail(e.getMissingHeaderQName(), fault.addDetail());
|
||||
} else {
|
||||
factory = SOAPVersion.SOAP_11.getSOAPFactory();
|
||||
fault = factory.createFault();
|
||||
fault.setFaultCode(subsubcode);
|
||||
}
|
||||
|
||||
fault.setFaultString(faultstring);
|
||||
|
||||
return fault;
|
||||
} catch (SOAPException se) {
|
||||
throw new WebServiceException(se);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void getProblemActionDetail(String action, Element element);
|
||||
public abstract void getInvalidMapDetail(QName name, Element element);
|
||||
public abstract void getMapRequiredDetail(QName name, Element element);
|
||||
|
||||
protected SEIModel seiModel;
|
||||
protected WSDLPort wsdlPort;
|
||||
protected WSBinding binding;
|
||||
protected final SOAPVersion soapVer;
|
||||
protected final AddressingVersion addVer;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.model.SEIModel;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
public class WsaTubeHelperImpl extends WsaTubeHelper {
|
||||
static final JAXBContext jc;
|
||||
|
||||
static {
|
||||
try {
|
||||
jc = JAXBContext.newInstance(ProblemAction.class,
|
||||
ProblemHeaderQName.class);
|
||||
} catch (JAXBException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public WsaTubeHelperImpl(WSDLPort wsdlPort, SEIModel seiModel, WSBinding binding) {
|
||||
super(binding,seiModel,wsdlPort);
|
||||
}
|
||||
|
||||
private Marshaller createMarshaller() throws JAXBException {
|
||||
Marshaller marshaller = jc.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
|
||||
return marshaller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void getProblemActionDetail(String action, Element element) {
|
||||
ProblemAction pa = new ProblemAction(action);
|
||||
try {
|
||||
createMarshaller().marshal(pa, element);
|
||||
} catch (JAXBException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void getInvalidMapDetail(QName name, Element element) {
|
||||
ProblemHeaderQName phq = new ProblemHeaderQName(name);
|
||||
try {
|
||||
createMarshaller().marshal(phq, element);
|
||||
} catch (JAXBException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void getMapRequiredDetail(QName name, Element element) {
|
||||
getInvalidMapDetail(name, element);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing.model;
|
||||
|
||||
import com.sun.xml.internal.ws.resources.AddressingMessages;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
public class ActionNotSupportedException extends WebServiceException {
|
||||
private String action;
|
||||
|
||||
public ActionNotSupportedException(String action) {
|
||||
super(AddressingMessages.ACTION_NOT_SUPPORTED_EXCEPTION(action));
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing.model;
|
||||
|
||||
import com.sun.xml.internal.ws.resources.AddressingMessages;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* This exception captures SOAP Fault information when a WS-Addressing 1.0 Message Addressing
|
||||
* Property is invalid and cannot be processed.
|
||||
*
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public class InvalidAddressingHeaderException extends WebServiceException {
|
||||
private QName problemHeader;
|
||||
private QName subsubcode;
|
||||
|
||||
/**
|
||||
* Creates a InvalidAddressingHeader exception capturing information about the invalid
|
||||
* Addressing Message Property and the reason in Subsubcode.
|
||||
* @param problemHeader
|
||||
* represents the invalid Addressing Header.
|
||||
* @param subsubcode
|
||||
* represents the reason why the Addressing header in question is invalid.
|
||||
*/
|
||||
public InvalidAddressingHeaderException(QName problemHeader, QName subsubcode) {
|
||||
super(AddressingMessages.INVALID_ADDRESSING_HEADER_EXCEPTION(problemHeader,subsubcode));
|
||||
this.problemHeader = problemHeader;
|
||||
this.subsubcode = subsubcode;
|
||||
}
|
||||
|
||||
public QName getProblemHeader() {
|
||||
return problemHeader;
|
||||
}
|
||||
|
||||
public QName getSubsubcode() {
|
||||
return subsubcode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing.model;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.resources.AddressingMessages;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* This exception signals that a particular WS-Addressing header is missing in a SOAP message.
|
||||
*
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public class MissingAddressingHeaderException extends WebServiceException {
|
||||
private final QName name;
|
||||
private transient final Packet packet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name QName of the missing WS-Addressing Header
|
||||
*/
|
||||
public MissingAddressingHeaderException(@NotNull QName name) {
|
||||
this(name,null);
|
||||
}
|
||||
|
||||
public MissingAddressingHeaderException(@NotNull QName name, @Nullable Packet p) {
|
||||
super(AddressingMessages.MISSING_HEADER_EXCEPTION(name));
|
||||
this.name = name;
|
||||
this.packet = p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the QName of the missing WS-Addressing Header.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*/
|
||||
public QName getMissingHeaderQName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link Packet} in which a header was missing.
|
||||
*
|
||||
* <p>
|
||||
* This object can be used to deep-inspect the problematic SOAP message.
|
||||
*/
|
||||
public Packet getPacket() {
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing.policy;
|
||||
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.policy.AssertionSet;
|
||||
import com.sun.xml.internal.ws.policy.NestedPolicy;
|
||||
import com.sun.xml.internal.ws.policy.Policy;
|
||||
import com.sun.xml.internal.ws.policy.PolicyAssertion;
|
||||
import com.sun.xml.internal.ws.policy.PolicyException;
|
||||
import com.sun.xml.internal.ws.policy.PolicyMap;
|
||||
import com.sun.xml.internal.ws.policy.PolicyMapKey;
|
||||
import com.sun.xml.internal.ws.policy.jaxws.spi.PolicyFeatureConfigurator;
|
||||
import com.sun.xml.internal.ws.policy.privateutil.PolicyLogger;
|
||||
import com.sun.xml.internal.ws.addressing.W3CAddressingMetadataConstants;
|
||||
import com.sun.xml.internal.ws.resources.ModelerMessages;
|
||||
import com.sun.xml.internal.bind.util.Which;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.logging.Level;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.soap.AddressingFeature;
|
||||
|
||||
/**
|
||||
* This Policy extension configures the WSDLModel with AddressingFeature when Addressing assertions are present in the
|
||||
* PolicyMap.
|
||||
*
|
||||
* @author japod
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public class AddressingFeatureConfigurator implements PolicyFeatureConfigurator {
|
||||
|
||||
private static final PolicyLogger LOGGER = PolicyLogger.getLogger(AddressingFeatureConfigurator.class);
|
||||
|
||||
private static final QName[] ADDRESSING_ASSERTIONS = {
|
||||
new QName(AddressingVersion.MEMBER.policyNsUri, "UsingAddressing")};
|
||||
|
||||
/**
|
||||
* Creates a new instance of AddressingFeatureConfigurator
|
||||
*/
|
||||
public AddressingFeatureConfigurator() {
|
||||
}
|
||||
|
||||
public Collection<WebServiceFeature> getFeatures(final PolicyMapKey key, final PolicyMap policyMap) throws PolicyException {
|
||||
LOGGER.entering(key, policyMap);
|
||||
final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
|
||||
if ((key != null) && (policyMap != null)) {
|
||||
final Policy policy = policyMap.getEndpointEffectivePolicy(key);
|
||||
for (QName addressingAssertionQName : ADDRESSING_ASSERTIONS) {
|
||||
if ((policy != null) && policy.contains(addressingAssertionQName)) {
|
||||
final Iterator <AssertionSet> assertions = policy.iterator();
|
||||
while(assertions.hasNext()){
|
||||
final AssertionSet assertionSet = assertions.next();
|
||||
final Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
|
||||
while(policyAssertion.hasNext()){
|
||||
final PolicyAssertion assertion = policyAssertion.next();
|
||||
if(assertion.getName().equals(addressingAssertionQName)){
|
||||
final WebServiceFeature feature = AddressingVersion.getFeature(addressingAssertionQName.getNamespaceURI(), true, !assertion.isOptional());
|
||||
if (LOGGER.isLoggable(Level.FINE)) {
|
||||
LOGGER.fine("Added addressing feature \"" + feature + "\" for element \"" + key + "\"");
|
||||
}
|
||||
features.add(feature);
|
||||
} // end-if non optional wsa assertion found
|
||||
} // next assertion
|
||||
} // next alternative
|
||||
} // end-if policy contains wsa assertion
|
||||
} //end foreach addr assertion
|
||||
|
||||
// Deal with WS-Addressing 1.0 Metadata assertions
|
||||
if (policy != null && policy.contains(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION)) {
|
||||
for (AssertionSet assertions : policy) {
|
||||
for (PolicyAssertion assertion : assertions) {
|
||||
if (assertion.getName().equals(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION)) {
|
||||
NestedPolicy nestedPolicy = assertion.getNestedPolicy();
|
||||
boolean requiresAnonymousResponses = false;
|
||||
boolean requiresNonAnonymousResponses = false;
|
||||
if (nestedPolicy != null) {
|
||||
requiresAnonymousResponses = nestedPolicy.contains(W3CAddressingMetadataConstants.WSAM_ANONYMOUS_NESTED_ASSERTION);
|
||||
requiresNonAnonymousResponses = nestedPolicy.contains(W3CAddressingMetadataConstants.WSAM_NONANONYMOUS_NESTED_ASSERTION);
|
||||
}
|
||||
if(requiresAnonymousResponses && requiresNonAnonymousResponses) {
|
||||
throw new WebServiceException("Only one among AnonymousResponses and NonAnonymousResponses can be nested in an Addressing assertion");
|
||||
}
|
||||
|
||||
final WebServiceFeature feature;
|
||||
try {
|
||||
if (requiresAnonymousResponses) {
|
||||
feature = new AddressingFeature(true, !assertion.isOptional(), AddressingFeature.Responses.ANONYMOUS);
|
||||
} else if (requiresNonAnonymousResponses) {
|
||||
feature = new AddressingFeature(true, !assertion.isOptional(), AddressingFeature.Responses.NON_ANONYMOUS);
|
||||
} else {
|
||||
feature = new AddressingFeature(true, !assertion.isOptional());
|
||||
}
|
||||
} catch (NoSuchMethodError e) {
|
||||
throw LOGGER.logSevereException(new PolicyException(ModelerMessages.RUNTIME_MODELER_ADDRESSING_RESPONSES_NOSUCHMETHOD(toJar(Which.which(AddressingFeature.class))), e));
|
||||
}
|
||||
if (LOGGER.isLoggable(Level.FINE)) {
|
||||
LOGGER.fine("Added addressing feature \"" + feature + "\" for element \"" + key + "\"");
|
||||
}
|
||||
features.add(feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LOGGER.exiting(features);
|
||||
return features;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the URL String inside jar, returns the URL to the jar itself.
|
||||
*/
|
||||
private static String toJar(String url) {
|
||||
if(!url.startsWith("jar:"))
|
||||
return url;
|
||||
url = url.substring(4); // cut off jar:
|
||||
return url.substring(0,url.lastIndexOf('!')); // cut off everything after '!'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing.policy;
|
||||
|
||||
import com.sun.xml.internal.ws.addressing.W3CAddressingMetadataConstants;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.model.SEIModel;
|
||||
import com.sun.xml.internal.ws.policy.AssertionSet;
|
||||
import com.sun.xml.internal.ws.policy.Policy;
|
||||
import com.sun.xml.internal.ws.policy.PolicyAssertion;
|
||||
import com.sun.xml.internal.ws.policy.PolicyException;
|
||||
import com.sun.xml.internal.ws.policy.PolicyMap;
|
||||
import com.sun.xml.internal.ws.policy.PolicySubject;
|
||||
import com.sun.xml.internal.ws.policy.jaxws.spi.PolicyMapConfigurator;
|
||||
import com.sun.xml.internal.ws.policy.privateutil.PolicyLogger;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.AssertionData;
|
||||
import com.sun.xml.internal.ws.policy.subject.WsdlBindingSubject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.logging.Level;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.soap.AddressingFeature;
|
||||
|
||||
/**
|
||||
* Generate an addressing policy and updates the PolicyMap if AddressingFeature is enabled.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public class AddressingPolicyMapConfigurator implements PolicyMapConfigurator {
|
||||
|
||||
private static final PolicyLogger LOGGER = PolicyLogger.getLogger(AddressingPolicyMapConfigurator.class);
|
||||
|
||||
private static final class AddressingAssertion extends PolicyAssertion {
|
||||
/**
|
||||
* Creates an assertion with nested alternatives.
|
||||
*
|
||||
* @param assertionData
|
||||
* @param nestedAlternative
|
||||
*/
|
||||
AddressingAssertion(AssertionData assertionData, final AssertionSet nestedAlternative) {
|
||||
super(assertionData, null, nestedAlternative);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an assertion with no nested alternatives.
|
||||
*
|
||||
* @param assertionData
|
||||
*/
|
||||
AddressingAssertion(AssertionData assertionData) {
|
||||
super(assertionData, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Puts an addressing policy into the PolicyMap if the addressing feature was set.
|
||||
*/
|
||||
public Collection<PolicySubject> update(final PolicyMap policyMap, final SEIModel model, final WSBinding wsBinding)
|
||||
throws PolicyException {
|
||||
LOGGER.entering(policyMap, model, wsBinding);
|
||||
|
||||
Collection<PolicySubject> subjects = new ArrayList<PolicySubject>();
|
||||
if (policyMap != null) {
|
||||
final AddressingFeature addressingFeature = wsBinding.getFeature(AddressingFeature.class);
|
||||
if (LOGGER.isLoggable(Level.FINEST)) {
|
||||
LOGGER.finest("addressingFeature = " + addressingFeature);
|
||||
}
|
||||
if ((addressingFeature != null) && addressingFeature.isEnabled()) {
|
||||
//add wsam:Addrressing assertion if not exists.
|
||||
addWsamAddressing(subjects, policyMap, model, addressingFeature);
|
||||
}
|
||||
} // endif policy map not null
|
||||
LOGGER.exiting(subjects);
|
||||
return subjects;
|
||||
}
|
||||
|
||||
private void addWsamAddressing(Collection<PolicySubject> subjects, PolicyMap policyMap, SEIModel model, AddressingFeature addressingFeature)
|
||||
throws PolicyException {
|
||||
final QName bindingName = model.getBoundPortTypeName();
|
||||
final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName);
|
||||
final Policy addressingPolicy = createWsamAddressingPolicy(bindingName, addressingFeature);
|
||||
final PolicySubject addressingPolicySubject = new PolicySubject(wsdlSubject, addressingPolicy);
|
||||
subjects.add(addressingPolicySubject);
|
||||
if (LOGGER.isLoggable(Level.FINE)) {
|
||||
LOGGER.fine("Added addressing policy with ID \"" + addressingPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a policy with an WSAM Addressing assertion.
|
||||
*/
|
||||
private Policy createWsamAddressingPolicy(final QName bindingName, AddressingFeature af) {
|
||||
final ArrayList<AssertionSet> assertionSets = new ArrayList<AssertionSet>(1);
|
||||
final ArrayList<PolicyAssertion> assertions = new ArrayList<PolicyAssertion>(1);
|
||||
final AssertionData addressingData =
|
||||
AssertionData.createAssertionData(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION);
|
||||
if (!af.isRequired()) {
|
||||
addressingData.setOptionalAttribute(true);
|
||||
}
|
||||
try {
|
||||
AddressingFeature.Responses responses = af.getResponses();
|
||||
if (responses == AddressingFeature.Responses.ANONYMOUS) {
|
||||
AssertionData nestedAsserData = AssertionData.createAssertionData(W3CAddressingMetadataConstants.WSAM_ANONYMOUS_NESTED_ASSERTION);
|
||||
PolicyAssertion nestedAsser = new AddressingAssertion(nestedAsserData, null);
|
||||
assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(Collections.singleton(nestedAsser))));
|
||||
} else if (responses == AddressingFeature.Responses.NON_ANONYMOUS) {
|
||||
final AssertionData nestedAsserData = AssertionData.createAssertionData(W3CAddressingMetadataConstants.WSAM_NONANONYMOUS_NESTED_ASSERTION);
|
||||
PolicyAssertion nestedAsser = new AddressingAssertion(nestedAsserData, null);
|
||||
assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(Collections.singleton(nestedAsser))));
|
||||
} else {
|
||||
assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(null)));
|
||||
}
|
||||
} catch (NoSuchMethodError e) {
|
||||
//If JAX-WS 2.2 API is really required, it would been reported in @Addressing or wsam:Addressing processing
|
||||
//Don't add any nested assertion to mimic the 2.1 behavior
|
||||
assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(null)));
|
||||
}
|
||||
assertionSets.add(AssertionSet.createAssertionSet(assertions));
|
||||
return Policy.createPolicy(null, bindingName.getLocalPart() + "_WSAM_Addressing_Policy", assertionSets);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing.policy;
|
||||
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.policy.PolicyAssertion;
|
||||
import com.sun.xml.internal.ws.policy.NestedPolicy;
|
||||
import com.sun.xml.internal.ws.policy.privateutil.PolicyLogger;
|
||||
import com.sun.xml.internal.ws.policy.spi.PolicyAssertionValidator;
|
||||
import com.sun.xml.internal.ws.addressing.W3CAddressingMetadataConstants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* This class validates the Addressing assertions.
|
||||
* If the assertion is wsam:Addressing, it makes sure that only valid assertions are nested.
|
||||
*
|
||||
* @author japod
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public class AddressingPolicyValidator implements PolicyAssertionValidator {
|
||||
|
||||
private static final ArrayList<QName> supportedAssertions = new ArrayList<QName>();
|
||||
|
||||
static {
|
||||
supportedAssertions.add(new QName(AddressingVersion.MEMBER.policyNsUri, "UsingAddressing"));
|
||||
supportedAssertions.add(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION);
|
||||
supportedAssertions.add(W3CAddressingMetadataConstants.WSAM_ANONYMOUS_NESTED_ASSERTION);
|
||||
supportedAssertions.add(W3CAddressingMetadataConstants.WSAM_NONANONYMOUS_NESTED_ASSERTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of AddressingPolicyValidator
|
||||
*/
|
||||
public AddressingPolicyValidator() {
|
||||
}
|
||||
|
||||
public Fitness validateClientSide(PolicyAssertion assertion) {
|
||||
return supportedAssertions.contains(assertion.getName()) ? Fitness.SUPPORTED : Fitness.UNKNOWN;
|
||||
}
|
||||
|
||||
public Fitness validateServerSide(PolicyAssertion assertion) {
|
||||
if (!supportedAssertions.contains(assertion.getName()))
|
||||
return Fitness.UNKNOWN;
|
||||
|
||||
//Make sure wsam:Addressing contains only one of the allowed nested assertions.
|
||||
if (assertion.getName().equals(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION)) {
|
||||
NestedPolicy nestedPolicy = assertion.getNestedPolicy();
|
||||
if (nestedPolicy != null) {
|
||||
boolean requiresAnonymousResponses = false;
|
||||
boolean requiresNonAnonymousResponses = false;
|
||||
for (PolicyAssertion nestedAsser : nestedPolicy.getAssertionSet()) {
|
||||
if (nestedAsser.getName().equals(W3CAddressingMetadataConstants.WSAM_ANONYMOUS_NESTED_ASSERTION)) {
|
||||
requiresAnonymousResponses = true;
|
||||
} else if (nestedAsser.getName().equals(W3CAddressingMetadataConstants.WSAM_NONANONYMOUS_NESTED_ASSERTION)) {
|
||||
requiresNonAnonymousResponses = true;
|
||||
} else {
|
||||
LOGGER.warning("Found unsupported assertion:\n" + nestedAsser + "\nnested into assertion:\n" + assertion);
|
||||
return Fitness.UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (requiresAnonymousResponses && requiresNonAnonymousResponses) {
|
||||
LOGGER.warning("Only one among AnonymousResponses and NonAnonymousResponses can be nested in an Addressing assertion");
|
||||
return Fitness.INVALID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Fitness.SUPPORTED;
|
||||
}
|
||||
|
||||
public String[] declareSupportedDomains() {
|
||||
return new String[]{AddressingVersion.MEMBER.policyNsUri, AddressingVersion.W3C.policyNsUri, W3CAddressingMetadataConstants.WSAM_NAMESPACE_NAME};
|
||||
}
|
||||
|
||||
private static final PolicyLogger LOGGER = PolicyLogger.getLogger(AddressingPolicyValidator.class);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing.policy;
|
||||
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.policy.spi.PrefixMapper;
|
||||
import com.sun.xml.internal.ws.addressing.W3CAddressingMetadataConstants;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This supplies the prefixes for the namespaces under Addressing domain.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public class AddressingPrefixMapper implements PrefixMapper {
|
||||
|
||||
private static final Map<String, String> prefixMap = new HashMap<String, String>();
|
||||
|
||||
static {
|
||||
prefixMap.put(AddressingVersion.MEMBER.policyNsUri, "wsap");
|
||||
prefixMap.put(AddressingVersion.MEMBER.nsUri, "wsa");
|
||||
prefixMap.put(W3CAddressingMetadataConstants.WSAM_NAMESPACE_NAME,W3CAddressingMetadataConstants.WSAM_PREFIX_NAME);
|
||||
}
|
||||
|
||||
public Map<String, String> getPrefixMap() {
|
||||
return prefixMap;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing.v200408;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* Constants for Member Submission WS-Addressing version
|
||||
*
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
public interface MemberSubmissionAddressingConstants {
|
||||
public static final String WSA_NAMESPACE_NAME = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
|
||||
public static final String WSA_NAMESPACE_WSDL_NAME = WSA_NAMESPACE_NAME;
|
||||
public static final String WSA_NAMESPACE_POLICY_NAME = "http://schemas.xmlsoap.org/ws/2004/08/addressing/policy";
|
||||
|
||||
public static final QName WSA_ACTION_QNAME = new QName(WSA_NAMESPACE_NAME,"Action");
|
||||
|
||||
public static final String WSA_SERVICENAME_NAME = "ServiceName";
|
||||
public static final String WSA_PORTTYPE_NAME = "PortType";
|
||||
public static final String WSA_PORTNAME_NAME = "PortName";
|
||||
|
||||
public static final String WSA_ADDRESS_NAME = "Address";
|
||||
public static final QName WSA_ADDRESS_QNAME = new QName(WSA_NAMESPACE_NAME, WSA_ADDRESS_NAME);
|
||||
|
||||
public static final String WSA_EPR_NAME = "EndpointReference";
|
||||
public static final QName WSA_EPR_QNAME = new QName(WSA_NAMESPACE_NAME, WSA_EPR_NAME);
|
||||
|
||||
public static final String WSA_ANONYMOUS_ADDRESS = WSA_NAMESPACE_NAME + "/role/anonymous";
|
||||
public static final String WSA_NONE_ADDRESS = "";
|
||||
|
||||
public static final String WSA_DEFAULT_FAULT_ACTION = WSA_NAMESPACE_NAME + "/fault";
|
||||
|
||||
public static final QName INVALID_MAP_QNAME = new QName(WSA_NAMESPACE_NAME, "InvalidMessageInformationHeader");
|
||||
public static final QName MAP_REQUIRED_QNAME = new QName(WSA_NAMESPACE_NAME, "MessageInformationHeaderRequired");
|
||||
public static final QName DESTINATION_UNREACHABLE_QNAME = new QName(WSA_NAMESPACE_NAME, "DestinationUnreachable");
|
||||
public static final QName ACTION_NOT_SUPPORTED_QNAME = new QName(WSA_NAMESPACE_NAME, "ActionNotSupported");
|
||||
public static final QName ENDPOINT_UNAVAILABLE_QNAME = new QName(WSA_NAMESPACE_NAME, "EndpointUnavailable");
|
||||
|
||||
public static final String ACTION_NOT_SUPPORTED_TEXT = "The \"%s\" cannot be processed at the receiver.";
|
||||
public static final String DESTINATION_UNREACHABLE_TEXT = "No route can be determined to reach the destination role defined by the WS-Addressing To.";
|
||||
public static final String ENDPOINT_UNAVAILABLE_TEXT = "The endpoint is unable to process the message at this time.";
|
||||
public static final String INVALID_MAP_TEXT = "A message information header is not valid and the message cannot be processed.";
|
||||
public static final String MAP_REQUIRED_TEXT = "A required message information header, To, MessageID, or Action, is not present.";
|
||||
|
||||
public static final QName PROBLEM_ACTION_QNAME = new QName(WSA_NAMESPACE_NAME, "ProblemAction");
|
||||
public static final QName PROBLEM_HEADER_QNAME_QNAME = new QName(WSA_NAMESPACE_NAME, "ProblemHeaderQName");
|
||||
public static final QName FAULT_DETAIL_QNAME = new QName(WSA_NAMESPACE_NAME, "FaultDetail");
|
||||
|
||||
public
|
||||
static final String ANONYMOUS_EPR = "<EndpointReference xmlns=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">\n"+
|
||||
" <Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</Address>\n"+
|
||||
"</EndpointReference>";
|
||||
|
||||
public static final QName MEX_METADATA = new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "Metadata","mex");
|
||||
public static final QName MEX_METADATA_SECTION = new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "MetadataSection","mex");
|
||||
public static final String MEX_METADATA_DIALECT_ATTRIBUTE = "Dialect";
|
||||
public static final String MEX_METADATA_DIALECT_VALUE = "http://schemas.xmlsoap.org/wsdl/";
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing.v200408;
|
||||
|
||||
import com.sun.xml.internal.ws.addressing.WsaClientTube;
|
||||
import com.sun.xml.internal.ws.addressing.model.MissingAddressingHeaderException;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.message.AddressingUtils;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.pipe.Tube;
|
||||
import com.sun.xml.internal.ws.api.pipe.TubeCloner;
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionAddressing;
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature;
|
||||
|
||||
/**
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public class MemberSubmissionWsaClientTube extends WsaClientTube {
|
||||
private final MemberSubmissionAddressing.Validation validation;
|
||||
|
||||
public MemberSubmissionWsaClientTube(WSDLPort wsdlPort, WSBinding binding, Tube next) {
|
||||
super(wsdlPort, binding, next);
|
||||
validation = binding.getFeature(MemberSubmissionAddressingFeature.class).getValidation();
|
||||
|
||||
}
|
||||
|
||||
public MemberSubmissionWsaClientTube(MemberSubmissionWsaClientTube that, TubeCloner cloner) {
|
||||
super(that, cloner);
|
||||
this.validation = that.validation;
|
||||
|
||||
}
|
||||
public MemberSubmissionWsaClientTube copy(TubeCloner cloner) {
|
||||
return new MemberSubmissionWsaClientTube(this, cloner);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkMandatoryHeaders(Packet packet, boolean foundAction, boolean foundTo, boolean foundReplyTo,
|
||||
boolean foundFaultTo, boolean foundMessageID, boolean foundRelatesTo) {
|
||||
super.checkMandatoryHeaders(packet,foundAction,foundTo,foundReplyTo,foundFaultTo,foundMessageID,foundRelatesTo);
|
||||
|
||||
// if no wsa:To header is found
|
||||
if (!foundTo) {
|
||||
throw new MissingAddressingHeaderException(addressingVersion.toTag,packet);
|
||||
}
|
||||
|
||||
if (!validation.equals(MemberSubmissionAddressing.Validation.LAX)) {
|
||||
|
||||
// if it is not one-way, response must contain wsa:RelatesTo
|
||||
// RelatesTo required as per
|
||||
// Table 5-3 of http://www.w3.org/TR/2006/WD-ws-addr-wsdl-20060216/#wsdl11requestresponse
|
||||
if (expectReply && (packet.getMessage() != null) && !foundRelatesTo) {
|
||||
String action = AddressingUtils.getAction(packet.getMessage().getHeaders(), addressingVersion, soapVersion);
|
||||
// Don't check for AddressingFaults as
|
||||
// Faults for requests with duplicate MessageId will have no wsa:RelatesTo
|
||||
if (!packet.getMessage().isFault() || !action.equals(addressingVersion.getDefaultFaultAction())) {
|
||||
throw new MissingAddressingHeaderException(addressingVersion.relatesToTag,packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing.v200408;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.ws.addressing.WsaServerTube;
|
||||
import com.sun.xml.internal.ws.addressing.model.MissingAddressingHeaderException;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.pipe.Tube;
|
||||
import com.sun.xml.internal.ws.api.pipe.TubeCloner;
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionAddressing;
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature;
|
||||
|
||||
/**
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
public class MemberSubmissionWsaServerTube extends WsaServerTube {
|
||||
private final MemberSubmissionAddressing.Validation validation;
|
||||
public MemberSubmissionWsaServerTube(WSEndpoint endpoint, @NotNull WSDLPort wsdlPort, WSBinding binding, Tube next) {
|
||||
super(endpoint, wsdlPort, binding, next);
|
||||
validation = binding.getFeature(MemberSubmissionAddressingFeature.class).getValidation();
|
||||
}
|
||||
|
||||
public MemberSubmissionWsaServerTube(MemberSubmissionWsaServerTube that, TubeCloner cloner) {
|
||||
super(that, cloner);
|
||||
this.validation = that.validation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemberSubmissionWsaServerTube copy(TubeCloner cloner) {
|
||||
return new MemberSubmissionWsaServerTube(this, cloner);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkMandatoryHeaders(Packet packet, boolean foundAction, boolean foundTo, boolean foundReplyTo,
|
||||
boolean foundFaultTo, boolean foundMessageId, boolean foundRelatesTo) {
|
||||
|
||||
super.checkMandatoryHeaders(packet, foundAction, foundTo, foundReplyTo,
|
||||
foundFaultTo, foundMessageId, foundRelatesTo);
|
||||
|
||||
// if no wsa:To header is found
|
||||
if (!foundTo)
|
||||
throw new MissingAddressingHeaderException(addressingVersion.toTag,packet);
|
||||
|
||||
//we can find Req/Response or Oneway only with WSDLModel
|
||||
if (wsdlPort != null) {
|
||||
WSDLBoundOperation wbo = getWSDLBoundOperation(packet);
|
||||
// if two-way, must contain wsa:ReplyTo
|
||||
// Unlike W3C version, we cannot assume default value as anonymous if not present.
|
||||
// For protocol messages, don't check as they do not have any corresponding wsdl operations
|
||||
if (wbo != null && !wbo.getOperation().isOneWay() && !foundReplyTo) {
|
||||
throw new MissingAddressingHeaderException(addressingVersion.replyToTag,packet);
|
||||
}
|
||||
}
|
||||
if (!validation.equals(MemberSubmissionAddressing.Validation.LAX)) {
|
||||
// wsa:MessageId is required if wsa:ReplyTo is present.
|
||||
if ((foundReplyTo || foundFaultTo) && !foundMessageId)
|
||||
throw new MissingAddressingHeaderException(addressingVersion.messageIDTag,packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing.v200408;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import static com.sun.xml.internal.ws.addressing.v200408.MemberSubmissionAddressingConstants.WSA_NAMESPACE_NAME;
|
||||
/**
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
@XmlRootElement(name="ProblemAction", namespace= WSA_NAMESPACE_NAME)
|
||||
public class ProblemAction {
|
||||
|
||||
@XmlElement(name="Action", namespace= WSA_NAMESPACE_NAME)
|
||||
private String action;
|
||||
|
||||
@XmlElement(name="SoapAction", namespace=WSA_NAMESPACE_NAME)
|
||||
private String soapAction;
|
||||
|
||||
/** Creates a new instance of ProblemAction */
|
||||
public ProblemAction() {
|
||||
}
|
||||
|
||||
public ProblemAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public ProblemAction(String action, String soapAction) {
|
||||
this.action = action;
|
||||
this.soapAction = soapAction;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public String getSoapAction() {
|
||||
return soapAction;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing.v200408;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlValue;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import static com.sun.xml.internal.ws.addressing.v200408.MemberSubmissionAddressingConstants.WSA_NAMESPACE_NAME;
|
||||
|
||||
/**
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
@XmlRootElement(name="ProblemHeaderQName", namespace= WSA_NAMESPACE_NAME)
|
||||
public class ProblemHeaderQName {
|
||||
@XmlValue
|
||||
private QName value;
|
||||
|
||||
/** Creates a new instance of ProblemHeaderQName */
|
||||
public ProblemHeaderQName() {
|
||||
}
|
||||
|
||||
public ProblemHeaderQName(QName name) {
|
||||
this.value = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.addressing.v200408;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
import com.sun.xml.internal.ws.addressing.WsaTubeHelper;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.model.SEIModel;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
public class WsaTubeHelperImpl extends WsaTubeHelper {
|
||||
static final JAXBContext jc;
|
||||
|
||||
static {
|
||||
try {
|
||||
jc = JAXBContext.newInstance(ProblemAction.class,
|
||||
ProblemHeaderQName.class);
|
||||
} catch (JAXBException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public WsaTubeHelperImpl(WSDLPort wsdlPort, SEIModel seiModel, WSBinding binding) {
|
||||
super(binding,seiModel,wsdlPort);
|
||||
}
|
||||
|
||||
private Marshaller createMarshaller() throws JAXBException {
|
||||
Marshaller marshaller = jc.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
|
||||
return marshaller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void getProblemActionDetail(String action, Element element) {
|
||||
ProblemAction pa = new ProblemAction(action);
|
||||
try {
|
||||
createMarshaller().marshal(pa, element);
|
||||
} catch (JAXBException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void getInvalidMapDetail(QName name, Element element) {
|
||||
ProblemHeaderQName phq = new ProblemHeaderQName(name);
|
||||
try {
|
||||
createMarshaller().marshal(phq, element);
|
||||
} catch (JAXBException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void getMapRequiredDetail(QName name, Element element) {
|
||||
getInvalidMapDetail(name, element);
|
||||
}
|
||||
}
|
||||
450
jdkSrc/jdk8/com/sun/xml/internal/ws/api/BindingID.java
Normal file
450
jdkSrc/jdk8/com/sun/xml/internal/ws/api/BindingID.java
Normal file
@@ -0,0 +1,450 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.ws.api.message.Message;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.api.pipe.Tube;
|
||||
import com.sun.xml.internal.ws.binding.BindingImpl;
|
||||
import com.sun.xml.internal.ws.binding.SOAPBindingImpl;
|
||||
import com.sun.xml.internal.ws.binding.WebServiceFeatureList;
|
||||
import com.sun.xml.internal.ws.encoding.SOAPBindingCodec;
|
||||
import com.sun.xml.internal.ws.encoding.XMLHTTPBindingCodec;
|
||||
import com.sun.xml.internal.ws.encoding.soap.streaming.SOAPNamespaceConstants;
|
||||
import com.sun.xml.internal.ws.util.ServiceFinder;
|
||||
import com.sun.xml.internal.ws.developer.JAXWSProperties;
|
||||
|
||||
import javax.xml.ws.BindingType;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.handler.Handler;
|
||||
import javax.xml.ws.http.HTTPBinding;
|
||||
import javax.xml.ws.soap.MTOMFeature;
|
||||
import javax.xml.ws.soap.SOAPBinding;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Parsed binding ID string.
|
||||
*
|
||||
* <p>
|
||||
* {@link BindingID} is an immutable object that represents a binding ID,
|
||||
* much like how {@link URL} is a representation of an URL.
|
||||
* Like {@link URL}, this class offers a bunch of methods that let you
|
||||
* query various traits/properties of a binding ID.
|
||||
*
|
||||
* <p>
|
||||
* {@link BindingID} is extensible; one can plug in a parser from
|
||||
* {@link String} to {@link BindingID} to interpret binding IDs that
|
||||
* the JAX-WS RI does no a-priori knowledge of.
|
||||
* Technologies such as Tango uses this to make the JAX-WS RI understand
|
||||
* binding IDs defined in their world.
|
||||
*
|
||||
* Such technologies are free to extend this class and expose more characterstics.
|
||||
*
|
||||
* <p>
|
||||
* Even though this class defines a few well known constants, {@link BindingID}
|
||||
* instances do not necessarily have singleton semantics. Use {@link #equals(Object)}
|
||||
* for the comparison.
|
||||
*
|
||||
* <h3>{@link BindingID} and {@link WSBinding}</h3>
|
||||
* <p>
|
||||
* {@link WSBinding} is mutable and represents a particular "use" of a {@link BindingID}.
|
||||
* As such, it has state like a list of {@link Handler}s, which are inherently local
|
||||
* to a particular usage. For example, if you have two proxies, you need two instances.
|
||||
*
|
||||
* {@link BindingID}, OTOH, is immutable and thus the single instance
|
||||
* that represents "SOAP1.2/HTTP" can be shared and reused by all proxies in the same VM.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class BindingID {
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link WSBinding} (which is conceptually an "use"
|
||||
* of {@link BindingID}) from a {@link BindingID}.
|
||||
*
|
||||
* @return
|
||||
* Always a new instance.
|
||||
*/
|
||||
public final @NotNull WSBinding createBinding() {
|
||||
return BindingImpl.create(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns wsdl:binding@transport attribute. Sub classes
|
||||
* are expected to override this method to provide their transport
|
||||
* attribute.
|
||||
*
|
||||
* @return wsdl:binding@transport attribute
|
||||
* @since JAX-WS RI 2.1.6
|
||||
*/
|
||||
public @NotNull String getTransport() {
|
||||
return SOAPNamespaceConstants.TRANSPORT_HTTP;
|
||||
}
|
||||
|
||||
public final @NotNull WSBinding createBinding(WebServiceFeature... features) {
|
||||
return BindingImpl.create(this, features);
|
||||
}
|
||||
|
||||
public final @NotNull WSBinding createBinding(WSFeatureList features) {
|
||||
return createBinding(features.toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the SOAP version of this binding.
|
||||
*
|
||||
* TODO: clarify what to do with XML/HTTP binding
|
||||
*
|
||||
* @return
|
||||
* If the binding is using SOAP, this method returns
|
||||
* a {@link SOAPVersion} constant.
|
||||
*
|
||||
* If the binding is not based on SOAP, this method
|
||||
* returns null. See {@link Message} for how a non-SOAP
|
||||
* binding shall be handled by {@link Tube}s.
|
||||
*/
|
||||
public abstract SOAPVersion getSOAPVersion();
|
||||
|
||||
/**
|
||||
* Creates a new {@link Codec} for this binding.
|
||||
*
|
||||
* @param binding
|
||||
* Ocassionally some aspects of binding can be overridden by
|
||||
* {@link WSBinding} at runtime by users, so some {@link Codec}s
|
||||
* need to have access to {@link WSBinding} that it's working for.
|
||||
*/
|
||||
public abstract @NotNull Codec createEncoder(@NotNull WSBinding binding);
|
||||
|
||||
/**
|
||||
* Gets the binding ID, which uniquely identifies the binding.
|
||||
*
|
||||
* <p>
|
||||
* The relevant specs define the binding IDs and what they mean.
|
||||
* The ID is used in many places to identify the kind of binding
|
||||
* (such as SOAP1.1, SOAP1.2, REST, ...)
|
||||
*
|
||||
* @return
|
||||
* Always non-null same value.
|
||||
*/
|
||||
@Override
|
||||
public abstract String toString();
|
||||
|
||||
/**
|
||||
* Returna a new {@link WebServiceFeatureList} instance
|
||||
* that represents the features that are built into this binding ID.
|
||||
*
|
||||
* <p>
|
||||
* For example, {@link BindingID} for
|
||||
* <tt>"{@value SOAPBinding#SOAP11HTTP_MTOM_BINDING}"</tt>
|
||||
* would always return a list that has {@link MTOMFeature} enabled.
|
||||
*/
|
||||
public WebServiceFeatureList createBuiltinFeatureList() {
|
||||
return new WebServiceFeatureList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this binding can generate WSDL.
|
||||
*
|
||||
* <p>
|
||||
* For e.g.: SOAP 1.1 and "XSOAP 1.2" is supposed to return true
|
||||
* from this method. For SOAP1.2, there is no standard WSDL, so the
|
||||
* runtime is not generating one and it expects the WSDL is packaged.
|
||||
*
|
||||
*/
|
||||
public boolean canGenerateWSDL() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a parameter of this binding ID.
|
||||
*
|
||||
* <p>
|
||||
* Some binding ID, such as those for SOAP/HTTP, uses the URL
|
||||
* query syntax (like <tt>?mtom=true</tt>) to control
|
||||
* the optional part of the binding. This method obtains
|
||||
* the value for such optional parts.
|
||||
*
|
||||
* <p>
|
||||
* For implementors of the derived classes, if your binding ID
|
||||
* does not define such optional parts (such as the XML/HTTP binding ID),
|
||||
* then you should simply return the specified default value
|
||||
* (which is what this implementation does.)
|
||||
*
|
||||
* @param parameterName
|
||||
* The parameter name, such as "mtom" in the above example.
|
||||
* @param defaultValue
|
||||
* If this binding ID doesn't have the specified parameter explicitly,
|
||||
* this value will be returned.
|
||||
*
|
||||
* @return
|
||||
* the value of the parameter, if it's present (such as "true"
|
||||
* in the above example.) If not present, this method returns
|
||||
* the {@code defaultValue}.
|
||||
*/
|
||||
public String getParameter(String parameterName, String defaultValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the equality based on {@link #toString()}.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof BindingID))
|
||||
return false;
|
||||
return toString().equals(obj.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return toString().hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a binding ID string into a {@link BindingID} object.
|
||||
*
|
||||
* <p>
|
||||
* This method first checks for a few known values and then delegate
|
||||
* the parsing to {@link BindingIDFactory}.
|
||||
*
|
||||
* <p>
|
||||
* If parsing succeeds this method returns a value. Otherwise
|
||||
* throws {@link WebServiceException}.
|
||||
*
|
||||
* @throws WebServiceException
|
||||
* If the binding ID is not understood.
|
||||
*/
|
||||
public static @NotNull BindingID parse(String lexical) {
|
||||
if(lexical.equals(XML_HTTP.toString()))
|
||||
return XML_HTTP;
|
||||
if(lexical.equals(REST_HTTP.toString()))
|
||||
return REST_HTTP;
|
||||
if(belongsTo(lexical,SOAP11_HTTP.toString()))
|
||||
return customize(lexical,SOAP11_HTTP);
|
||||
if(belongsTo(lexical,SOAP12_HTTP.toString()))
|
||||
return customize(lexical,SOAP12_HTTP);
|
||||
if(belongsTo(lexical,SOAPBindingImpl.X_SOAP12HTTP_BINDING))
|
||||
return customize(lexical,X_SOAP12_HTTP);
|
||||
|
||||
// OK, it's none of the values JAX-WS understands.
|
||||
for( BindingIDFactory f : ServiceFinder.find(BindingIDFactory.class) ) {
|
||||
BindingID r = f.parse(lexical);
|
||||
if(r!=null)
|
||||
return r;
|
||||
}
|
||||
|
||||
// nobody understood this value
|
||||
throw new WebServiceException("Wrong binding ID: "+lexical);
|
||||
}
|
||||
|
||||
private static boolean belongsTo(String lexical, String id) {
|
||||
return lexical.equals(id) || lexical.startsWith(id+'?');
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses parameter portion and returns appropriately populated {@link SOAPHTTPImpl}
|
||||
*/
|
||||
private static SOAPHTTPImpl customize(String lexical, SOAPHTTPImpl base) {
|
||||
if(lexical.equals(base.toString()))
|
||||
return base;
|
||||
|
||||
// otherwise we must have query parameter
|
||||
// we assume the spec won't define any tricky parameters that require
|
||||
// complicated handling (such as %HH or non-ASCII char), so this parser
|
||||
// is quite simple-minded.
|
||||
SOAPHTTPImpl r = new SOAPHTTPImpl(base.getSOAPVersion(), lexical, base.canGenerateWSDL());
|
||||
try {
|
||||
// With X_SOAP12_HTTP, base != lexical and lexical does n't have any query string
|
||||
if(lexical.indexOf('?') == -1) {
|
||||
return r;
|
||||
}
|
||||
String query = URLDecoder.decode(lexical.substring(lexical.indexOf('?')+1),"UTF-8");
|
||||
for( String token : query.split("&") ) {
|
||||
int idx = token.indexOf('=');
|
||||
if(idx<0)
|
||||
throw new WebServiceException("Malformed binding ID (no '=' in "+token+")");
|
||||
r.parameters.put(token.substring(0,idx),token.substring(idx+1));
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new AssertionError(e); // UTF-8 is supported everywhere
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Figures out the binding from {@link BindingType} annotation.
|
||||
*
|
||||
* @return
|
||||
* default to {@link BindingID#SOAP11_HTTP}, if no such annotation is present.
|
||||
* @see #parse(String)
|
||||
*/
|
||||
public static @NotNull BindingID parse(Class<?> implClass) {
|
||||
BindingType bindingType = implClass.getAnnotation(BindingType.class);
|
||||
if (bindingType != null) {
|
||||
String bindingId = bindingType.value();
|
||||
if (bindingId.length() > 0) {
|
||||
return BindingID.parse(bindingId);
|
||||
}
|
||||
}
|
||||
return SOAP11_HTTP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constant that represents implementation specific SOAP1.2/HTTP which is
|
||||
* used to generate non-standard WSDLs
|
||||
*/
|
||||
public static final SOAPHTTPImpl X_SOAP12_HTTP = new SOAPHTTPImpl(
|
||||
SOAPVersion.SOAP_12, SOAPBindingImpl.X_SOAP12HTTP_BINDING, true);
|
||||
|
||||
/**
|
||||
* Constant that represents SOAP1.2/HTTP.
|
||||
*/
|
||||
public static final SOAPHTTPImpl SOAP12_HTTP = new SOAPHTTPImpl(
|
||||
SOAPVersion.SOAP_12, SOAPBinding.SOAP12HTTP_BINDING, true);
|
||||
/**
|
||||
* Constant that represents SOAP1.1/HTTP.
|
||||
*/
|
||||
public static final SOAPHTTPImpl SOAP11_HTTP = new SOAPHTTPImpl(
|
||||
SOAPVersion.SOAP_11, SOAPBinding.SOAP11HTTP_BINDING, true);
|
||||
|
||||
/**
|
||||
* Constant that represents SOAP1.2/HTTP.
|
||||
*/
|
||||
public static final SOAPHTTPImpl SOAP12_HTTP_MTOM = new SOAPHTTPImpl(
|
||||
SOAPVersion.SOAP_12, SOAPBinding.SOAP12HTTP_MTOM_BINDING, true, true);
|
||||
/**
|
||||
* Constant that represents SOAP1.1/HTTP.
|
||||
*/
|
||||
public static final SOAPHTTPImpl SOAP11_HTTP_MTOM = new SOAPHTTPImpl(
|
||||
SOAPVersion.SOAP_11, SOAPBinding.SOAP11HTTP_MTOM_BINDING, true, true);
|
||||
|
||||
|
||||
/**
|
||||
* Constant that represents REST.
|
||||
*/
|
||||
public static final BindingID XML_HTTP = new Impl(SOAPVersion.SOAP_11, HTTPBinding.HTTP_BINDING,false) {
|
||||
@Override
|
||||
public Codec createEncoder(WSBinding binding) {
|
||||
return new XMLHTTPBindingCodec(binding.getFeatures());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Constant that represents REST.
|
||||
*/
|
||||
private static final BindingID REST_HTTP = new Impl(SOAPVersion.SOAP_11, JAXWSProperties.REST_BINDING,true) {
|
||||
@Override
|
||||
public Codec createEncoder(WSBinding binding) {
|
||||
return new XMLHTTPBindingCodec(binding.getFeatures());
|
||||
}
|
||||
};
|
||||
|
||||
private static abstract class Impl extends BindingID {
|
||||
final SOAPVersion version;
|
||||
private final String lexical;
|
||||
private final boolean canGenerateWSDL;
|
||||
|
||||
public Impl(SOAPVersion version, String lexical, boolean canGenerateWSDL) {
|
||||
this.version = version;
|
||||
this.lexical = lexical;
|
||||
this.canGenerateWSDL = canGenerateWSDL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SOAPVersion getSOAPVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return lexical;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean canGenerateWSDL() {
|
||||
return canGenerateWSDL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal implementation for SOAP/HTTP.
|
||||
*/
|
||||
private static final class SOAPHTTPImpl extends Impl implements Cloneable {
|
||||
/*final*/ Map<String,String> parameters = new HashMap<String,String>();
|
||||
|
||||
static final String MTOM_PARAM = "mtom";
|
||||
|
||||
public SOAPHTTPImpl(SOAPVersion version, String lexical, boolean canGenerateWSDL) {
|
||||
super(version, lexical, canGenerateWSDL);
|
||||
}
|
||||
|
||||
public SOAPHTTPImpl(SOAPVersion version, String lexical, boolean canGenerateWSDL,
|
||||
boolean mtomEnabled) {
|
||||
this(version, lexical, canGenerateWSDL);
|
||||
String mtomStr = mtomEnabled ? "true" : "false";
|
||||
parameters.put(MTOM_PARAM, mtomStr);
|
||||
}
|
||||
|
||||
public @NotNull @Override Codec createEncoder(WSBinding binding) {
|
||||
return new SOAPBindingCodec(binding.getFeatures());
|
||||
}
|
||||
|
||||
private Boolean isMTOMEnabled() {
|
||||
String mtom = parameters.get(MTOM_PARAM);
|
||||
return mtom==null?null:Boolean.valueOf(mtom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebServiceFeatureList createBuiltinFeatureList() {
|
||||
WebServiceFeatureList r=super.createBuiltinFeatureList();
|
||||
Boolean mtom = isMTOMEnabled();
|
||||
if(mtom != null)
|
||||
r.add(new MTOMFeature(mtom));
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameter(String parameterName, String defaultValue) {
|
||||
if (parameters.get(parameterName) == null)
|
||||
return super.getParameter(parameterName, defaultValue);
|
||||
return parameters.get(parameterName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SOAPHTTPImpl clone() throws CloneNotSupportedException {
|
||||
return (SOAPHTTPImpl) super.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* Extension point to plug in additional {@link BindingID} parsing logic.
|
||||
*
|
||||
* <p>
|
||||
* When the JAX-WS RI is asked to parse a binding ID string into a {@link BindingID}
|
||||
* object, it uses service idiom to look for the implementations of this class
|
||||
* in the <tt>META-INF/services/...</tt>.
|
||||
*
|
||||
* @since JAX-WS 2.0.next
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see BindingID#parse(String)
|
||||
*/
|
||||
public abstract class BindingIDFactory {
|
||||
/**
|
||||
* Parses a binding ID string into {@link BindingID} if possible.
|
||||
*
|
||||
* @return
|
||||
* a non-null return value would cause the JAX-WS RI to consider
|
||||
* the parsing to be successful. No furhter {@link BindingIDFactory}
|
||||
* will be consulted.
|
||||
*
|
||||
* <p>
|
||||
* Retruning a null value indicates that this factory doesn't understand
|
||||
* this string, in which case the JAX-WS RI will keep asking next
|
||||
* {@link BindingIDFactory}.
|
||||
*
|
||||
* @throws WebServiceException
|
||||
* if the implementation understood the lexical value but it is not correct,
|
||||
* this exception can be thrown to abort the parsing with error.
|
||||
* No further {@link BindingIDFactory} will be consulted, and
|
||||
* {@link BindingID#parse(String)} will throw the exception.
|
||||
*/
|
||||
public abstract @Nullable BindingID parse(@NotNull String lexical) throws WebServiceException;
|
||||
|
||||
/**
|
||||
* Creates a {@link BindingID} for given transport and SOAPVersion.
|
||||
*
|
||||
* @return
|
||||
* a non-null return value would cause the JAX-WS RI to consider
|
||||
* the creation to be successful. No furhter {@link BindingIDFactory}
|
||||
* will be consulted.
|
||||
*
|
||||
* <p>
|
||||
* Retruning a null value indicates that this factory doesn't understand
|
||||
* the transport, in which case the JAX-WS RI will keep asking next
|
||||
* {@link BindingIDFactory}.
|
||||
*
|
||||
* @throws WebServiceException
|
||||
* if the implementation understood the transport but it is not correct,
|
||||
* this exception can be thrown to abort the creation with error.
|
||||
* No further {@link BindingIDFactory} will be consulted, and
|
||||
* {@link BindingID#create(String, SOAPVersion)} will throw the exception.
|
||||
*/
|
||||
public @Nullable BindingID create(@NotNull String transport, @NotNull SOAPVersion soapVersion) throws WebServiceException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
52
jdkSrc/jdk8/com/sun/xml/internal/ws/api/Cancelable.java
Normal file
52
jdkSrc/jdk8/com/sun/xml/internal/ws/api/Cancelable.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
/**
|
||||
* Interface for tasks that may be cancelled
|
||||
*
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public interface Cancelable {
|
||||
/**
|
||||
* Attempts to cancel execution of this task. This attempt will
|
||||
* fail if the task has already completed, has already been cancelled,
|
||||
* or could not be cancelled for some other reason. If successful,
|
||||
* and this task has not started when <tt>cancel</tt> is called,
|
||||
* this task should never run. If the task has already started,
|
||||
* then the <tt>mayInterruptIfRunning</tt> parameter determines
|
||||
* whether the thread executing this task should be interrupted in
|
||||
* an attempt to stop the task.
|
||||
*
|
||||
* @param mayInterruptIfRunning <tt>true</tt> if the thread executing this
|
||||
* task should be interrupted; otherwise, in-progress tasks are allowed
|
||||
* to complete
|
||||
* @return <tt>false</tt> if the task could not be cancelled,
|
||||
* typically because it has already completed normally;
|
||||
* <tt>true</tt> otherwise
|
||||
*/
|
||||
public void cancel(boolean mayInterruptIfRunning);
|
||||
}
|
||||
54
jdkSrc/jdk8/com/sun/xml/internal/ws/api/Component.java
Normal file
54
jdkSrc/jdk8/com/sun/xml/internal/ws/api/Component.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
|
||||
/**
|
||||
* Interface that allows components to hook up with each other.
|
||||
* Replaces {@link com.sun.xml.internal.ws.api.server.EndpointComponent} so that component
|
||||
* pattern can apply to more RI types.
|
||||
*
|
||||
* @since 2.2.6
|
||||
* @see WSEndpoint#getComponents()
|
||||
* @see ComponentRegistry
|
||||
*/
|
||||
public interface Component {
|
||||
/**
|
||||
* Gets the specified SPI.
|
||||
*
|
||||
* <p>
|
||||
* This method works as a kind of directory service
|
||||
* for SPIs, allowing various components to define private contract
|
||||
* and talk to each other.
|
||||
*
|
||||
* @return
|
||||
* null if such an SPI is not provided by this object.
|
||||
*/
|
||||
@Nullable <S> S getSPI(@NotNull Class<S> spiType);
|
||||
}
|
||||
53
jdkSrc/jdk8/com/sun/xml/internal/ws/api/ComponentEx.java
Normal file
53
jdkSrc/jdk8/com/sun/xml/internal/ws/api/ComponentEx.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
/**
|
||||
* Extended version of {@link Component}. Allows component to return multiple
|
||||
* SPI implementations through an {@link Iterable}.
|
||||
*
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public interface ComponentEx extends Component {
|
||||
/**
|
||||
* Gets an iterator of implementations of the specified SPI.
|
||||
*
|
||||
* <p>
|
||||
* This method works as a kind of directory service
|
||||
* for SPIs, allowing various components to define private contract
|
||||
* and talk to each other. However unlike {@link Component#getSPI(java.lang.Class)}, this
|
||||
* method can support cases where there is an ordered collection (defined
|
||||
* by {@link Iterable} of implementations. The SPI contract should define
|
||||
* whether lookups are for the first appropriate implementation or whether
|
||||
* all returned implementations should be used.
|
||||
*
|
||||
* @return
|
||||
* non-null {@link Iterable} of the SPI's provided by this object. Iterator may have no values.
|
||||
*/
|
||||
@NotNull <S> Iterable<S> getIterableSPI(@NotNull Class<S> spiType);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import com.sun.xml.internal.ws.api.server.Container;
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
import com.sun.xml.internal.ws.client.Stub;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
/**
|
||||
* Allows registration of a {@link Component} against the {@link ComponentRegistry} implementations
|
||||
* of the {@link Container}, {@link WSEndpoint}, {@link WSService}, or {@link Stub}. The
|
||||
* registration is guaranteed to occur early in the initialization of these objects prior to tubeline creation
|
||||
* (applicable to endpoint and stub only).
|
||||
* <p>
|
||||
* Because the Container is shared among all Stubs created from a common WSService object, this feature must
|
||||
* be passed during WSService initialization in order to register a Component against the client-side Container.
|
||||
* <p>
|
||||
* IllegalArgumentException will be thrown if the feature is used with an inappropriate target, e.g. stub target
|
||||
* used during WSEndpoint initialization.
|
||||
*
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public class ComponentFeature extends WebServiceFeature implements ServiceSharedFeatureMarker {
|
||||
/**
|
||||
* Targets the object on which the Component will be registered
|
||||
*
|
||||
*/
|
||||
public static enum Target {
|
||||
CONTAINER, ENDPOINT, SERVICE, STUB
|
||||
}
|
||||
|
||||
private final Component component;
|
||||
private final Target target;
|
||||
|
||||
/**
|
||||
* Constructs ComponentFeature with indicated component and that is targeted at the Container.
|
||||
* @param component component
|
||||
*/
|
||||
public ComponentFeature(Component component) {
|
||||
this(component, Target.CONTAINER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ComponentFeature with indicated component and target
|
||||
* @param component component
|
||||
* @param target target
|
||||
*/
|
||||
public ComponentFeature(Component component, Target target) {
|
||||
this.enabled = true;
|
||||
this.component = component;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return ComponentFeature.class.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves component
|
||||
* @return component
|
||||
*/
|
||||
public Component getComponent() {
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves target
|
||||
* @return target
|
||||
*/
|
||||
public Target getTarget() {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
/**
|
||||
* Registry for component delegates. It is expected that implementations of
|
||||
* ComponentRegistry will delegate to registered {@link Component}s in its own
|
||||
* implementation of {@link Component#getSPI(java.lang.Class)}, either before or after it
|
||||
* considers its own SPI implementations.
|
||||
*
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public interface ComponentRegistry extends Component {
|
||||
/**
|
||||
* Returns the set of {@link Component}s registered with this object
|
||||
* @return set of registered components
|
||||
*/
|
||||
public @NotNull Set<Component> getComponents();
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.xml.internal.ws.api.server.Container;
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
import com.sun.xml.internal.ws.client.Stub;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
/**
|
||||
* Allows registration of multiple {@link Component}s against the {@link ComponentRegistry} implementations
|
||||
* of the {@link Container}, {@link WSEndpoint}, {@link WSService}, or {@link Stub}. The
|
||||
* registration is guaranteed to occur early in the initialization of these objects prior to tubeline creation
|
||||
* (applicable to endpoint and stub only).
|
||||
* <p>
|
||||
* Because the Container is shared among all Stubs created from a common WSService object, this feature must
|
||||
* be passed during WSService initialization in order to register a Component against the client-side Container.
|
||||
* <p>
|
||||
* IllegalArgumentException will be thrown if the feature is used with an inappropriate target, e.g. stub target
|
||||
* used during WSEndpoint initialization.
|
||||
*
|
||||
* @since 2.2.8
|
||||
*/
|
||||
public class ComponentsFeature extends WebServiceFeature implements ServiceSharedFeatureMarker {
|
||||
private final List<ComponentFeature> componentFeatures;
|
||||
|
||||
/**
|
||||
* Constructs ComponentFeature with indicated component and target
|
||||
* @param component component
|
||||
* @param target target
|
||||
*/
|
||||
public ComponentsFeature(List<ComponentFeature> componentFeatures) {
|
||||
this.enabled = true;
|
||||
this.componentFeatures = componentFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return ComponentsFeature.class.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves component
|
||||
* @return component
|
||||
*/
|
||||
public List<ComponentFeature> getComponentFeatures() {
|
||||
return componentFeatures;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
/**
|
||||
* Placeholder for backwards compatibility.
|
||||
*
|
||||
* @deprecated Use com.oracle.webservices.internal.api.message.DistributedPropertySet instead.
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class DistributedPropertySet extends com.oracle.webservices.internal.api.message.BaseDistributedPropertySet {
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public void addSatellite(@NotNull PropertySet satellite) {
|
||||
super.addSatellite(satellite);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public void addSatellite(@NotNull Class keyClass, @NotNull PropertySet satellite) {
|
||||
super.addSatellite(keyClass, satellite);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public void copySatelliteInto(@NotNull DistributedPropertySet r) {
|
||||
super.copySatelliteInto(r);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public void removeSatellite(PropertySet satellite) {
|
||||
super.removeSatellite(satellite);
|
||||
}
|
||||
}
|
||||
232
jdkSrc/jdk8/com/sun/xml/internal/ws/api/EndpointAddress.java
Normal file
232
jdkSrc/jdk8/com/sun/xml/internal/ws/api/EndpointAddress.java
Normal file
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import com.sun.istack.internal.Nullable;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.Proxy;
|
||||
import java.net.ProxySelector;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Represents the endpoint address URI.
|
||||
*
|
||||
* <p>
|
||||
* Conceptually this can be really thought of as an {@link URI},
|
||||
* but it hides some of the details that improve the performance.
|
||||
*
|
||||
* <p>
|
||||
* Being an {@link URI} allows this class to represent custom made-up URIs
|
||||
* (like "jms" for example.) Whenever possible, this object
|
||||
* also creates an {@link URL} (this is only possible when the address
|
||||
* has a registered {@link URLStreamHandler}), so that if the clients
|
||||
* of this code wants to use it, it can do so.
|
||||
*
|
||||
*
|
||||
* <h3>How it improves the performance</h3>
|
||||
* <ol>
|
||||
* <li>
|
||||
* Endpoint address is often eventually turned into an {@link URLConnection},
|
||||
* and given that generally this value is read more often than being set,
|
||||
* it makes sense to eagerly turn it into an {@link URL},
|
||||
* thereby avoiding a repeated conversion.
|
||||
*
|
||||
* <li>
|
||||
* JDK spends a lot of time choosing a list of {@link Proxy}
|
||||
* to connect to an {@link URL}. Since the default proxy selector
|
||||
* implementation always return the same proxy for the same URL,
|
||||
* we can determine the proxy by ourselves to let JDK skip its
|
||||
* proxy-discovery step.
|
||||
*
|
||||
* (That said, user-defined proxy selector can do a lot of interesting things
|
||||
* --- like doing a round-robin, or pick one from a proxy farm randomly,
|
||||
* and so it's dangerous to stick to one proxy. For this case,
|
||||
* we still let JDK decide the proxy. This shouldn't be that much of an
|
||||
* disappointment, since most people only mess with system properties,
|
||||
* and never with {@link ProxySelector}. Also, avoiding optimization
|
||||
* with non-standard proxy selector allows people to effectively disable
|
||||
* this optimization, which may come in handy for a trouble-shooting.)
|
||||
* </ol>
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public final class EndpointAddress {
|
||||
@Nullable
|
||||
private URL url;
|
||||
private final URI uri;
|
||||
private final String stringForm;
|
||||
private volatile boolean dontUseProxyMethod;
|
||||
/**
|
||||
* Pre-selected proxy.
|
||||
*
|
||||
* If {@link #url} is null, this field is null.
|
||||
* Otherwise, this field could still be null if the proxy couldn't be chosen
|
||||
* upfront.
|
||||
*/
|
||||
private Proxy proxy;
|
||||
|
||||
public EndpointAddress(URI uri) {
|
||||
this.uri = uri;
|
||||
this.stringForm = uri.toString();
|
||||
try {
|
||||
initURL();
|
||||
proxy = chooseProxy();
|
||||
} catch (MalformedURLException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see #create(String)
|
||||
*/
|
||||
public EndpointAddress(String url) throws URISyntaxException {
|
||||
this.uri = new URI(url);
|
||||
this.stringForm = url;
|
||||
try {
|
||||
initURL();
|
||||
proxy = chooseProxy();
|
||||
} catch (MalformedURLException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initURL() throws MalformedURLException {
|
||||
String scheme = uri.getScheme();
|
||||
//URI.toURL() only works when scheme is not null.
|
||||
if (scheme == null) {
|
||||
this.url = new URL(uri.toString());
|
||||
return;
|
||||
}
|
||||
scheme =scheme.toLowerCase();
|
||||
if ("http".equals(scheme) || "https".equals(scheme)) {
|
||||
url = new URL(uri.toASCIIString());
|
||||
} else {
|
||||
this.url = uri.toURL();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link EndpointAddress} with a reasonably
|
||||
* generic error handling.
|
||||
*/
|
||||
public static EndpointAddress create(String url) {
|
||||
try {
|
||||
return new EndpointAddress(url);
|
||||
} catch(URISyntaxException e) {
|
||||
throw new WebServiceException("Illegal endpoint address: "+url,e);
|
||||
}
|
||||
}
|
||||
|
||||
private Proxy chooseProxy() {
|
||||
ProxySelector sel =
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<ProxySelector>() {
|
||||
@Override
|
||||
public ProxySelector run() {
|
||||
return ProxySelector.getDefault();
|
||||
}
|
||||
});
|
||||
|
||||
if(sel==null)
|
||||
return Proxy.NO_PROXY;
|
||||
|
||||
|
||||
if(!sel.getClass().getName().equals("sun.net.spi.DefaultProxySelector"))
|
||||
// user-defined proxy. may return a different proxy for each invocation
|
||||
return null;
|
||||
|
||||
Iterator<Proxy> it = sel.select(uri).iterator();
|
||||
if(it.hasNext())
|
||||
return it.next();
|
||||
|
||||
return Proxy.NO_PROXY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an URL of this endpoint adress.
|
||||
*
|
||||
* @return
|
||||
* null if this endpoint address doesn't have a registered {@link URLStreamHandler}.
|
||||
*/
|
||||
public URL getURL() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an URI of the endpoint address.
|
||||
*
|
||||
* @return
|
||||
* always non-null.
|
||||
*/
|
||||
public URI getURI() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to open {@link URLConnection} for this endpoint.
|
||||
*
|
||||
* <p>
|
||||
* This is possible only when an endpoint address has
|
||||
* the corresponding {@link URLStreamHandler}.
|
||||
*
|
||||
* @throws IOException
|
||||
* if {@link URL#openConnection()} reports an error.
|
||||
* @throws AssertionError
|
||||
* if this endpoint doesn't have an associated URL.
|
||||
* if the code is written correctly this shall never happen.
|
||||
*/
|
||||
public URLConnection openConnection() throws IOException {
|
||||
if (url == null) {
|
||||
throw new WebServiceException("URI="+uri+" doesn't have the corresponding URL");
|
||||
}
|
||||
if(proxy!=null && !dontUseProxyMethod) {
|
||||
try {
|
||||
return url.openConnection(proxy);
|
||||
} catch(UnsupportedOperationException e) {
|
||||
// Some OSGi and app server environments donot
|
||||
// override URLStreamHandler.openConnection(URL, Proxy) as it
|
||||
// is introduced in Java SE 5 API. Fallback to the other method.
|
||||
dontUseProxyMethod = true;
|
||||
}
|
||||
}
|
||||
return url.openConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return stringForm;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionAddressing;
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This annotation should be used on a constructor of classes extending {@link WebServiceFeature} other than
|
||||
* Spec defined features, to help JAX-WS runtime recognize feature extensions.
|
||||
* </p>
|
||||
* <p>
|
||||
* For WebServiceFeature annotations to be recognizable by JAX-WS runtime, the feature annotation should point
|
||||
* to a corresponding bean (class extending WebServiceFeature). Only one of the constructors in the bean MUST be marked
|
||||
* with @FeatureConstructor whose value captures the annotaion attribute names for the corresponding parameters.
|
||||
* </p>
|
||||
* For example,
|
||||
* @see MemberSubmissionAddressingFeature
|
||||
* @see MemberSubmissionAddressing
|
||||
*
|
||||
* @see com.sun.xml.internal.ws.developer.Stateful
|
||||
* @see com.sun.xml.internal.ws.developer.StatefulFeature
|
||||
*
|
||||
* @author Rama Pulavarthi
|
||||
*/
|
||||
@Retention(RUNTIME)
|
||||
@Target(ElementType.CONSTRUCTOR)
|
||||
|
||||
public @interface FeatureConstructor {
|
||||
/**
|
||||
* The name of the parameter.
|
||||
*/
|
||||
String[] value() default {};
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* Validates a list of {@link WebServiceFeature} instances when they are added to
|
||||
* the client or service binding.
|
||||
* <p>
|
||||
* {@link WebServiceFeature} classes may specify validator beans using {@link FeatureListValidatorAnnotation}.
|
||||
* <p>
|
||||
* Current behavior will allow runtime components to add features to the binding after initial validation; however,
|
||||
* this behavior is discouraged and will not be supported in later releases of the reference
|
||||
* implementation.
|
||||
*
|
||||
* @since 2.2.8
|
||||
* @see FeatureListValidatorAnnotation
|
||||
*/
|
||||
public interface FeatureListValidator {
|
||||
/**
|
||||
* Validates feature list. Implementations should throw {@link WebServiceException} if the
|
||||
* list of features is invalid. Implementations may add features to the list or make other
|
||||
* changes; however, only validators belonging to features on the original list will be
|
||||
* invoked.
|
||||
*
|
||||
* @param list feature list
|
||||
*/
|
||||
public void validate(WSFeatureList list);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
/**
|
||||
* This annotation should be used on classes that extend {@link WebServiceFeature} in
|
||||
* order to specify the type of {@link FeatureListValidator} bean that will be invoked when
|
||||
* instances of the {@link WebServiceFeature} class are included in the list of features
|
||||
* that are added to a client or service binding.
|
||||
*
|
||||
* @since 2.2.8
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface FeatureListValidatorAnnotation {
|
||||
/**
|
||||
* The <code>FeatureListValidator</code> bean that is associated
|
||||
* with the <code>FeatureListValidator</code> annotation
|
||||
*/
|
||||
Class<? extends FeatureListValidator> bean();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
/**
|
||||
* Features, Providers, and JWS implementations can implement this interface to
|
||||
* receive a callback allowing them to modify the features enabled for a client
|
||||
* or endpoint binding.
|
||||
*
|
||||
* Implementations of this interface can make any changes they like to the set of
|
||||
* features; however, general best practice is that implementations should not
|
||||
* override features specified by the developer. For instance, a Feature object
|
||||
* for WS-ReliableMessaging might use this interface to automatically enable
|
||||
* WS-Addressing (by adding the AddressingFeature), but not modify addressing if the
|
||||
* user had already specified a different addressing version.
|
||||
*
|
||||
* @since 2.2.6
|
||||
* @deprecated use {@link FeatureListValidatorAnnotation}
|
||||
*/
|
||||
public interface ImpliesWebServiceFeature {
|
||||
/**
|
||||
* Callback that may inspect the current feature list and add additional features
|
||||
* @param list Feature list
|
||||
*/
|
||||
public void implyFeatures(WSFeatureList list);
|
||||
}
|
||||
135
jdkSrc/jdk8/com/sun/xml/internal/ws/api/PropertySet.java
Normal file
135
jdkSrc/jdk8/com/sun/xml/internal/ws/api/PropertySet.java
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Placeholder for backwards compatibility.
|
||||
*
|
||||
* @deprecated Use com.oracle.webservices.internal.api.message.PropertySet instead.
|
||||
* @author snajper
|
||||
*/
|
||||
public abstract class PropertySet extends com.oracle.webservices.internal.api.message.BasePropertySet {
|
||||
/**
|
||||
* Represents the list of strongly-typed known properties
|
||||
* (keyed by property names.)
|
||||
*
|
||||
* <p>
|
||||
* Just giving it an alias to make the use of this class more fool-proof.
|
||||
* @deprecated
|
||||
*/
|
||||
protected static class PropertyMap extends com.oracle.webservices.internal.api.message.BasePropertySet.PropertyMap {}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
protected static PropertyMap parse(final Class clazz) {
|
||||
com.oracle.webservices.internal.api.message.BasePropertySet.PropertyMap pm = com.oracle.webservices.internal.api.message.BasePropertySet.parse(clazz);
|
||||
PropertyMap map = new PropertyMap();
|
||||
map.putAll(pm);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the property.
|
||||
*
|
||||
* @param key
|
||||
* This field is typed as {@link Object} to follow the {@link Map#get(Object)}
|
||||
* convention, but if anything but {@link String} is passed, this method
|
||||
* just returns null.
|
||||
*/
|
||||
public Object get(Object key) {
|
||||
Accessor sp = getPropertyMap().get(key);
|
||||
if(sp!=null)
|
||||
return sp.get(this);
|
||||
throw new IllegalArgumentException("Undefined property "+key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a property.
|
||||
*
|
||||
* <h3>Implementation Note</h3>
|
||||
* This method is slow. Code inside JAX-WS should define strongly-typed
|
||||
* fields in this class and access them directly, instead of using this.
|
||||
*
|
||||
* @throws ReadOnlyPropertyException
|
||||
* if the given key is an alias of a strongly-typed field,
|
||||
* and if the name object given is not assignable to the field.
|
||||
*
|
||||
* @see Property
|
||||
*/
|
||||
public Object put(String key, Object value) {
|
||||
Accessor sp = getPropertyMap().get(key);
|
||||
if(sp!=null) {
|
||||
Object old = sp.get(this);
|
||||
sp.set(this,value);
|
||||
return old;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Undefined property "+key);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean supports(Object key) {
|
||||
return getPropertyMap().containsKey(key);
|
||||
}
|
||||
|
||||
public Object remove(Object key) {
|
||||
Accessor sp = getPropertyMap().get(key);
|
||||
if(sp!=null) {
|
||||
Object old = sp.get(this);
|
||||
sp.set(this,null);
|
||||
return old;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Undefined property "+key);
|
||||
}
|
||||
}
|
||||
|
||||
protected void createEntrySet(Set<Entry<String,Object>> core) {
|
||||
for (final Entry<String, Accessor> e : getPropertyMap().entrySet()) {
|
||||
core.add(new Entry<String, Object>() {
|
||||
public String getKey() {
|
||||
return e.getKey();
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return e.getValue().get(PropertySet.this);
|
||||
}
|
||||
|
||||
public Object setValue(Object value) {
|
||||
Accessor acc = e.getValue();
|
||||
Object old = acc.get(PropertySet.this);
|
||||
acc.set(PropertySet.this,value);
|
||||
return old;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract PropertyMap getPropertyMap();
|
||||
}
|
||||
68
jdkSrc/jdk8/com/sun/xml/internal/ws/api/ResourceLoader.java
Normal file
68
jdkSrc/jdk8/com/sun/xml/internal/ws/api/ResourceLoader.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import com.sun.xml.internal.ws.api.server.Container;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Used to locate resources for jax-ws extensions. Using this, extensions
|
||||
* do not to have to write container specific code to locate resources.
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
*/
|
||||
public abstract class ResourceLoader {
|
||||
|
||||
/**
|
||||
* Returns the actual location of the resource from the 'resource' arg
|
||||
* that represents a virtual locaion of a file understood by a container.
|
||||
* ResourceLoader impl for a Container knows how to map this
|
||||
* virtual location to actual location.
|
||||
* <p>
|
||||
* Extensions can get hold of this object using {@link Container}.
|
||||
* <p/>
|
||||
* for e.g.:
|
||||
* <pre>
|
||||
* ResourceLoader loader = container.getSPI(ResourceLoader.class);
|
||||
* URL catalog = loader.get("jax-ws-catalog.xml");
|
||||
* </pre>
|
||||
* A ResourceLoader for servlet environment, may do the following.
|
||||
* <pre>
|
||||
* URL getResource(String resource) {
|
||||
* return servletContext.getResource("/WEB-INF/"+resource);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param resource Designates a path that is understood by the container. The
|
||||
* implementations must support "jax-ws-catalog.xml" resource.
|
||||
* @return the actual location, if found, or null if not found.
|
||||
* @throws MalformedURLException if there is an error in creating URL
|
||||
*/
|
||||
public abstract URL getResource(String resource) throws MalformedURLException;
|
||||
|
||||
}
|
||||
279
jdkSrc/jdk8/com/sun/xml/internal/ws/api/SOAPVersion.java
Normal file
279
jdkSrc/jdk8/com/sun/xml/internal/ws/api/SOAPVersion.java
Normal file
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import com.sun.xml.internal.bind.util.Which;
|
||||
import com.sun.xml.internal.ws.api.message.saaj.SAAJFactory;
|
||||
import com.sun.xml.internal.ws.encoding.soap.SOAP12Constants;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.MessageFactory;
|
||||
import javax.xml.soap.SOAPConstants;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPFactory;
|
||||
import javax.xml.ws.soap.SOAPBinding;
|
||||
|
||||
import com.oracle.webservices.internal.api.EnvelopeStyle;
|
||||
import com.oracle.webservices.internal.api.EnvelopeStyleFeature;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Version of SOAP (1.1 and 1.2).
|
||||
*
|
||||
* <p>
|
||||
* This class defines various constants for SOAP 1.1 and SOAP 1.2,
|
||||
* and also defines convenience methods to simplify the processing
|
||||
* of multiple SOAP versions.
|
||||
*
|
||||
* <p>
|
||||
* This constant alows you to do:
|
||||
*
|
||||
* <pre>
|
||||
* SOAPVersion version = ...;
|
||||
* version.someOp(...);
|
||||
* </pre>
|
||||
*
|
||||
* As opposed to:
|
||||
*
|
||||
* <pre>
|
||||
* if(binding is SOAP11) {
|
||||
* doSomeOp11(...);
|
||||
* } else {
|
||||
* doSomeOp12(...);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public enum SOAPVersion {
|
||||
SOAP_11(SOAPBinding.SOAP11HTTP_BINDING,
|
||||
com.sun.xml.internal.ws.encoding.soap.SOAPConstants.URI_ENVELOPE,
|
||||
"text/xml",
|
||||
SOAPConstants.URI_SOAP_ACTOR_NEXT, "actor",
|
||||
javax.xml.soap.SOAPConstants.SOAP_1_1_PROTOCOL,
|
||||
new QName(com.sun.xml.internal.ws.encoding.soap.SOAPConstants.URI_ENVELOPE, "MustUnderstand"),
|
||||
"Client",
|
||||
"Server",
|
||||
Collections.singleton(SOAPConstants.URI_SOAP_ACTOR_NEXT)),
|
||||
|
||||
SOAP_12(SOAPBinding.SOAP12HTTP_BINDING,
|
||||
SOAP12Constants.URI_ENVELOPE,
|
||||
"application/soap+xml",
|
||||
SOAPConstants.URI_SOAP_1_2_ROLE_ULTIMATE_RECEIVER, "role",
|
||||
javax.xml.soap.SOAPConstants.SOAP_1_2_PROTOCOL,
|
||||
new QName(com.sun.xml.internal.ws.encoding.soap.SOAP12Constants.URI_ENVELOPE, "MustUnderstand"),
|
||||
"Sender",
|
||||
"Receiver",
|
||||
new HashSet<String>(Arrays.asList(SOAPConstants.URI_SOAP_1_2_ROLE_NEXT,SOAPConstants.URI_SOAP_1_2_ROLE_ULTIMATE_RECEIVER)));
|
||||
|
||||
/**
|
||||
* Binding ID for SOAP/HTTP binding of this SOAP version.
|
||||
*
|
||||
* <p>
|
||||
* Either {@link SOAPBinding#SOAP11HTTP_BINDING} or
|
||||
* {@link SOAPBinding#SOAP12HTTP_BINDING}
|
||||
*/
|
||||
public final String httpBindingId;
|
||||
|
||||
/**
|
||||
* SOAP envelope namespace URI.
|
||||
*/
|
||||
public final String nsUri;
|
||||
|
||||
/**
|
||||
* Content-type. Either "text/xml" or "application/soap+xml".
|
||||
*/
|
||||
public final String contentType;
|
||||
|
||||
/**
|
||||
* SOAP MustUnderstand FaultCode for this SOAP version
|
||||
*/
|
||||
public final QName faultCodeMustUnderstand;
|
||||
|
||||
/**
|
||||
* SAAJ {@link MessageFactory} for this SOAP version.
|
||||
* @deprecated
|
||||
*/
|
||||
public final MessageFactory saajMessageFactory;
|
||||
|
||||
/**
|
||||
* SAAJ {@link SOAPFactory} for this SOAP version.
|
||||
* @deprecated
|
||||
*/
|
||||
public final SOAPFactory saajSoapFactory;
|
||||
|
||||
private final String saajFactoryString;
|
||||
|
||||
/**
|
||||
* If the actor/role attribute is absent, this SOAP version assumes this value.
|
||||
*/
|
||||
public final String implicitRole;
|
||||
|
||||
/**
|
||||
* Singleton set that contains {@link #implicitRole}.
|
||||
*/
|
||||
public final Set<String> implicitRoleSet;
|
||||
|
||||
/**
|
||||
* This represents the roles required to be assumed by SOAP binding implementation.
|
||||
*/
|
||||
public final Set<String> requiredRoles;
|
||||
|
||||
/**
|
||||
* "role" (SOAP 1.2) or "actor" (SOAP 1.1)
|
||||
*/
|
||||
public final String roleAttributeName;
|
||||
|
||||
/**
|
||||
* "{nsUri}Client" or "{nsUri}Sender"
|
||||
*/
|
||||
public final QName faultCodeClient;
|
||||
|
||||
/**
|
||||
* "{nsUri}Server" or "{nsUri}Receiver"
|
||||
*/
|
||||
public final QName faultCodeServer;
|
||||
|
||||
private SOAPVersion(String httpBindingId, String nsUri, String contentType, String implicitRole, String roleAttributeName,
|
||||
String saajFactoryString, QName faultCodeMustUnderstand, String faultCodeClientLocalName,
|
||||
String faultCodeServerLocalName,Set<String> requiredRoles) {
|
||||
this.httpBindingId = httpBindingId;
|
||||
this.nsUri = nsUri;
|
||||
this.contentType = contentType;
|
||||
this.implicitRole = implicitRole;
|
||||
this.implicitRoleSet = Collections.singleton(implicitRole);
|
||||
this.roleAttributeName = roleAttributeName;
|
||||
this.saajFactoryString = saajFactoryString;
|
||||
try {
|
||||
saajMessageFactory = MessageFactory.newInstance(saajFactoryString);
|
||||
saajSoapFactory = SOAPFactory.newInstance(saajFactoryString);
|
||||
} catch (SOAPException e) {
|
||||
throw new Error(e);
|
||||
} catch (NoSuchMethodError e) {
|
||||
// SAAJ 1.3 is not in the classpath
|
||||
LinkageError x = new LinkageError("You are loading old SAAJ from "+ Which.which(MessageFactory.class));
|
||||
x.initCause(e);
|
||||
throw x;
|
||||
}
|
||||
this.faultCodeMustUnderstand = faultCodeMustUnderstand;
|
||||
this.requiredRoles = requiredRoles;
|
||||
this.faultCodeClient = new QName(nsUri,faultCodeClientLocalName);
|
||||
this.faultCodeServer = new QName(nsUri,faultCodeServerLocalName);
|
||||
}
|
||||
|
||||
public SOAPFactory getSOAPFactory() {
|
||||
try {
|
||||
return SAAJFactory.getSOAPFactory(saajFactoryString);
|
||||
} catch (SOAPException e) {
|
||||
throw new Error(e);
|
||||
} catch (NoSuchMethodError e) {
|
||||
// SAAJ 1.3 is not in the classpath
|
||||
LinkageError x = new LinkageError("You are loading old SAAJ from "+ Which.which(MessageFactory.class));
|
||||
x.initCause(e);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
public MessageFactory getMessageFactory() {
|
||||
try {
|
||||
return SAAJFactory.getMessageFactory(saajFactoryString);
|
||||
} catch (SOAPException e) {
|
||||
throw new Error(e);
|
||||
} catch (NoSuchMethodError e) {
|
||||
// SAAJ 1.3 is not in the classpath
|
||||
LinkageError x = new LinkageError("You are loading old SAAJ from "+ Which.which(MessageFactory.class));
|
||||
x.initCause(e);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return httpBindingId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link SOAPVersion} whose {@link #httpBindingId} equals to
|
||||
* the given string.
|
||||
*
|
||||
* This method does not perform input string validation.
|
||||
*
|
||||
* @param binding
|
||||
* for historical reason, we treat null as {@link #SOAP_11},
|
||||
* but you really shouldn't be passing null.
|
||||
* @return always non-null.
|
||||
*/
|
||||
public static SOAPVersion fromHttpBinding(String binding) {
|
||||
if(binding==null)
|
||||
return SOAP_11;
|
||||
|
||||
if(binding.equals(SOAP_12.httpBindingId))
|
||||
return SOAP_12;
|
||||
else
|
||||
return SOAP_11;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link SOAPVersion} whose {@link #nsUri} equals to
|
||||
* the given string.
|
||||
*
|
||||
* This method does not perform input string validation.
|
||||
*
|
||||
* @param nsUri
|
||||
* must not be null.
|
||||
* @return always non-null.
|
||||
*/
|
||||
public static SOAPVersion fromNsUri(String nsUri) {
|
||||
if(nsUri.equals(SOAP_12.nsUri))
|
||||
return SOAP_12;
|
||||
else
|
||||
return SOAP_11;
|
||||
}
|
||||
|
||||
public static SOAPVersion from(EnvelopeStyleFeature f) {
|
||||
EnvelopeStyle.Style[] style = f.getStyles();
|
||||
if (style.length != 1) throw new IllegalArgumentException ("The EnvelopingFeature must has exactly one Enveloping.Style");
|
||||
return from(style[0]);
|
||||
}
|
||||
|
||||
public static SOAPVersion from(EnvelopeStyle.Style style) {
|
||||
switch (style) {
|
||||
case SOAP11: return SOAP_11;
|
||||
case SOAP12: return SOAP_12;
|
||||
case XML: //ERROR??
|
||||
default: return SOAP_11;
|
||||
}
|
||||
}
|
||||
|
||||
public EnvelopeStyleFeature toFeature() {
|
||||
return SOAP_11.equals(this) ?
|
||||
new EnvelopeStyleFeature(new EnvelopeStyle.Style[]{EnvelopeStyle.Style.SOAP11}) :
|
||||
new EnvelopeStyleFeature(new EnvelopeStyle.Style[]{EnvelopeStyle.Style.SOAP12});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
/**
|
||||
* Marker interface for {@link WebServiceFeature} derived classes that when instances are specified in the feature list to a service delegate must be
|
||||
* added to the feature list of any Stubs created by that delegate. WebServiceFeature instances passed directly in the parameters of get...() or createDispatch()
|
||||
* must take precedence over feature instances passed during service delegate initialization.
|
||||
*
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public interface ServiceSharedFeatureMarker {
|
||||
|
||||
}
|
||||
209
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSBinding.java
Normal file
209
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSBinding.java
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.message.Message;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.api.pipe.Tube;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.Binding;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.handler.Handler;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* JAX-WS implementation of {@link Binding}.
|
||||
*
|
||||
* <p>
|
||||
* This object can be created by {@link BindingID#createBinding()}.
|
||||
*
|
||||
* <p>
|
||||
* Binding conceptually includes the on-the-wire format of the message,
|
||||
* this this object owns {@link Codec}.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public interface WSBinding extends Binding {
|
||||
/**
|
||||
* Gets the SOAP version of this binding.
|
||||
*
|
||||
* TODO: clarify what to do with XML/HTTP binding
|
||||
*
|
||||
* <p>
|
||||
* This is just a short-cut for {@code getBindingID().getSOAPVersion()}
|
||||
*
|
||||
* @return
|
||||
* If the binding is using SOAP, this method returns
|
||||
* a {@link SOAPVersion} constant.
|
||||
*
|
||||
* If the binding is not based on SOAP, this method
|
||||
* returns null. See {@link Message} for how a non-SOAP
|
||||
* binding shall be handled by {@link Tube}s.
|
||||
*/
|
||||
SOAPVersion getSOAPVersion();
|
||||
/**
|
||||
* Gets the WS-Addressing version of this binding.
|
||||
* <p/>
|
||||
* TODO: clarify what to do with XML/HTTP binding
|
||||
*
|
||||
* @return If the binding is using SOAP and WS-Addressing is enabled,
|
||||
* this method returns a {@link AddressingVersion} constant.
|
||||
* If binding is not using SOAP or WS-Addressing is not enabled,
|
||||
* this method returns null.
|
||||
*
|
||||
* This might be little slow as it has to go over all the features on binding.
|
||||
* Its advisable to cache the addressingVersion wherever possible and reuse it.
|
||||
*/
|
||||
AddressingVersion getAddressingVersion();
|
||||
|
||||
/**
|
||||
* Gets the binding ID, which uniquely identifies the binding.
|
||||
*
|
||||
* <p>
|
||||
* The relevant specs define the binding IDs and what they mean.
|
||||
* The ID is used in many places to identify the kind of binding
|
||||
* (such as SOAP1.1, SOAP1.2, REST, ...)
|
||||
*
|
||||
* @return
|
||||
* Always non-null same value.
|
||||
*/
|
||||
@NotNull BindingID getBindingId();
|
||||
|
||||
@NotNull@Override
|
||||
List<Handler> getHandlerChain();
|
||||
|
||||
/**
|
||||
* Checks if a particular {@link WebServiceFeature} is enabled.
|
||||
*
|
||||
* @return
|
||||
* true if enabled.
|
||||
*/
|
||||
boolean isFeatureEnabled(@NotNull Class<? extends WebServiceFeature> feature);
|
||||
|
||||
/**
|
||||
* Experimental: Checks if a particular {@link WebServiceFeature} on an operation is enabled.
|
||||
*
|
||||
* @param operationName
|
||||
* The WSDL name of the operation.
|
||||
* @return
|
||||
* true if enabled.
|
||||
*/
|
||||
boolean isOperationFeatureEnabled(@NotNull Class<? extends WebServiceFeature> feature,
|
||||
@NotNull final QName operationName);
|
||||
|
||||
/**
|
||||
* Gets a {@link WebServiceFeature} of the specific type.
|
||||
*
|
||||
* @param featureType
|
||||
* The type of the feature to retrieve.
|
||||
* @return
|
||||
* If the feature is present and enabled, return a non-null instance.
|
||||
* Otherwise null.
|
||||
*/
|
||||
@Nullable <F extends WebServiceFeature> F getFeature(@NotNull Class<F> featureType);
|
||||
|
||||
/**
|
||||
* Experimental: Gets a {@link WebServiceFeature} of the specific type that applies to an operation.
|
||||
*
|
||||
* @param featureType
|
||||
* The type of the feature to retrieve.
|
||||
* @param operationName
|
||||
* The WSDL name of the operation.
|
||||
* @return
|
||||
* If the feature is present and enabled, return a non-null instance.
|
||||
* Otherwise null.
|
||||
*/
|
||||
@Nullable <F extends WebServiceFeature> F getOperationFeature(@NotNull Class<F> featureType,
|
||||
@NotNull final QName operationName);
|
||||
|
||||
/**
|
||||
* Returns a list of features associated with {@link WSBinding}.
|
||||
*/
|
||||
@NotNull WSFeatureList getFeatures();
|
||||
|
||||
/**
|
||||
* Experimental: Returns a list of features associated with {@link WSBinding} that apply to
|
||||
* a particular operation.
|
||||
*
|
||||
* @param operationName
|
||||
* The WSDL name of the operation.
|
||||
*/
|
||||
@NotNull WSFeatureList getOperationFeatures(@NotNull final QName operationName);
|
||||
|
||||
/**
|
||||
* Experimental: Returns a list of features associated with {@link WSBinding} that apply to
|
||||
* the input message of an operation.
|
||||
*
|
||||
* @param operationName
|
||||
* The WSDL name of the operation.
|
||||
*/
|
||||
@NotNull WSFeatureList getInputMessageFeatures(@NotNull final QName operationName);
|
||||
|
||||
/**
|
||||
* Experimental: Returns a list of features associated with {@link WSBinding} that apply to
|
||||
* the output message of an operation.
|
||||
*
|
||||
* @param operationName
|
||||
* The WSDL name of the operation.
|
||||
*/
|
||||
@NotNull WSFeatureList getOutputMessageFeatures(@NotNull final QName operationName);
|
||||
|
||||
/**
|
||||
* Experimental: Returns a list of features associated with {@link WSBinding} that apply to
|
||||
* one of the fault messages of an operation.
|
||||
*
|
||||
* @param operationName
|
||||
* The WSDL name of the operation.
|
||||
* @param messageName
|
||||
* The WSDL name of the fault message.
|
||||
*/
|
||||
@NotNull WSFeatureList getFaultMessageFeatures(@NotNull final QName operationName,
|
||||
@NotNull final QName messageName);
|
||||
|
||||
/**
|
||||
* Returns set of header QNames known to be supported by this binding.
|
||||
* @return Set of known QNames
|
||||
*/
|
||||
@NotNull Set<QName> getKnownHeaders();
|
||||
|
||||
/**
|
||||
* Adds header QName to set known to be supported by this binding
|
||||
* @param knownHeader Known header QName
|
||||
* @return true, if new entry was added; false, if known header QName was already known
|
||||
*/
|
||||
boolean addKnownHeader(QName knownHeader);
|
||||
|
||||
/**
|
||||
* @return A MessageContextFactory configured according to the binding's features.
|
||||
*/
|
||||
@NotNull com.oracle.webservices.internal.api.message.MessageContextFactory getMessageContextFactory();
|
||||
}
|
||||
51
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSDLLocator.java
Normal file
51
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSDLLocator.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.xml.ws.Service;
|
||||
|
||||
/**
|
||||
* Used to locate WSDL documents; particularly useful for J2EE deployment archives
|
||||
*
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public abstract class WSDLLocator {
|
||||
|
||||
/**
|
||||
* Returns the actual WSDL location
|
||||
*
|
||||
* @param service Service class
|
||||
* @param wsdlLoc Designates the WSDL location either from the service class
|
||||
* or through other means
|
||||
* @return the actual WSDL location, if found, or null if not found.
|
||||
* @throws MalformedURLException if there is an error in creating URL
|
||||
*/
|
||||
public abstract URL locateWSDL(Class<Service> service, String wsdlLoc) throws MalformedURLException;
|
||||
|
||||
}
|
||||
84
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSFeatureList.java
Normal file
84
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSFeatureList.java
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
/**
|
||||
* Read-only list of {@link WebServiceFeature}s.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public interface WSFeatureList extends Iterable<WebServiceFeature> {
|
||||
/**
|
||||
* Checks if a particular {@link WebServiceFeature} is enabled.
|
||||
*
|
||||
* @return
|
||||
* true if enabled.
|
||||
*/
|
||||
boolean isEnabled(@NotNull Class<? extends WebServiceFeature> feature);
|
||||
|
||||
/**
|
||||
* Gets a {@link WebServiceFeature} of the specific type.
|
||||
*
|
||||
* @param featureType
|
||||
* The type of the feature to retrieve.
|
||||
* @return
|
||||
* If the feature is present and enabled, return a non-null instance.
|
||||
* Otherwise null.
|
||||
*/
|
||||
@Nullable <F extends WebServiceFeature> F get(@NotNull Class<F> featureType);
|
||||
|
||||
/**
|
||||
* Obtains all the features in the array.
|
||||
*/
|
||||
@NotNull WebServiceFeature[] toArray();
|
||||
|
||||
/**
|
||||
* Merges the extra features that are not already set on binding.
|
||||
* i.e, if a feature is set already on binding through some other API
|
||||
* the corresponding wsdlFeature is not set.
|
||||
*
|
||||
* @param features Web Service features that need to be merged with already configured features.
|
||||
* @param reportConflicts If true, checks if the feature setting in WSDL (wsdl extension or
|
||||
* policy configuration) conflicts with feature setting in Deployed Service and
|
||||
* logs warning if there are any conflicts.
|
||||
*/
|
||||
void mergeFeatures(@NotNull WebServiceFeature[] features, boolean reportConflicts);
|
||||
|
||||
/**
|
||||
* Merges the extra features that are not already set on binding.
|
||||
* i.e, if a feature is set already on binding through some other API
|
||||
* the corresponding wsdlFeature is not set.
|
||||
*
|
||||
* @param features Web Service features that need to be merged with already configured features.
|
||||
* @param reportConflicts If true, checks if the feature setting in WSDL (wsdl extension or
|
||||
* policy configuration) conflicts with feature setting in Deployed Service and
|
||||
* logs warning if there are any conflicts.
|
||||
*/
|
||||
void mergeFeatures(@NotNull Iterable<WebServiceFeature> features, boolean reportConflicts);
|
||||
}
|
||||
248
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSService.java
Normal file
248
jdkSrc/jdk8/com/sun/xml/internal/ws/api/WSService.java
Normal file
@@ -0,0 +1,248 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
|
||||
import com.sun.xml.internal.ws.api.server.Container;
|
||||
import com.sun.xml.internal.ws.api.server.ContainerResolver;
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
import com.sun.xml.internal.ws.client.WSServiceDelegate;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.Dispatch;
|
||||
import javax.xml.ws.EndpointReference;
|
||||
import javax.xml.ws.Service;
|
||||
import javax.xml.ws.Service.Mode;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.spi.ServiceDelegate;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
* JAX-WS implementation of {@link ServiceDelegate}.
|
||||
*
|
||||
* <p>
|
||||
* This abstract class is used only to improve the static type safety
|
||||
* of the JAX-WS internal API.
|
||||
*
|
||||
* <p>
|
||||
* The class name intentionally doesn't include "Delegate",
|
||||
* because the fact that it's a delegate is a detail of
|
||||
* the JSR-224 API, and for the layers above us this object
|
||||
* nevertheless represents {@link Service}. We want them
|
||||
* to think of this as an internal representation of a service.
|
||||
*
|
||||
* <p>
|
||||
* Only JAX-WS internal code may downcast this to {@link WSServiceDelegate}.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class WSService extends ServiceDelegate implements ComponentRegistry {
|
||||
private final Set<Component> components = new CopyOnWriteArraySet<Component>();
|
||||
|
||||
protected WSService() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Works like {@link #getPort(EndpointReference, Class, WebServiceFeature...)}
|
||||
* but takes {@link WSEndpointReference}.
|
||||
*/
|
||||
public abstract <T> T getPort(WSEndpointReference epr, Class<T> portInterface, WebServiceFeature... features);
|
||||
|
||||
/**
|
||||
* Works like {@link #createDispatch(javax.xml.ws.EndpointReference, java.lang.Class, javax.xml.ws.Service.Mode, javax.xml.ws.WebServiceFeature[])}
|
||||
* but it takes the port name separately, so that EPR without embedded metadata can be used.
|
||||
*/
|
||||
public abstract <T> Dispatch<T> createDispatch(QName portName, WSEndpointReference wsepr, Class<T> aClass, Service.Mode mode, WebServiceFeature... features);
|
||||
|
||||
/**
|
||||
* Works like {@link #createDispatch(javax.xml.ws.EndpointReference, javax.xml.bind.JAXBContext, javax.xml.ws.Service.Mode, javax.xml.ws.WebServiceFeature[])}
|
||||
* but it takes the port name separately, so that EPR without embedded metadata can be used.
|
||||
*/
|
||||
public abstract Dispatch<Object> createDispatch(QName portName, WSEndpointReference wsepr, JAXBContext jaxbContext, Service.Mode mode, WebServiceFeature... features);
|
||||
|
||||
/**
|
||||
* Gets the {@link Container} object.
|
||||
*
|
||||
* <p>
|
||||
* The components inside {@link WSEndpoint} uses this reference
|
||||
* to communicate with the hosting environment.
|
||||
*
|
||||
* @return
|
||||
* always same object. If no "real" {@link Container} instance
|
||||
* is given, {@link Container#NONE} will be returned.
|
||||
*/
|
||||
public abstract @NotNull Container getContainer();
|
||||
|
||||
public @Nullable <S> S getSPI(@NotNull Class<S> spiType) {
|
||||
for (Component c : components) {
|
||||
S s = c.getSPI(spiType);
|
||||
if (s != null)
|
||||
return s;
|
||||
}
|
||||
|
||||
return getContainer().getSPI(spiType);
|
||||
}
|
||||
|
||||
public @NotNull Set<Component> getComponents() {
|
||||
return components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>Service</code> instance.
|
||||
*
|
||||
* The specified WSDL document location and service qualified name MUST
|
||||
* uniquely identify a <code>wsdl:service</code> element.
|
||||
*
|
||||
* @param wsdlDocumentLocation URL for the WSDL document location
|
||||
* for the service
|
||||
* @param serviceName QName for the service
|
||||
* @throws WebServiceException If any error in creation of the
|
||||
* specified service.
|
||||
**/
|
||||
public static WSService create( URL wsdlDocumentLocation, QName serviceName) {
|
||||
return new WSServiceDelegate(wsdlDocumentLocation,serviceName,Service.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>Service</code> instance.
|
||||
*
|
||||
* @param serviceName QName for the service
|
||||
* @throws WebServiceException If any error in creation of the
|
||||
* specified service
|
||||
*/
|
||||
public static WSService create(QName serviceName) {
|
||||
return create(null,serviceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a service with a dummy service name.
|
||||
*/
|
||||
public static WSService create() {
|
||||
return create(null,new QName(WSService.class.getName(),"dummy"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Typed parameter bag used by {@link WSService#create(URL, QName, InitParams)}
|
||||
*
|
||||
* @since 2.1.3
|
||||
*/
|
||||
public static final class InitParams {
|
||||
private Container container;
|
||||
/**
|
||||
* Sets the {@link Container} object used by the created service.
|
||||
* This allows the client to use a specific {@link Container} instance
|
||||
* as opposed to the one obtained by {@link ContainerResolver}.
|
||||
*/
|
||||
public void setContainer(Container c) {
|
||||
this.container = c;
|
||||
}
|
||||
public Container getContainer() {
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To create a {@link Service}, we need to go through the API that doesn't let us
|
||||
* pass parameters, so as a hack we use thread local.
|
||||
*/
|
||||
protected static final ThreadLocal<InitParams> INIT_PARAMS = new ThreadLocal<InitParams>();
|
||||
|
||||
/**
|
||||
* Used as a immutable constant so that we can avoid null check.
|
||||
*/
|
||||
protected static final InitParams EMPTY_PARAMS = new InitParams();
|
||||
|
||||
/**
|
||||
* Creates a {@link Service} instance.
|
||||
*
|
||||
* <p>
|
||||
* This method works really like {@link Service#create(URL, QName)}
|
||||
* except it takes one more RI specific parameter.
|
||||
*
|
||||
* @param wsdlDocumentLocation
|
||||
* {@code URL} for the WSDL document location for the service.
|
||||
* Can be null, in which case WSDL is not loaded.
|
||||
* @param serviceName
|
||||
* {@code QName} for the service.
|
||||
* @param properties
|
||||
* Additional RI specific initialization parameters. Can be null.
|
||||
* @throws WebServiceException
|
||||
* If any error in creation of the specified service.
|
||||
**/
|
||||
public static Service create( URL wsdlDocumentLocation, QName serviceName, InitParams properties) {
|
||||
if(INIT_PARAMS.get()!=null)
|
||||
throw new IllegalStateException("someone left non-null InitParams");
|
||||
INIT_PARAMS.set(properties);
|
||||
try {
|
||||
Service svc = Service.create(wsdlDocumentLocation, serviceName);
|
||||
if(INIT_PARAMS.get()!=null)
|
||||
throw new IllegalStateException("Service "+svc+" didn't recognize InitParams");
|
||||
return svc;
|
||||
} finally {
|
||||
// even in case of an exception still reset INIT_PARAMS
|
||||
INIT_PARAMS.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the {@link WSService} that's encapsulated inside a {@link Service}.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if the given service object is not from the JAX-WS RI.
|
||||
*/
|
||||
public static WSService unwrap(final Service svc) {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<WSService>() {
|
||||
public WSService run() {
|
||||
try {
|
||||
Field f = svc.getClass().getField("delegate");
|
||||
f.setAccessible(true);
|
||||
Object delegate = f.get(svc);
|
||||
if(!(delegate instanceof WSService))
|
||||
throw new IllegalArgumentException();
|
||||
return (WSService) delegate;
|
||||
} catch (NoSuchFieldException e) {
|
||||
AssertionError x = new AssertionError("Unexpected service API implementation");
|
||||
x.initCause(e);
|
||||
throw x;
|
||||
} catch (IllegalAccessException e) {
|
||||
IllegalAccessError x = new IllegalAccessError(e.getMessage());
|
||||
x.initCause(e);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api;
|
||||
|
||||
import com.sun.xml.internal.ws.binding.WebServiceFeatureList;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
/**
|
||||
* Factory methods to get web service features from the corresponding
|
||||
* feature annotations
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
*/
|
||||
public class WebServiceFeatureFactory {
|
||||
|
||||
/**
|
||||
* Returns a feature list for feature annotations(i.e which have
|
||||
* {@link javax.xml.ws.spi.WebServiceFeatureAnnotation} meta annotation)
|
||||
*
|
||||
* @param ann list of annotations(that can also have non-feature annotations)
|
||||
* @return non-null feature list object
|
||||
*/
|
||||
public static WSFeatureList getWSFeatureList(Iterable<Annotation> ann) {
|
||||
WebServiceFeatureList list = new WebServiceFeatureList();
|
||||
list.parseAnnotations(ann);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a corresponding feature for a feature annotation(i.e which has
|
||||
* {@link javax.xml.ws.spi.WebServiceFeatureAnnotation} meta annotation)
|
||||
*
|
||||
* @param ann any annotation, not required to be a feature annotation
|
||||
* @return corresponding feature for the annotation
|
||||
* null, if the annotation is not a feature annotation
|
||||
*/
|
||||
public static WebServiceFeature getWebServiceFeature(Annotation ann) {
|
||||
return WebServiceFeatureList.getFeature(ann);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.addressing;
|
||||
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.oracle.webservices.internal.api.message.BasePropertySet;
|
||||
import javax.xml.ws.handler.MessageContext;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>This property set exists so the upper stack can SET addressing info
|
||||
* on a PER-REQUEST basis (instead of a per proxy/dispatch basis via OneWayFeature).</p>
|
||||
*
|
||||
* <p>This class is NOT used for reading addressing header values.</p>
|
||||
*/
|
||||
public class AddressingPropertySet extends BasePropertySet {
|
||||
|
||||
// NOTE: Setting ACTION on client side is covered by standard BindingProvider.
|
||||
|
||||
public static final String ADDRESSING_FAULT_TO = "com.sun.xml.internal.ws.api.addressing.fault.to";
|
||||
private String faultTo;
|
||||
@Property(ADDRESSING_FAULT_TO)
|
||||
public String getFaultTo() { return faultTo; }
|
||||
public void setFaultTo(final String x) { faultTo = x; }
|
||||
|
||||
public static final String ADDRESSING_MESSAGE_ID = "com.sun.xml.internal.ws.api.addressing.message.id";
|
||||
private String messageId;
|
||||
public String getMessageId() { return messageId; }
|
||||
public void setMessageId(final String x) { messageId = x; }
|
||||
|
||||
public static final String ADDRESSING_RELATES_TO = "com.sun.xml.internal.ws.api.addressing.relates.to";
|
||||
@Property(ADDRESSING_RELATES_TO)
|
||||
private String relatesTo;
|
||||
public String getRelatesTo() { return relatesTo; }
|
||||
public void setRelatesTo(final String x) { relatesTo = x; }
|
||||
|
||||
public static final String ADDRESSING_REPLY_TO = "com.sun.xml.internal.ws.api.addressing.reply.to";
|
||||
@Property(ADDRESSING_REPLY_TO)
|
||||
private String replyTo;
|
||||
public String getReplyTo() { return replyTo; }
|
||||
public void setReplyTo(final String x) { replyTo = x; }
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
// PropertySet boilerplate
|
||||
//
|
||||
|
||||
private static final PropertyMap model;
|
||||
|
||||
static {
|
||||
model = parse(AddressingPropertySet.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PropertyMap getPropertyMap() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,753 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.addressing;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.stream.buffer.XMLStreamBuffer;
|
||||
import com.sun.xml.internal.ws.addressing.W3CAddressingConstants;
|
||||
import com.sun.xml.internal.ws.addressing.WsaTubeHelper;
|
||||
import com.sun.xml.internal.ws.addressing.v200408.MemberSubmissionAddressingConstants;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.message.Header;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.model.SEIModel;
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature;
|
||||
import com.sun.xml.internal.ws.developer.MemberSubmissionEndpointReference;
|
||||
import com.sun.xml.internal.ws.message.stream.OutboundStreamHeader;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.ws.EndpointReference;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.soap.AddressingFeature;
|
||||
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* 'Traits' object that absorbs differences of WS-Addressing versions.
|
||||
*
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
public enum AddressingVersion {
|
||||
|
||||
W3C("http://www.w3.org/2005/08/addressing",
|
||||
"wsa",
|
||||
W3CAddressingConstants.ANONYMOUS_EPR,
|
||||
"http://www.w3.org/2006/05/addressing/wsdl",
|
||||
"http://www.w3.org/2006/05/addressing/wsdl",
|
||||
"http://www.w3.org/2005/08/addressing/anonymous",
|
||||
"http://www.w3.org/2005/08/addressing/none",
|
||||
new EPR(W3CEndpointReference.class,
|
||||
"Address",
|
||||
"ServiceName",
|
||||
"EndpointName",
|
||||
"InterfaceName",
|
||||
new QName("http://www.w3.org/2005/08/addressing","Metadata","wsa"),
|
||||
"ReferenceParameters",
|
||||
null )) {
|
||||
|
||||
/* package */ String getActionMismatchLocalName() {
|
||||
return "ActionMismatch";
|
||||
}
|
||||
@Override
|
||||
public boolean isReferenceParameter(String localName) {
|
||||
return localName.equals("ReferenceParameters");
|
||||
}
|
||||
|
||||
@Override
|
||||
public WsaTubeHelper getWsaHelper(WSDLPort wsdlPort, SEIModel seiModel, WSBinding binding) {
|
||||
return new com.sun.xml.internal.ws.addressing.WsaTubeHelperImpl(wsdlPort, seiModel, binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package */ String getMapRequiredLocalName() {
|
||||
return "MessageAddressingHeaderRequired";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMapRequiredText() {
|
||||
return "A required header representing a Message Addressing Property is not present";
|
||||
}
|
||||
|
||||
/* package */ String getInvalidAddressLocalName() {
|
||||
return "InvalidAddress";
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package */ String getInvalidMapLocalName() {
|
||||
return "InvalidAddressingHeader";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvalidMapText() {
|
||||
return "A header representing a Message Addressing Property is not valid and the message cannot be processed";
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package */ String getInvalidCardinalityLocalName() {
|
||||
return "InvalidCardinality";
|
||||
}
|
||||
|
||||
/*package*/ Header createReferenceParameterHeader(XMLStreamBuffer mark, String nsUri, String localName) {
|
||||
return new OutboundReferenceParameterHeader(mark,nsUri,localName);
|
||||
}
|
||||
|
||||
/*package*/ String getIsReferenceParameterLocalName() {
|
||||
return "IsReferenceParameter";
|
||||
}
|
||||
|
||||
/* package */ String getWsdlAnonymousLocalName() {
|
||||
return "Anonymous";
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return "wsa";
|
||||
}
|
||||
|
||||
public String getWsdlPrefix() {
|
||||
return "wsaw";
|
||||
}
|
||||
|
||||
public Class<? extends WebServiceFeature> getFeatureClass() {
|
||||
return AddressingFeature.class;
|
||||
}
|
||||
},
|
||||
MEMBER("http://schemas.xmlsoap.org/ws/2004/08/addressing",
|
||||
"wsa",
|
||||
MemberSubmissionAddressingConstants.ANONYMOUS_EPR,
|
||||
"http://schemas.xmlsoap.org/ws/2004/08/addressing",
|
||||
"http://schemas.xmlsoap.org/ws/2004/08/addressing/policy",
|
||||
"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
|
||||
"",
|
||||
new EPR(MemberSubmissionEndpointReference.class,
|
||||
"Address",
|
||||
"ServiceName",
|
||||
"PortName",
|
||||
"PortType",
|
||||
MemberSubmissionAddressingConstants.MEX_METADATA,
|
||||
"ReferenceParameters",
|
||||
"ReferenceProperties")) {
|
||||
/* package */ String getActionMismatchLocalName() {
|
||||
return "InvalidMessageInformationHeader";
|
||||
}
|
||||
@Override
|
||||
public boolean isReferenceParameter(String localName) {
|
||||
return localName.equals("ReferenceParameters") || localName.equals("ReferenceProperties");
|
||||
}
|
||||
|
||||
@Override
|
||||
public WsaTubeHelper getWsaHelper(WSDLPort wsdlPort, SEIModel seiModel, WSBinding binding) {
|
||||
return new com.sun.xml.internal.ws.addressing.v200408.WsaTubeHelperImpl(wsdlPort, seiModel, binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package */ String getMapRequiredLocalName() {
|
||||
return "MessageInformationHeaderRequired";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMapRequiredText() {
|
||||
return "A required message information header, To, MessageID, or Action, is not present.";
|
||||
}
|
||||
|
||||
/* package */ String getInvalidAddressLocalName() {
|
||||
return getInvalidMapLocalName();
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package */ String getInvalidMapLocalName() {
|
||||
return "InvalidMessageInformationHeader";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvalidMapText() {
|
||||
return "A message information header is not valid and the message cannot be processed.";
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package */ String getInvalidCardinalityLocalName() {
|
||||
return getInvalidMapLocalName();
|
||||
}
|
||||
|
||||
/*package*/ Header createReferenceParameterHeader(XMLStreamBuffer mark, String nsUri, String localName) {
|
||||
return new OutboundStreamHeader(mark,nsUri,localName);
|
||||
}
|
||||
|
||||
/*package*/ String getIsReferenceParameterLocalName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/* package */ String getWsdlAnonymousLocalName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return "wsa";
|
||||
}
|
||||
|
||||
public String getWsdlPrefix() {
|
||||
return "wsaw";
|
||||
}
|
||||
|
||||
public Class<? extends WebServiceFeature> getFeatureClass() {
|
||||
return MemberSubmissionAddressingFeature.class;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace URI
|
||||
*/
|
||||
public final String nsUri;
|
||||
|
||||
/**
|
||||
* Namespace URI for the WSDL Binding
|
||||
*/
|
||||
public final String wsdlNsUri;
|
||||
|
||||
/**
|
||||
* Representing either {@link W3CEndpointReference} or
|
||||
* {@link MemberSubmissionEndpointReference}.
|
||||
*/
|
||||
public final EPR eprType;
|
||||
|
||||
/**
|
||||
* Namespace URI for the WSDL Binding
|
||||
*/
|
||||
public final String policyNsUri;
|
||||
|
||||
/**
|
||||
* Gets the anonymous URI value associated with this WS-Addressing version.
|
||||
*/
|
||||
public final @NotNull String anonymousUri;
|
||||
|
||||
/**
|
||||
* Gets the none URI value associated with this WS-Addressing version.
|
||||
*/
|
||||
public final @NotNull String noneUri;
|
||||
|
||||
/**
|
||||
* Represents the anonymous EPR.
|
||||
*/
|
||||
public final WSEndpointReference anonymousEpr;
|
||||
|
||||
/**
|
||||
* Represents the To QName in the SOAP message for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName toTag;
|
||||
|
||||
/**
|
||||
* Represents the From QName in the SOAP message for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName fromTag;
|
||||
|
||||
/**
|
||||
* Represents the ReplyTo QName in the SOAP message for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName replyToTag;
|
||||
|
||||
/**
|
||||
* Represents the FaultTo QName for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName faultToTag;
|
||||
|
||||
/**
|
||||
* Represents the Action QName in the SOAP message for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName actionTag;
|
||||
|
||||
/**
|
||||
* Represents the MessageID QName in the SOAP message for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName messageIDTag;
|
||||
|
||||
/**
|
||||
* Represents the RelatesTo QName in the SOAP message for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName relatesToTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the fault code when a required header representing a
|
||||
* WS-Addressing Message Addressing Property is not present.
|
||||
*/
|
||||
public final QName mapRequiredTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the fault code when Action is not supported at this endpoint.
|
||||
*/
|
||||
public final QName actionMismatchTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the fault code when Action is not supported at this endpoint.
|
||||
*/
|
||||
public final QName actionNotSupportedTag;
|
||||
|
||||
/**
|
||||
* Represents the text of the fault when Action is not supported at this endpoint.
|
||||
*/
|
||||
public final String actionNotSupportedText;
|
||||
|
||||
/**
|
||||
* Represents the QName of the fault code when a header representing a
|
||||
* WS-Addressing Message Addressing Property is invalid and cannot be processed.
|
||||
*/
|
||||
public final QName invalidMapTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the fault code when a header representing a
|
||||
* WS-Addressing Message Addressing Property occurs greater than expected number.
|
||||
*/
|
||||
public final QName invalidCardinalityTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the fault code when a header representing an
|
||||
* address is not valid.
|
||||
*/
|
||||
public final QName invalidAddressTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the element that conveys additional information
|
||||
* on the pre-defined WS-Addressing faults.
|
||||
*/
|
||||
public final QName problemHeaderQNameTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the element that conveys additional information
|
||||
* if Action is not matching with that expected.
|
||||
*/
|
||||
public final QName problemActionTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the header element that is used to capture the fault detail
|
||||
* if there is a fault processing WS-Addressing Message Addressing Property. This is
|
||||
* only used for SOAP 1.1.
|
||||
*/
|
||||
public final QName faultDetailTag;
|
||||
|
||||
/**
|
||||
* Fault sub-sub-code that represents
|
||||
* "Specifies that the invalid header was expected to be an EPR but did not contain an [address]."
|
||||
*/
|
||||
public final QName fault_missingAddressInEpr;
|
||||
|
||||
/**
|
||||
* Represents the Action QName in the WSDL for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName wsdlActionTag;
|
||||
|
||||
/**
|
||||
* Represents the WSDL extension QName for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName wsdlExtensionTag;
|
||||
|
||||
/**
|
||||
* Represents the WSDL anonymous QName for a specific WS-Addressing Version.
|
||||
*/
|
||||
public final QName wsdlAnonymousTag;
|
||||
|
||||
/**
|
||||
* Represents the QName of the reference parameter in a SOAP message. This is
|
||||
* only valid for W3C WS-Addressing.
|
||||
*/
|
||||
public final QName isReferenceParameterTag;
|
||||
|
||||
private static final String EXTENDED_FAULT_NAMESPACE = "http://jax-ws.dev.java.net/addressing/fault";
|
||||
public static final String UNSET_OUTPUT_ACTION = "http://jax-ws.dev.java.net/addressing/output-action-not-set";
|
||||
public static final String UNSET_INPUT_ACTION = "http://jax-ws.dev.java.net/addressing/input-action-not-set";
|
||||
|
||||
/**
|
||||
* Fault sub-sub-code that represents duplicate <Address> element in EPR.
|
||||
* This is a fault code not defined in the spec.
|
||||
*/
|
||||
public static final QName fault_duplicateAddressInEpr = new QName(
|
||||
EXTENDED_FAULT_NAMESPACE, "DuplicateAddressInEpr", "wsa"
|
||||
);
|
||||
|
||||
private AddressingVersion(String nsUri, String prefix, String anonymousEprString, String wsdlNsUri, String policyNsUri,
|
||||
String anonymousUri, String noneUri,
|
||||
EPR eprType ) {
|
||||
this.nsUri = nsUri;
|
||||
this.wsdlNsUri = wsdlNsUri;
|
||||
this.policyNsUri = policyNsUri;
|
||||
this.anonymousUri = anonymousUri;
|
||||
this.noneUri = noneUri;
|
||||
toTag = new QName(nsUri,"To", prefix);
|
||||
fromTag = new QName(nsUri,"From", prefix);
|
||||
replyToTag = new QName(nsUri,"ReplyTo", prefix);
|
||||
faultToTag = new QName(nsUri,"FaultTo", prefix);
|
||||
actionTag = new QName(nsUri,"Action", prefix);
|
||||
messageIDTag = new QName(nsUri,"MessageID", prefix);
|
||||
relatesToTag = new QName(nsUri,"RelatesTo", prefix);
|
||||
|
||||
mapRequiredTag = new QName(nsUri,getMapRequiredLocalName(), prefix);
|
||||
actionMismatchTag = new QName(nsUri,getActionMismatchLocalName(), prefix);
|
||||
actionNotSupportedTag = new QName(nsUri,"ActionNotSupported", prefix);
|
||||
actionNotSupportedText = "The \"%s\" cannot be processed at the receiver";
|
||||
invalidMapTag = new QName(nsUri,getInvalidMapLocalName(), prefix);
|
||||
invalidAddressTag = new QName(nsUri,getInvalidAddressLocalName(), prefix);
|
||||
invalidCardinalityTag = new QName(nsUri,getInvalidCardinalityLocalName(), prefix);
|
||||
faultDetailTag = new QName(nsUri,"FaultDetail", prefix);
|
||||
|
||||
problemHeaderQNameTag = new QName(nsUri,"ProblemHeaderQName", prefix);
|
||||
problemActionTag = new QName(nsUri, "ProblemAction", prefix);
|
||||
|
||||
fault_missingAddressInEpr = new QName(nsUri,"MissingAddressInEPR", prefix);
|
||||
isReferenceParameterTag = new QName(nsUri,getIsReferenceParameterLocalName(), prefix);
|
||||
|
||||
wsdlActionTag = new QName(wsdlNsUri,"Action", prefix);
|
||||
wsdlExtensionTag = new QName(wsdlNsUri, "UsingAddressing", prefix);
|
||||
wsdlAnonymousTag = new QName(wsdlNsUri, getWsdlAnonymousLocalName(), prefix);
|
||||
|
||||
// create stock anonymous EPR
|
||||
try {
|
||||
this.anonymousEpr = new WSEndpointReference(new ByteArrayInputStream(anonymousEprString.getBytes("UTF-8")),this);
|
||||
} catch (XMLStreamException e) {
|
||||
throw new Error(e); // bug in our code as EPR should parse.
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
this.eprType = eprType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the local name of the fault when a header representing a WS-Addressing Action is not same as SOAPAction
|
||||
*
|
||||
* @return local name
|
||||
*/
|
||||
/* package */ abstract String getActionMismatchLocalName();
|
||||
|
||||
/**
|
||||
* Returns {@link AddressingVersion} whose {@link #nsUri} equals to
|
||||
* the given string.
|
||||
*
|
||||
* This method does not perform input string validation.
|
||||
*
|
||||
* @param nsUri
|
||||
* must not be null.
|
||||
* @return always non-null.
|
||||
*/
|
||||
public static AddressingVersion fromNsUri(String nsUri) {
|
||||
if (nsUri.equals(W3C.nsUri))
|
||||
return W3C;
|
||||
|
||||
if (nsUri.equals(MEMBER.nsUri))
|
||||
return MEMBER;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link AddressingVersion} from a {@link WSBinding}
|
||||
*
|
||||
* @param binding WSDL binding
|
||||
* @return
|
||||
* addresing version enabled, or null if none is enabled.
|
||||
*/
|
||||
public static @Nullable
|
||||
AddressingVersion fromBinding(WSBinding binding) {
|
||||
// TODO: who is responsible for reporting an error if both versions
|
||||
// are on?
|
||||
if (binding.isFeatureEnabled(AddressingFeature.class))
|
||||
return W3C;
|
||||
|
||||
if (binding.isFeatureEnabled(MemberSubmissionAddressingFeature.class))
|
||||
return MEMBER;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link AddressingVersion} from a {@link WSDLPort}
|
||||
*
|
||||
* @param port WSDL port
|
||||
* @return addresing version
|
||||
*/
|
||||
public static AddressingVersion fromPort(WSDLPort port) {
|
||||
if (port == null)
|
||||
return null;
|
||||
|
||||
WebServiceFeature wsf = port.getFeature(AddressingFeature.class);
|
||||
if (wsf == null) {
|
||||
wsf = port.getFeature(MemberSubmissionAddressingFeature.class);
|
||||
}
|
||||
if (wsf == null)
|
||||
return null;
|
||||
|
||||
return fromFeature(wsf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link #nsUri} associated with this {@link AddressingVersion}
|
||||
*
|
||||
* @return namespace URI
|
||||
* @deprecated
|
||||
* Use {@link #nsUri}.
|
||||
*/
|
||||
public String getNsUri() {
|
||||
return nsUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given local name is considered as
|
||||
* a reference parameter in EPR.
|
||||
*
|
||||
* For W3C, this means "ReferenceParameters",
|
||||
* and for the member submission version, this means
|
||||
* either "ReferenceParameters" or "ReferenceProperties".
|
||||
*/
|
||||
public abstract boolean isReferenceParameter(String localName);
|
||||
|
||||
/**
|
||||
* Returns WsaTubeHelper for the WS-Addressing version identified by <code>binding</code>
|
||||
* {@link WSBinding} and for the {@link WSDLPort} port.
|
||||
*
|
||||
* @return WS-A version specific helper
|
||||
*
|
||||
* @deprecated
|
||||
* TODO why are we exposing implementation specificc class through api?
|
||||
* TODO Remove it if no one elase uses it.
|
||||
*/
|
||||
public abstract WsaTubeHelper getWsaHelper(WSDLPort wsdlPort, SEIModel seiModel, WSBinding binding);
|
||||
|
||||
/**
|
||||
* Gets the none URI value associated with this WS-Addressing version.
|
||||
*
|
||||
* @return none URI value
|
||||
* @deprecated
|
||||
* Use {@link #noneUri}.
|
||||
*/
|
||||
public final String getNoneUri() {
|
||||
return noneUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the anonymous URI value associated with this WS-Addressing version.
|
||||
*
|
||||
* @deprecated
|
||||
* Use {@link #anonymousUri}
|
||||
*/
|
||||
public final String getAnonymousUri() {
|
||||
return anonymousUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default fault Action value associated with this WS-Addressing version.
|
||||
*
|
||||
* @return default fault Action value
|
||||
*/
|
||||
public String getDefaultFaultAction() {
|
||||
return nsUri + "/fault";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the local name of the fault when a header representing a WS-Addressing Message
|
||||
* Addresing Property is absent.
|
||||
*
|
||||
* @return local name
|
||||
*/
|
||||
/* package */ abstract String getMapRequiredLocalName();
|
||||
|
||||
/**
|
||||
* Gets the description text when a required WS-Addressing header representing a
|
||||
* Message Addressing Property is absent.
|
||||
*
|
||||
* @return description text
|
||||
*/
|
||||
public abstract String getMapRequiredText();
|
||||
|
||||
/**
|
||||
* Gets the local name of the fault when a header representing anaddress is invalid.
|
||||
* @return local name
|
||||
*/
|
||||
/* package */ abstract String getInvalidAddressLocalName();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the local name of the fault when a header representing a WS-Addressing Message
|
||||
* Addresing Property is invalid and cannot be processed.
|
||||
*
|
||||
* @return local name
|
||||
*/
|
||||
/* package */ abstract String getInvalidMapLocalName();
|
||||
|
||||
/**
|
||||
* Gets the description text when a header representing a WS-Addressing
|
||||
* Message Addressing Property is invalid and cannot be processed.
|
||||
*
|
||||
* @return description text
|
||||
*/
|
||||
public abstract String getInvalidMapText();
|
||||
|
||||
/**
|
||||
* Gets the local name of the fault when a header representing a WS-Addressing Message
|
||||
* Addresing Property occurs greater than expected number.
|
||||
*
|
||||
* @return local name
|
||||
*/
|
||||
/* package */ abstract String getInvalidCardinalityLocalName();
|
||||
|
||||
/* package */ abstract String getWsdlAnonymousLocalName();
|
||||
|
||||
public abstract String getPrefix();
|
||||
|
||||
public abstract String getWsdlPrefix();
|
||||
|
||||
public abstract Class<? extends WebServiceFeature> getFeatureClass();
|
||||
/**
|
||||
* Creates an outbound {@link Header} from a reference parameter.
|
||||
*/
|
||||
/*package*/ abstract Header createReferenceParameterHeader(XMLStreamBuffer mark, String nsUri, String localName);
|
||||
|
||||
/**
|
||||
* Gets the local name for wsa:IsReferenceParameter. This method will return a valid
|
||||
* value only valid for W3C WS-Addressing. For Member Submission WS-Addressing, this method
|
||||
* returns null.
|
||||
*/
|
||||
/*package*/ abstract String getIsReferenceParameterLocalName();
|
||||
|
||||
public static AddressingVersion fromFeature(WebServiceFeature af) {
|
||||
if (af.getID().equals(AddressingFeature.ID))
|
||||
return W3C;
|
||||
else if (af.getID().equals(MemberSubmissionAddressingFeature.ID))
|
||||
return MEMBER;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link WebServiceFeature} corresponding to the namespace URI of
|
||||
* WS-Addressing policy assertion in the WSDL. <code>enabled</code> and
|
||||
* <code>required</code> are used to initialize the value of the feature.
|
||||
*
|
||||
* @param nsUri namespace URI of the WS-Addressing policy assertion in the WSDL
|
||||
* @param enabled true if feature is to be enabled, false otherwise
|
||||
* @param required true if feature is required, false otherwise. Corresponds
|
||||
* to wsdl:required on the extension/assertion.
|
||||
* @return WebServiceFeature corresponding to the assertion namespace URI
|
||||
* @throws WebServiceException if an unsupported namespace URI is passed
|
||||
*/
|
||||
public static @NotNull WebServiceFeature getFeature(String nsUri, boolean enabled, boolean required) {
|
||||
if (nsUri.equals(W3C.policyNsUri))
|
||||
return new AddressingFeature(enabled, required);
|
||||
else if (nsUri.equals(MEMBER.policyNsUri))
|
||||
return new MemberSubmissionAddressingFeature(enabled, required);
|
||||
else
|
||||
throw new WebServiceException("Unsupported namespace URI: " + nsUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the corresponding {@link AddressingVersion} instance from the
|
||||
* EPR class.
|
||||
*/
|
||||
public static @NotNull AddressingVersion fromSpecClass(Class<? extends EndpointReference> eprClass) {
|
||||
if(eprClass==W3CEndpointReference.class)
|
||||
return W3C;
|
||||
if(eprClass==MemberSubmissionEndpointReference.class)
|
||||
return MEMBER;
|
||||
throw new WebServiceException("Unsupported EPR type: "+eprClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the WebServiceFeature is either a {@link AddressingFeature} or
|
||||
* {@link MemberSubmissionAddressingFeature} and is required.
|
||||
*
|
||||
* @param wsf The WebServiceFeature encaps
|
||||
* @throws WebServiceException if <code>wsf</code> does not contain either {@link AddressingFeature} or
|
||||
* {@link MemberSubmissionAddressingFeature}
|
||||
* @return true if <code>wsf</code> requires WS-Addressing
|
||||
*/
|
||||
public static boolean isRequired(WebServiceFeature wsf) {
|
||||
if (wsf.getID().equals(AddressingFeature.ID)) {
|
||||
return ((AddressingFeature)wsf).isRequired();
|
||||
} else if (wsf.getID().equals(MemberSubmissionAddressingFeature.ID)) {
|
||||
return ((MemberSubmissionAddressingFeature)wsf).isRequired();
|
||||
} else
|
||||
throw new WebServiceException("WebServiceFeature not an Addressing feature: "+ wsf.getID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if <code>binding</code> contains either a {@link AddressingFeature} or
|
||||
* {@link MemberSubmissionAddressingFeature} and is required.
|
||||
*
|
||||
* @param binding The binding
|
||||
* @return true if <code>binding</code> requires WS-Addressing
|
||||
*/
|
||||
public static boolean isRequired(WSBinding binding) {
|
||||
AddressingFeature af = binding.getFeature(AddressingFeature.class);
|
||||
if (af != null)
|
||||
return af.isRequired();
|
||||
MemberSubmissionAddressingFeature msaf = binding.getFeature(MemberSubmissionAddressingFeature.class);
|
||||
if(msaf != null)
|
||||
return msaf.isRequired();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if <code>binding</code> contains either a {@link AddressingFeature} or
|
||||
* {@link MemberSubmissionAddressingFeature} and is enabled.
|
||||
*
|
||||
* @param binding The binding
|
||||
* @return true if WS-Addressing is enabled for <code>binding</code>.
|
||||
*/
|
||||
public static boolean isEnabled(WSBinding binding) {
|
||||
return binding.isFeatureEnabled(MemberSubmissionAddressingFeature.class) ||
|
||||
binding.isFeatureEnabled(AddressingFeature.class);
|
||||
}
|
||||
|
||||
public final static class EPR {
|
||||
public final Class<? extends EndpointReference> eprClass;
|
||||
public final String address;
|
||||
public final String serviceName;
|
||||
public final String portName;
|
||||
public final String portTypeName;
|
||||
public final String referenceParameters;
|
||||
/**
|
||||
* Element under which metadata is specified.
|
||||
* In W3C, it is wsa:Metadata
|
||||
* In Member, it is directly under mex:MetadataSection
|
||||
*/
|
||||
public final QName wsdlMetadata;
|
||||
public final String referenceProperties;
|
||||
|
||||
public EPR(Class<? extends EndpointReference> eprClass, String address, String serviceName, String portName,
|
||||
String portTypeName, QName wsdlMetadata,
|
||||
String referenceParameters, String referenceProperties) {
|
||||
this.eprClass = eprClass;
|
||||
this.address = address;
|
||||
this.serviceName = serviceName;
|
||||
this.portName = portName;
|
||||
this.portTypeName = portTypeName;
|
||||
this.referenceParameters = referenceParameters;
|
||||
this.referenceProperties = referenceProperties;
|
||||
this.wsdlMetadata = wsdlMetadata;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.addressing;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Writer;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.message.AbstractHeaderImpl;
|
||||
import com.sun.xml.internal.ws.util.xml.XmlUtil;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.soap.SOAPHeader;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
|
||||
/**
|
||||
* Used to represent outbound endpoint reference header,
|
||||
* such as <ReplyTo> and <FaultTo>.
|
||||
* Used from {@link WSEndpointReference}.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see WSEndpointReference
|
||||
*/
|
||||
final class EPRHeader extends AbstractHeaderImpl {
|
||||
|
||||
private final String nsUri,localName;
|
||||
private final WSEndpointReference epr;
|
||||
|
||||
EPRHeader(QName tagName, WSEndpointReference epr) {
|
||||
this.nsUri = tagName.getNamespaceURI();
|
||||
this.localName = tagName.getLocalPart();
|
||||
this.epr = epr;
|
||||
}
|
||||
|
||||
public @NotNull String getNamespaceURI() {
|
||||
return nsUri;
|
||||
}
|
||||
|
||||
public @NotNull String getLocalPart() {
|
||||
return localName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getAttribute(@NotNull String nsUri, @NotNull String localName) {
|
||||
try {
|
||||
XMLStreamReader sr = epr.read("EndpointReference"/*doesn't matter*/);
|
||||
while(sr.getEventType()!= XMLStreamConstants.START_ELEMENT)
|
||||
sr.next();
|
||||
|
||||
return sr.getAttributeValue(nsUri,localName);
|
||||
} catch (XMLStreamException e) {
|
||||
// since we are reading from buffer, this can't happen.
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public XMLStreamReader readHeader() throws XMLStreamException {
|
||||
return epr.read(localName);
|
||||
}
|
||||
|
||||
public void writeTo(XMLStreamWriter w) throws XMLStreamException {
|
||||
epr.writeTo(localName, w);
|
||||
}
|
||||
|
||||
public void writeTo(SOAPMessage saaj) throws SOAPException {
|
||||
try {
|
||||
// TODO what about in-scope namespaces
|
||||
// Not very efficient consider implementing a stream buffer
|
||||
// processor that produces a DOM node from the buffer.
|
||||
Transformer t = XmlUtil.newTransformer();
|
||||
SOAPHeader header = saaj.getSOAPHeader();
|
||||
if (header == null)
|
||||
header = saaj.getSOAPPart().getEnvelope().addHeader();
|
||||
// TODO workaround for oracle xdk bug 16555545, when this bug is fixed the line below can be
|
||||
// uncommented and all lines below, except the catch block, can be removed.
|
||||
// t.transform(epr.asSource(localName), new DOMResult(header));
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
XMLStreamWriter w = XMLOutputFactory.newFactory().createXMLStreamWriter(baos);
|
||||
epr.writeTo(localName, w);
|
||||
w.flush();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
|
||||
fac.setNamespaceAware(true);
|
||||
Node eprNode = fac.newDocumentBuilder().parse(bais).getDocumentElement();
|
||||
Node eprNodeToAdd = header.getOwnerDocument().importNode(eprNode, true);
|
||||
header.appendChild(eprNodeToAdd);
|
||||
} catch (Exception e) {
|
||||
throw new SOAPException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
|
||||
epr.writeTo(localName,contentHandler,errorHandler,true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.addressing;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.WSService;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.pipe.ClientTubeAssemblerContext;
|
||||
import com.sun.xml.internal.ws.api.pipe.Fiber;
|
||||
import com.sun.xml.internal.ws.api.pipe.TransportTubeFactory;
|
||||
import com.sun.xml.internal.ws.api.pipe.Tube;
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
import com.sun.xml.internal.ws.binding.BindingImpl;
|
||||
|
||||
/**
|
||||
* Delivers response messages targeted at non-anonymous endpoint addresses
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public class NonAnonymousResponseProcessor {
|
||||
private static final NonAnonymousResponseProcessor DEFAULT = new NonAnonymousResponseProcessor();
|
||||
|
||||
public static NonAnonymousResponseProcessor getDefault() {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
protected NonAnonymousResponseProcessor() {}
|
||||
|
||||
/**
|
||||
* Send a response to a non-anonymous address. Also closes the transport back channel
|
||||
* of {@link Packet} if it's not closed already.
|
||||
*
|
||||
* @param packet
|
||||
* The response from our server, which will be delivered to the destination.
|
||||
* @return The response packet that should be used to complete the tubeline response processing
|
||||
*/
|
||||
public Packet process(Packet packet) {
|
||||
Fiber.CompletionCallback fiberCallback = null;
|
||||
Fiber currentFiber = Fiber.getCurrentIfSet();
|
||||
if (currentFiber != null) {
|
||||
// Link completion of the current fiber to the new fiber that will
|
||||
// deliver the async response. This allows access to the response
|
||||
// packet that may be generated by sending a new message for the
|
||||
// current async response.
|
||||
|
||||
final Fiber.CompletionCallback currentFiberCallback =
|
||||
currentFiber.getCompletionCallback();
|
||||
|
||||
if (currentFiberCallback != null) {
|
||||
fiberCallback = new Fiber.CompletionCallback() {
|
||||
public void onCompletion(@NotNull Packet response) {
|
||||
currentFiberCallback.onCompletion(response);
|
||||
}
|
||||
|
||||
public void onCompletion(@NotNull Throwable error) {
|
||||
currentFiberCallback.onCompletion(error);
|
||||
}
|
||||
};
|
||||
currentFiber.setCompletionCallback(null);
|
||||
}
|
||||
}
|
||||
|
||||
// we need to assemble a pipeline to talk to this endpoint.
|
||||
WSEndpoint<?> endpoint = packet.endpoint;
|
||||
WSBinding binding = endpoint.getBinding();
|
||||
Tube transport = TransportTubeFactory.create(Thread.currentThread().getContextClassLoader(),
|
||||
new ClientTubeAssemblerContext(
|
||||
packet.endpointAddress, endpoint.getPort(), (WSService) null,
|
||||
binding, endpoint.getContainer(),
|
||||
((BindingImpl) binding).createCodec(), null, null));
|
||||
Fiber fiber = endpoint.getEngine().createFiber();
|
||||
fiber.start(transport, packet, fiberCallback);
|
||||
|
||||
// then we'll proceed the rest like one-way.
|
||||
Packet copy = packet.copy(false);
|
||||
copy.endpointAddress = null;
|
||||
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.addressing;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.FeatureConstructor;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
import com.sun.org.glassfish.gmbal.ManagedAttribute;
|
||||
import com.sun.org.glassfish.gmbal.ManagedData;
|
||||
|
||||
/**
|
||||
* Unsupported RI extension to work around an issue in WSIT.
|
||||
*
|
||||
* <p>
|
||||
* <b>This feature is not meant to be used by a common Web service developer</b> as there
|
||||
* is no need to send the above mentioned header for a one-way operation. But these
|
||||
* properties may need to be sent in certain middleware Web services.
|
||||
*
|
||||
* <p>
|
||||
* This feature allows ReplyTo, From and RelatesTo Message Addressing Properties
|
||||
* to be added for all messages that are sent from the port configured with
|
||||
* this annotation. All operations are assumed to be one-way, and
|
||||
* this feature should be used for one-way
|
||||
* operations only.
|
||||
*
|
||||
* If a non-null ReplyTo is specified, then MessageID property is also added.
|
||||
*
|
||||
* @author Arun Gupta
|
||||
*/
|
||||
@ManagedData
|
||||
public class OneWayFeature extends WebServiceFeature {
|
||||
/**
|
||||
* Constant value identifying the {@link OneWayFeature}
|
||||
*/
|
||||
public static final String ID = "http://java.sun.com/xml/ns/jaxws/addressing/oneway";
|
||||
|
||||
private String messageId;
|
||||
private WSEndpointReference replyTo;
|
||||
private WSEndpointReference sslReplyTo;
|
||||
private WSEndpointReference from;
|
||||
private WSEndpointReference faultTo;
|
||||
private WSEndpointReference sslFaultTo;
|
||||
private String relatesToID;
|
||||
private boolean useAsyncWithSyncInvoke = false;
|
||||
|
||||
/**
|
||||
* Create an {@link OneWayFeature}. The instance created will be enabled.
|
||||
*/
|
||||
public OneWayFeature() {
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an {@link OneWayFeature}
|
||||
*
|
||||
* @param enabled specifies whether this feature should
|
||||
* be enabled or not.
|
||||
*/
|
||||
public OneWayFeature(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an {@link OneWayFeature}
|
||||
*
|
||||
* @param enabled specifies whether this feature should be enabled or not.
|
||||
* @param replyTo specifies the {@link WSEndpointReference} of wsa:ReplyTo header.
|
||||
*/
|
||||
public OneWayFeature(boolean enabled, WSEndpointReference replyTo) {
|
||||
this.enabled = enabled;
|
||||
this.replyTo = replyTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an {@link OneWayFeature}
|
||||
*
|
||||
* @param enabled specifies whether this feature should be enabled or not.
|
||||
* @param replyTo specifies the {@link WSEndpointReference} of wsa:ReplyTo header.
|
||||
* @param from specifies the {@link WSEndpointReference} of wsa:From header.
|
||||
* @param relatesTo specifies the MessageID to be used for wsa:RelatesTo header.
|
||||
*/
|
||||
@FeatureConstructor({"enabled","replyTo","from","relatesTo"})
|
||||
public OneWayFeature(boolean enabled, WSEndpointReference replyTo, WSEndpointReference from, String relatesTo) {
|
||||
this.enabled = enabled;
|
||||
this.replyTo = replyTo;
|
||||
this.from = from;
|
||||
this.relatesToID = relatesTo;
|
||||
}
|
||||
|
||||
public OneWayFeature(final AddressingPropertySet a, AddressingVersion v) {
|
||||
this.enabled = true;
|
||||
this.messageId = a.getMessageId();
|
||||
this.relatesToID = a.getRelatesTo();
|
||||
this.replyTo = makeEPR(a.getReplyTo(), v);
|
||||
this.faultTo = makeEPR(a.getFaultTo(), v);
|
||||
}
|
||||
|
||||
private WSEndpointReference makeEPR(final String x, final AddressingVersion v) {
|
||||
if (x == null) { return null; }
|
||||
return new WSEndpointReference(x, v);
|
||||
}
|
||||
|
||||
public String getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ManagedAttribute
|
||||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public boolean
|
||||
hasSslEprs() {
|
||||
return sslReplyTo != null || sslFaultTo != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for wsa:ReplyTo header {@link WSEndpointReference} .
|
||||
*
|
||||
* @return address of the wsa:ReplyTo header
|
||||
*/
|
||||
@ManagedAttribute
|
||||
public WSEndpointReference getReplyTo() {
|
||||
return replyTo;
|
||||
}
|
||||
|
||||
public WSEndpointReference getReplyTo(boolean ssl) {
|
||||
return (ssl && sslReplyTo != null) ? sslReplyTo : replyTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for wsa:ReplyTo header {@link WSEndpointReference}.
|
||||
*
|
||||
* @param address
|
||||
*/
|
||||
public void setReplyTo(WSEndpointReference address) {
|
||||
this.replyTo = address;
|
||||
}
|
||||
|
||||
public WSEndpointReference getSslReplyTo() {
|
||||
return sslReplyTo;
|
||||
}
|
||||
|
||||
public void setSslReplyTo(WSEndpointReference sslReplyTo) {
|
||||
this.sslReplyTo = sslReplyTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for wsa:From header {@link WSEndpointReference}.
|
||||
*
|
||||
* @return address of the wsa:From header
|
||||
*/
|
||||
@ManagedAttribute
|
||||
public WSEndpointReference getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for wsa:From header {@link WSEndpointReference}.
|
||||
*
|
||||
* @param address of the wsa:From header
|
||||
*/
|
||||
public void setFrom(WSEndpointReference address) {
|
||||
this.from = address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for MessageID for wsa:RelatesTo header.
|
||||
*
|
||||
* @return address of the wsa:FaultTo header
|
||||
*/
|
||||
@ManagedAttribute
|
||||
public String getRelatesToID() {
|
||||
return relatesToID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for MessageID for wsa:RelatesTo header.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void setRelatesToID(String id) {
|
||||
this.relatesToID = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for wsa:FaultTo header {@link WSEndpointReference}.
|
||||
*
|
||||
* @return address of the wsa:FaultTo header
|
||||
*/
|
||||
public WSEndpointReference getFaultTo() {
|
||||
return faultTo;
|
||||
}
|
||||
|
||||
public WSEndpointReference getFaultTo(boolean ssl) {
|
||||
return (ssl && sslFaultTo != null) ? sslFaultTo : faultTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for wsa:FaultTo header {@link WSEndpointReference}.
|
||||
*
|
||||
* @param address of the wsa:FaultTo header
|
||||
*/
|
||||
public void setFaultTo(WSEndpointReference address) {
|
||||
this.faultTo = address;
|
||||
}
|
||||
|
||||
public WSEndpointReference getSslFaultTo() {
|
||||
return sslFaultTo;
|
||||
}
|
||||
|
||||
public void setSslFaultTo(WSEndpointReference sslFaultTo) {
|
||||
this.sslFaultTo = sslFaultTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for whether async is to be used with sync invoke
|
||||
*
|
||||
* @return whether async is to be used with sync invoke
|
||||
*/
|
||||
public boolean isUseAsyncWithSyncInvoke() {
|
||||
return useAsyncWithSyncInvoke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for whether async is to be used with sync invoke
|
||||
*
|
||||
* @param useAsyncWithSyncInvoke whether async is to be used with sync invoke
|
||||
*/
|
||||
public void setUseAsyncWithSyncInvoke(boolean useAsyncWithSyncInvoke) {
|
||||
this.useAsyncWithSyncInvoke = useAsyncWithSyncInvoke;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate a new EPR using an existing one and substituting SSL specific
|
||||
* host and port values.
|
||||
* @param epr Existing EPR that will be the starting point for the SSL
|
||||
* version
|
||||
* @param sslHost New SSL host or null if the existing host should be used
|
||||
* @param sslPort New SSL port or -1 if the existing port should be used
|
||||
* @return
|
||||
*/
|
||||
public static WSEndpointReference
|
||||
enableSslForEpr(@NotNull WSEndpointReference epr,
|
||||
@Nullable String sslHost,
|
||||
int sslPort) {
|
||||
if (!epr.isAnonymous()) {
|
||||
String address = epr.getAddress();
|
||||
URL url;
|
||||
try {
|
||||
url = new URL(address);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
String protocol = url.getProtocol();
|
||||
if (!protocol.equalsIgnoreCase("https")) {
|
||||
protocol = "https";
|
||||
String host = url.getHost();
|
||||
if (sslHost != null) {
|
||||
host = sslHost;
|
||||
}
|
||||
int port = url.getPort();
|
||||
if (sslPort > 0) {
|
||||
port = sslPort;
|
||||
}
|
||||
try {
|
||||
url = new URL(protocol, host, port, url.getFile());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
address = url.toExternalForm();
|
||||
return
|
||||
new WSEndpointReference(address, epr.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
return epr;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,397 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.addressing;
|
||||
|
||||
import com.sun.istack.internal.FinalArrayList;
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.stream.buffer.XMLStreamBuffer;
|
||||
import com.sun.xml.internal.stream.buffer.XMLStreamBufferException;
|
||||
import com.sun.xml.internal.ws.api.message.Header;
|
||||
import com.sun.xml.internal.ws.message.AbstractHeaderImpl;
|
||||
import com.sun.xml.internal.ws.util.xml.XMLStreamWriterFilter;
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
import org.xml.sax.helpers.XMLFilterImpl;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.soap.SOAPHeader;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.stream.util.StreamReaderDelegate;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* Used to represent outbound header created from {@link WSEndpointReference}'s
|
||||
* referenec parameters.
|
||||
*
|
||||
* <p>
|
||||
* This is optimized for outbound use, so it implements some of the methods lazily,
|
||||
* in a slow way.
|
||||
*
|
||||
* <p>
|
||||
* This header adds "wsa:IsReferenceParameter" and thus only used for the W3C version.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
final class OutboundReferenceParameterHeader extends AbstractHeaderImpl {
|
||||
private final XMLStreamBuffer infoset;
|
||||
private final String nsUri,localName;
|
||||
|
||||
/**
|
||||
* The attributes on the header element.
|
||||
* Lazily parsed.
|
||||
* Null if not parsed yet.
|
||||
*/
|
||||
private FinalArrayList<Attribute> attributes;
|
||||
|
||||
OutboundReferenceParameterHeader(XMLStreamBuffer infoset, String nsUri, String localName) {
|
||||
this.infoset = infoset;
|
||||
this.nsUri = nsUri;
|
||||
this.localName = localName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getNamespaceURI() {
|
||||
return nsUri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getLocalPart() {
|
||||
return localName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttribute(String nsUri, String localName) {
|
||||
if(attributes==null) {
|
||||
parseAttributes();
|
||||
}
|
||||
for(int i=attributes.size()-1; i>=0; i-- ) {
|
||||
Attribute a = attributes.get(i);
|
||||
if (a.localName.equals(localName) && a.nsUri.equals(nsUri)) {
|
||||
return a.value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* We don't really expect this to be used, but just to satisfy
|
||||
* the {@link Header} contract.
|
||||
*
|
||||
* So this is rather slow.
|
||||
*/
|
||||
private void parseAttributes() {
|
||||
try {
|
||||
XMLStreamReader reader = readHeader();
|
||||
reader.nextTag(); // move to the first element, which is the header element
|
||||
|
||||
attributes = new FinalArrayList<Attribute>();
|
||||
boolean refParamAttrWritten = false;
|
||||
for (int i = 0; i < reader.getAttributeCount(); i++) {
|
||||
final String attrLocalName = reader.getAttributeLocalName(i);
|
||||
final String namespaceURI = reader.getAttributeNamespace(i);
|
||||
final String value = reader.getAttributeValue(i);
|
||||
if (namespaceURI.equals(AddressingVersion.W3C.nsUri)&& attrLocalName.equals("IS_REFERENCE_PARAMETER")) {
|
||||
refParamAttrWritten = true;
|
||||
}
|
||||
attributes.add(new Attribute(namespaceURI,attrLocalName,value));
|
||||
}
|
||||
// we are adding one more attribute "wsa:IsReferenceParameter", if its not alrady there
|
||||
if (!refParamAttrWritten) {
|
||||
attributes.add(new Attribute(AddressingVersion.W3C.nsUri,IS_REFERENCE_PARAMETER,TRUE_VALUE));
|
||||
}
|
||||
} catch (XMLStreamException e) {
|
||||
throw new WebServiceException("Unable to read the attributes for {"+nsUri+"}"+localName+" header",e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLStreamReader readHeader() throws XMLStreamException {
|
||||
return new StreamReaderDelegate(infoset.readAsXMLStreamReader()) {
|
||||
int state=0; /* 0:expecting root, 1:in root, 2:past root */
|
||||
@Override
|
||||
public int next() throws XMLStreamException {
|
||||
return check(super.next());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextTag() throws XMLStreamException {
|
||||
return check(super.nextTag());
|
||||
}
|
||||
|
||||
private int check(int type) {
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (type == START_ELEMENT) {
|
||||
state = 1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
state = 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAttributeCount() {
|
||||
if (state == 1) {
|
||||
return super.getAttributeCount()+1;
|
||||
} else {
|
||||
return super.getAttributeCount();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeLocalName(int index) {
|
||||
if (state == 1 && index == super.getAttributeCount()) {
|
||||
return IS_REFERENCE_PARAMETER;
|
||||
} else {
|
||||
return super.getAttributeLocalName(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeNamespace(int index) {
|
||||
if (state == 1 && index==super.getAttributeCount()) {
|
||||
return AddressingVersion.W3C.nsUri;
|
||||
}
|
||||
else {
|
||||
return super.getAttributeNamespace(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributePrefix(int index) {
|
||||
if(state==1 && index==super.getAttributeCount()) {
|
||||
return "wsa";
|
||||
} else {
|
||||
return super.getAttributePrefix(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeType(int index) {
|
||||
if(state==1 && index==super.getAttributeCount()) {
|
||||
return "CDATA";
|
||||
} else {
|
||||
return super.getAttributeType(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeValue(int index) {
|
||||
if(state==1 && index==super.getAttributeCount()) {
|
||||
return TRUE_VALUE;
|
||||
} else {
|
||||
return super.getAttributeValue(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getAttributeName(int index) {
|
||||
if(state==1 && index==super.getAttributeCount()) {
|
||||
return new QName(AddressingVersion.W3C.nsUri, IS_REFERENCE_PARAMETER, "wsa");
|
||||
} else {
|
||||
return super.getAttributeName(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeValue(String namespaceUri, String localName) {
|
||||
if(state==1 && localName.equals(IS_REFERENCE_PARAMETER) && namespaceUri.equals(AddressingVersion.W3C.nsUri)) {
|
||||
return TRUE_VALUE;
|
||||
} else {
|
||||
return super.getAttributeValue(namespaceUri, localName);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(XMLStreamWriter w) throws XMLStreamException {
|
||||
infoset.writeToXMLStreamWriter(new XMLStreamWriterFilter(w) {
|
||||
private boolean root=true;
|
||||
private boolean onRootEl = true;
|
||||
@Override
|
||||
public void writeStartElement(String localName) throws XMLStreamException {
|
||||
super.writeStartElement(localName);
|
||||
writeAddedAttribute();
|
||||
}
|
||||
|
||||
private void writeAddedAttribute() throws XMLStreamException {
|
||||
if(!root) {
|
||||
onRootEl = false;
|
||||
return;
|
||||
}
|
||||
root=false;
|
||||
writeNamespace("wsa",AddressingVersion.W3C.nsUri);
|
||||
super.writeAttribute("wsa",AddressingVersion.W3C.nsUri,IS_REFERENCE_PARAMETER,TRUE_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException {
|
||||
super.writeStartElement(namespaceURI, localName);
|
||||
writeAddedAttribute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
|
||||
//TODO: Verify with KK later
|
||||
//check if prefix is declared before writing start element.
|
||||
boolean prefixDeclared = isPrefixDeclared(prefix,namespaceURI);
|
||||
super.writeStartElement(prefix, localName, namespaceURI);
|
||||
if (!prefixDeclared && !prefix.equals("")) {
|
||||
super.writeNamespace(prefix,namespaceURI);
|
||||
}
|
||||
writeAddedAttribute();
|
||||
}
|
||||
@Override
|
||||
public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException{
|
||||
if (!isPrefixDeclared(prefix, namespaceURI)) {
|
||||
super.writeNamespace(prefix,namespaceURI);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAttribute(String prefix, String namespaceURI, String localName, String value) throws XMLStreamException {
|
||||
//skip if its on root element and attribute is wsa;IsReferenceParameter, as we write it.
|
||||
if(onRootEl && namespaceURI.equals(AddressingVersion.W3C.nsUri)
|
||||
&& localName.equals(IS_REFERENCE_PARAMETER)) {
|
||||
return;
|
||||
}
|
||||
writer.writeAttribute(prefix, namespaceURI, localName, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException {
|
||||
writer.writeAttribute(namespaceURI, localName, value);
|
||||
}
|
||||
private boolean isPrefixDeclared(String prefix, String namespaceURI ) {
|
||||
return namespaceURI.equals(getNamespaceContext().getNamespaceURI(prefix));
|
||||
}
|
||||
},true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(SOAPMessage saaj) throws SOAPException {
|
||||
//TODO: SAAJ returns null instead of throwing SOAPException,
|
||||
// when there is no SOAPHeader in the message,
|
||||
// which leads to NPE.
|
||||
try {
|
||||
SOAPHeader header = saaj.getSOAPHeader();
|
||||
if (header == null) {
|
||||
header = saaj.getSOAPPart().getEnvelope().addHeader();
|
||||
}
|
||||
Element node = (Element)infoset.writeTo(header);
|
||||
node.setAttributeNS(AddressingVersion.W3C.nsUri,AddressingVersion.W3C.getPrefix()+":"+IS_REFERENCE_PARAMETER,TRUE_VALUE);
|
||||
} catch (XMLStreamBufferException e) {
|
||||
throw new SOAPException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
|
||||
class Filter extends XMLFilterImpl {
|
||||
Filter(ContentHandler ch) { setContentHandler(ch); }
|
||||
private int depth=0;
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
|
||||
if(depth++==0) {
|
||||
// add one more attribute
|
||||
super.startPrefixMapping("wsa",AddressingVersion.W3C.nsUri);
|
||||
|
||||
//Add the attirbute wsa:IsReferenceParameter if not present already
|
||||
if(atts.getIndex(AddressingVersion.W3C.nsUri,IS_REFERENCE_PARAMETER) == -1) {
|
||||
AttributesImpl atts2 = new AttributesImpl(atts);
|
||||
atts2.addAttribute(
|
||||
AddressingVersion.W3C.nsUri,
|
||||
IS_REFERENCE_PARAMETER,
|
||||
"wsa:IsReferenceParameter",
|
||||
"CDATA",
|
||||
TRUE_VALUE);
|
||||
atts = atts2;
|
||||
}
|
||||
}
|
||||
|
||||
super.startElement(uri, localName, qName, atts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||
super.endElement(uri, localName, qName);
|
||||
if (--depth == 0) {
|
||||
super.endPrefixMapping("wsa");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
infoset.writeTo(new Filter(contentHandler),errorHandler);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Keep the information about an attribute on the header element.
|
||||
*/
|
||||
static final class Attribute {
|
||||
/**
|
||||
* Can be empty but never null.
|
||||
*/
|
||||
final String nsUri;
|
||||
final String localName;
|
||||
final String value;
|
||||
|
||||
public Attribute(String nsUri, String localName, String value) {
|
||||
this.nsUri = fixNull(nsUri);
|
||||
this.localName = localName;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert null to "".
|
||||
*/
|
||||
private static String fixNull(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We the performance paranoid people in the JAX-WS RI thinks
|
||||
* saving three bytes is worth while...
|
||||
*/
|
||||
private static final String TRUE_VALUE = "1";
|
||||
private static final String IS_REFERENCE_PARAMETER = "IsReferenceParameter";
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@javax.xml.bind.annotation.XmlSchema(namespace="http://schemas.xmlsoap.org/ws/2004/08/addressing",
|
||||
location = "http://schemas.xmlsoap.org/ws/2004/08/addressing")
|
||||
package com.sun.xml.internal.ws.api.addressing;
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.client;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.ws.api.pipe.Pipe;
|
||||
import com.sun.xml.internal.ws.api.pipe.ClientPipeAssemblerContext;
|
||||
|
||||
/**
|
||||
* Allow the container (primarily Glassfish) to inject
|
||||
* their own pipes into the client pipeline.
|
||||
*
|
||||
* <p>
|
||||
* This interface has a rather ad-hoc set of methods, because
|
||||
* we didn't want to define an autonomous pipe-assembly process.
|
||||
* (We thought this is a smaller evil compared to that.)
|
||||
*
|
||||
* <p>
|
||||
* JAX-WS obtains this through {@link com.sun.xml.internal.ws.api.server.Container#getSPI(Class)}.
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
*/
|
||||
public abstract class ClientPipelineHook {
|
||||
|
||||
/**
|
||||
* Called during the pipeline construction process once to allow a container
|
||||
* to register a pipe for security.
|
||||
*
|
||||
* This pipe will be injected to a point very close to the transport, allowing
|
||||
* it to do some security operations.
|
||||
*
|
||||
* @param ctxt
|
||||
* Represents abstraction of SEI, WSDL abstraction etc. Context can be used
|
||||
* whether add a new pipe to the head or not.
|
||||
*
|
||||
* @param tail
|
||||
* Head of the partially constructed pipeline. If the implementation
|
||||
* wishes to add new pipes, it should do so by extending
|
||||
* {@link com.sun.xml.internal.ws.api.pipe.helper.AbstractFilterPipeImpl} and making sure that this {@link com.sun.xml.internal.ws.api.pipe.Pipe}
|
||||
* eventually processes messages.
|
||||
*
|
||||
* @return
|
||||
* The default implementation just returns <tt>tail</tt>, which means
|
||||
* no additional pipe is inserted. If the implementation adds
|
||||
* new pipes, return the new head pipe.
|
||||
*/
|
||||
public @NotNull Pipe createSecurityPipe(ClientPipeAssemblerContext ctxt, @NotNull Pipe tail) {
|
||||
return tail;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.client;
|
||||
|
||||
import com.sun.xml.internal.ws.api.FeatureConstructor;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
import com.sun.org.glassfish.gmbal.ManagedAttribute;
|
||||
import com.sun.org.glassfish.gmbal.ManagedData;
|
||||
|
||||
/**
|
||||
* Client side feature to enable or disable the selection of the optimal
|
||||
* encoding by the client when sending outbound messages.
|
||||
* <p>
|
||||
* The following describes the affects of this feature with respect
|
||||
* to being enabled or disabled:
|
||||
* <ul>
|
||||
* <li> ENABLED: In this Mode, the most optimal encoding will be selected
|
||||
* depending on the configuration and capabilities of the client
|
||||
* the capabilities of the Web service.
|
||||
* <li> DISABLED: In this Mode, the default encoding will be selected.
|
||||
* </ul>
|
||||
* <p>
|
||||
* If this feature is not present on a Web service then the default behaviour
|
||||
* is equivalent to this feature being present and disabled.
|
||||
* <p>
|
||||
* If this feature is enabled by the client and the Service supports the
|
||||
* Fast Infoset encoding, as specified by the {@link com.sun.xml.internal.ws.api.fastinfoset.FastInfosetFeature},
|
||||
* and Fast Infoset is determined to be the most optimal encoding, then the
|
||||
* Fast Infoset encoding will be automatically selected by the client.
|
||||
* <p>
|
||||
* TODO: Still not sure if a feature is a server side only thing or can
|
||||
* also be a client side thing. If the former then this class should be
|
||||
* removed.
|
||||
* @author Paul.Sandoz@Sun.Com
|
||||
*/
|
||||
@ManagedData
|
||||
public class SelectOptimalEncodingFeature extends WebServiceFeature {
|
||||
/**
|
||||
* Constant value identifying the {@link SelectOptimalEncodingFeature}
|
||||
*/
|
||||
public static final String ID = "http://java.sun.com/xml/ns/jaxws/client/selectOptimalEncoding";
|
||||
|
||||
/**
|
||||
* Create a {@link SelectOptimalEncodingFeature}.
|
||||
* The instance created will be enabled.
|
||||
*/
|
||||
public SelectOptimalEncodingFeature() {
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link SelectOptimalEncodingFeature}
|
||||
*
|
||||
* @param enabled specifies whether this feature should
|
||||
* be enabled or not.
|
||||
*/
|
||||
@FeatureConstructor({"enabled"})
|
||||
public SelectOptimalEncodingFeature(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ManagedAttribute
|
||||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.client;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.BindingID;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.WSFeatureList;
|
||||
import com.sun.xml.internal.ws.api.WSService;
|
||||
import com.sun.xml.internal.ws.developer.WSBindingProvider;
|
||||
|
||||
import javax.xml.ws.BindingProvider;
|
||||
import javax.xml.ws.Dispatch;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Interception point for inner working of {@link WSService}.
|
||||
*
|
||||
* <p>
|
||||
* System-level code could hook an implementation of this to
|
||||
* {@link WSService} to augument its behavior.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @since 2.1 EA3
|
||||
* @see ServiceInterceptorFactory
|
||||
*/
|
||||
public abstract class ServiceInterceptor {
|
||||
/**
|
||||
* Called before {@link WSBinding} is created, to allow interceptors
|
||||
* to add {@link WebServiceFeature}s to the created {@link WSBinding}.
|
||||
*
|
||||
* @param port
|
||||
* Information about the port for which dispatch/proxy will be created.
|
||||
* @param serviceEndpointInterface
|
||||
* Null if the created binding is for {@link Dispatch}. Otheriwse
|
||||
* it represents the port interface of the proxy to be created.
|
||||
* @param defaultFeatures
|
||||
* The list of features that are currently scheduled to be set for
|
||||
* the newly created {@link WSBinding}.
|
||||
*
|
||||
* @return
|
||||
* A set of features to be added to the newly created {@link WSBinding}.
|
||||
* Can be empty but never null.
|
||||
* <tt>defaultFeatures</tt> will take precedence over what this method
|
||||
* would return (because it includes user-specified ones which will
|
||||
* take the at-most priority), but features you return from this method
|
||||
* will take precedence over {@link BindingID}'s
|
||||
* {@link BindingID#createBuiltinFeatureList() implicit features}.
|
||||
*/
|
||||
public List<WebServiceFeature> preCreateBinding(@NotNull WSPortInfo port, @Nullable Class<?> serviceEndpointInterface, @NotNull WSFeatureList defaultFeatures) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback to notify the event of creation of proxy object for SEI endpoint. The
|
||||
* callback could set some properties on the {@link BindingProvider}.
|
||||
*
|
||||
* @param bp created proxy instance
|
||||
* @param serviceEndpointInterface SEI of the endpoint
|
||||
*/
|
||||
public void postCreateProxy(@NotNull WSBindingProvider bp,@NotNull Class<?> serviceEndpointInterface) {
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback to notify that a {@link Dispatch} object is created. The callback
|
||||
* could set some properties on the {@link BindingProvider}.
|
||||
*
|
||||
* @param bp BindingProvider of dispatch object
|
||||
*/
|
||||
public void postCreateDispatch(@NotNull WSBindingProvider bp) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggregates multiple interceptors into one facade.
|
||||
*/
|
||||
public static ServiceInterceptor aggregate(final ServiceInterceptor... interceptors) {
|
||||
if(interceptors.length==1)
|
||||
return interceptors[0];
|
||||
return new ServiceInterceptor() {
|
||||
public List<WebServiceFeature> preCreateBinding(@NotNull WSPortInfo port, @Nullable Class<?> portInterface, @NotNull WSFeatureList defaultFeatures) {
|
||||
List<WebServiceFeature> r = new ArrayList<WebServiceFeature>();
|
||||
for (ServiceInterceptor si : interceptors)
|
||||
r.addAll(si.preCreateBinding(port,portInterface,defaultFeatures));
|
||||
return r;
|
||||
}
|
||||
|
||||
public void postCreateProxy(@NotNull WSBindingProvider bp, @NotNull Class<?> serviceEndpointInterface) {
|
||||
for (ServiceInterceptor si : interceptors)
|
||||
si.postCreateProxy(bp,serviceEndpointInterface);
|
||||
}
|
||||
|
||||
public void postCreateDispatch(@NotNull WSBindingProvider bp) {
|
||||
for (ServiceInterceptor si : interceptors)
|
||||
si.postCreateDispatch(bp);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.client;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.WSService;
|
||||
import com.sun.xml.internal.ws.util.ServiceFinder;
|
||||
|
||||
import javax.xml.ws.Service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Creates {@link ServiceInterceptor}.
|
||||
*
|
||||
* <p>
|
||||
* Code that wishes to inject {@link ServiceInterceptor} into {@link WSService}
|
||||
* must implement this class. There are two ways to have the JAX-WS RI
|
||||
* recognize your {@link ServiceInterceptor}s.
|
||||
*
|
||||
* <h3>Use {@link ServiceFinder}</h3>
|
||||
* <p>
|
||||
* {@link ServiceInterceptorFactory}s discovered via {@link ServiceFinder}
|
||||
* will be incorporated to all {@link WSService} instances.
|
||||
*
|
||||
* <h3>Register per-thread</h3>
|
||||
*
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @see ServiceInterceptor
|
||||
* @see 2.1 EA3
|
||||
*/
|
||||
public abstract class ServiceInterceptorFactory {
|
||||
public abstract ServiceInterceptor create(@NotNull WSService service);
|
||||
|
||||
/**
|
||||
* Loads all {@link ServiceInterceptor}s and return aggregated one.
|
||||
*/
|
||||
public static @NotNull ServiceInterceptor load(@NotNull WSService service, @Nullable ClassLoader cl) {
|
||||
List<ServiceInterceptor> l = new ArrayList<ServiceInterceptor>();
|
||||
|
||||
// first service look-up
|
||||
for( ServiceInterceptorFactory f : ServiceFinder.find(ServiceInterceptorFactory.class))
|
||||
l.add(f.create(service));
|
||||
|
||||
// then thread-local
|
||||
for( ServiceInterceptorFactory f : threadLocalFactories.get())
|
||||
l.add(f.create(service));
|
||||
|
||||
return ServiceInterceptor.aggregate(l.toArray(new ServiceInterceptor[l.size()]));
|
||||
}
|
||||
|
||||
private static ThreadLocal<Set<ServiceInterceptorFactory>> threadLocalFactories = new ThreadLocal<Set<ServiceInterceptorFactory>>() {
|
||||
protected Set<ServiceInterceptorFactory> initialValue() {
|
||||
return new HashSet<ServiceInterceptorFactory>();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers {@link ServiceInterceptorFactory} for this thread.
|
||||
*
|
||||
* <p>
|
||||
* Once registered, {@link ServiceInterceptorFactory}s are consulted for every
|
||||
* {@link Service} created in this thread, until it gets unregistered.
|
||||
*/
|
||||
public static boolean registerForThread(ServiceInterceptorFactory factory) {
|
||||
return threadLocalFactories.get().add(factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes previously registered {@link ServiceInterceptorFactory} for this thread.
|
||||
*/
|
||||
public static boolean unregisterForThread(ServiceInterceptorFactory factory) {
|
||||
return threadLocalFactories.get().remove(factory);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.client;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.Dispatch;
|
||||
|
||||
import com.sun.xml.internal.ws.api.pipe.ThrowableContainerPropertySet;
|
||||
|
||||
/**
|
||||
* When using {@link Dispatch}<{@link Packet}> and the invocation completes with a Throwable, it is
|
||||
* useful to be able to inspect the Packet in addition to the Throwable as the Packet contains
|
||||
* meta-data about the request and/or response. However, the default behavior is that the caller
|
||||
* only receives the Throwable.
|
||||
*
|
||||
* When an instance of this feature is enabled on the binding, any Throwable generated will be available
|
||||
* on the Packet on the satellite {@link ThrowableContainerPropertySet}.
|
||||
*
|
||||
* @see ThrowableContainerPropertySet
|
||||
*/
|
||||
public class ThrowableInPacketCompletionFeature extends WebServiceFeature {
|
||||
|
||||
public ThrowableInPacketCompletionFeature() {
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return ThrowableInPacketCompletionFeature.class.getName();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.client;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.BindingID;
|
||||
import com.sun.xml.internal.ws.api.EndpointAddress;
|
||||
import com.sun.xml.internal.ws.api.WSService;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.policy.PolicyMap;
|
||||
|
||||
import javax.xml.ws.handler.PortInfo;
|
||||
|
||||
/**
|
||||
* JAX-WS RI's extension to {@link PortInfo}.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public interface WSPortInfo extends PortInfo {
|
||||
/**
|
||||
* Returns {@link WSService} object that owns this port.
|
||||
*/
|
||||
@NotNull WSService getOwner();
|
||||
|
||||
/**
|
||||
* Returns the same information as {@link #getBindingID()}
|
||||
* but in a strongly-typed fashion
|
||||
*/
|
||||
@NotNull BindingID getBindingId();
|
||||
|
||||
/**
|
||||
* Gets the endpoint address of this port.
|
||||
*/
|
||||
@NotNull EndpointAddress getEndpointAddress();
|
||||
|
||||
/**
|
||||
* Gets the {@link WSDLPort} object that represents this port,
|
||||
* if {@link WSService} is configured with WSDL. Otherwise null.
|
||||
*/
|
||||
@Nullable WSDLPort getPort();
|
||||
|
||||
/**
|
||||
* Gives the PolicMap that captures the Policy for the PortInfo
|
||||
*
|
||||
* @return PolicyMap
|
||||
*
|
||||
* @deprecated
|
||||
* Do not use this method as the PolicyMap API is not final yet and might change in next few months.
|
||||
*/
|
||||
|
||||
public PolicyMap getPolicyMap();
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.config.management;
|
||||
|
||||
import com.sun.xml.internal.ws.api.server.Invoker;
|
||||
|
||||
import org.xml.sax.EntityResolver;
|
||||
|
||||
/**
|
||||
* Store the parameters that were passed into the original WSEndpoint instance
|
||||
* upon creation. This allows us to instantiate a new instance with the same
|
||||
* parameters.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public class EndpointCreationAttributes {
|
||||
|
||||
private final boolean processHandlerAnnotation;
|
||||
private final Invoker invoker;
|
||||
private final EntityResolver entityResolver;
|
||||
private final boolean isTransportSynchronous;
|
||||
|
||||
/**
|
||||
* Instantiate this data access object.
|
||||
*
|
||||
* @param processHandlerAnnotation The original processHandlerAnnotation setting.
|
||||
* @param invoker The original Invoker instance.
|
||||
* @param resolver The original EntityResolver instance.
|
||||
* @param isTransportSynchronous The original isTransportSynchronous setting.
|
||||
*/
|
||||
public EndpointCreationAttributes(final boolean processHandlerAnnotation,
|
||||
final Invoker invoker,
|
||||
final EntityResolver resolver,
|
||||
final boolean isTransportSynchronous) {
|
||||
this.processHandlerAnnotation = processHandlerAnnotation;
|
||||
this.invoker = invoker;
|
||||
this.entityResolver = resolver;
|
||||
this.isTransportSynchronous = isTransportSynchronous;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original processHandlerAnnotation setting.
|
||||
*
|
||||
* @return The original processHandlerAnnotation setting.
|
||||
*/
|
||||
public boolean isProcessHandlerAnnotation() {
|
||||
return this.processHandlerAnnotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original Invoker instance.
|
||||
*
|
||||
* @return The original Invoker instance.
|
||||
*/
|
||||
public Invoker getInvoker() {
|
||||
return this.invoker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original EntityResolver instance.
|
||||
*
|
||||
* @return The original EntityResolver instance.
|
||||
*/
|
||||
public EntityResolver getEntityResolver() {
|
||||
return this.entityResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original isTransportSynchronous setting.
|
||||
*
|
||||
* @return The original isTransportSynchronous setting.
|
||||
*/
|
||||
public boolean isTransportSynchronous() {
|
||||
return this.isTransportSynchronous;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.config.management;
|
||||
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
|
||||
/**
|
||||
* Interface to create a new WSEndpoint wrapper. This is intended to be implemented
|
||||
* by the configuration management to return a ManagedEndpoint that wraps the
|
||||
* original WSEndpoint instance.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public interface ManagedEndpointFactory {
|
||||
|
||||
/**
|
||||
* This method may return a WSEndpoint implementation that wraps the original
|
||||
* WSEndpoint instance. This allows to interject e.g. management code. If
|
||||
* management has not been enabled for this endpoint, it will return the original
|
||||
* WSEndpoint instance.
|
||||
*
|
||||
* @param <T> The endpoint implementation type.
|
||||
* @param endpoint The endpoint instance.
|
||||
* @param attributes The parameters with which the original endpoint instance
|
||||
* was created.
|
||||
* @return A WSEndpoint that wraps the original WSEndpoint instance or the
|
||||
* original WSEndpoint instance.
|
||||
*/
|
||||
public <T> WSEndpoint<T> createEndpoint(WSEndpoint<T> endpoint, EndpointCreationAttributes attributes);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.config.management;
|
||||
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* Allows to trigger a reconfiguration action on an object.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public interface Reconfigurable {
|
||||
|
||||
/**
|
||||
* Executes any action when an endpoint is reconfigured.
|
||||
*
|
||||
* @throws WebServiceException Thrown if the reconfiguration failed.
|
||||
*/
|
||||
void reconfigure() throws WebServiceException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.config.management.policy;
|
||||
|
||||
import com.sun.istack.internal.logging.Logger;
|
||||
import com.sun.xml.internal.ws.api.client.WSPortInfo;
|
||||
import com.sun.xml.internal.ws.policy.PolicyAssertion;
|
||||
import com.sun.xml.internal.ws.policy.PolicyMap;
|
||||
import com.sun.xml.internal.ws.policy.PolicyConstants;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.AssertionData;
|
||||
import com.sun.xml.internal.ws.policy.spi.AssertionCreationException;
|
||||
import com.sun.xml.internal.ws.resources.ManagementMessages;
|
||||
|
||||
import java.util.Collection;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* The client-side ManagedClient policy assertion.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public class ManagedClientAssertion extends ManagementAssertion {
|
||||
|
||||
public static final QName MANAGED_CLIENT_QNAME =
|
||||
new QName(PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "ManagedClient");
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ManagedClientAssertion.class);
|
||||
|
||||
/**
|
||||
* Return ManagedClient assertion if there is one associated with the client.
|
||||
*
|
||||
* @param portInfo The client PortInfo.
|
||||
* @return The policy assertion if found. Null otherwise.
|
||||
* @throws WebServiceException If computing the effective policy of the port failed.
|
||||
*/
|
||||
public static ManagedClientAssertion getAssertion(WSPortInfo portInfo) throws WebServiceException {
|
||||
if (portInfo == null)
|
||||
return null;
|
||||
|
||||
LOGGER.entering(portInfo);
|
||||
// getPolicyMap is deprecated because it is only supposed to be used by Metro code
|
||||
// and not by other clients.
|
||||
@SuppressWarnings("deprecation")
|
||||
final PolicyMap policyMap = portInfo.getPolicyMap();
|
||||
final ManagedClientAssertion assertion = ManagementAssertion.getAssertion(MANAGED_CLIENT_QNAME,
|
||||
policyMap, portInfo.getServiceName(), portInfo.getPortName(), ManagedClientAssertion.class);
|
||||
LOGGER.exiting(assertion);
|
||||
return assertion;
|
||||
}
|
||||
|
||||
public ManagedClientAssertion(AssertionData data, Collection<PolicyAssertion> assertionParameters)
|
||||
throws AssertionCreationException {
|
||||
super(MANAGED_CLIENT_QNAME, data, assertionParameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clients cannot be managed.
|
||||
*
|
||||
* @return False.
|
||||
*/
|
||||
public boolean isManagementEnabled() {
|
||||
final String management = this.getAttributeValue(MANAGEMENT_ATTRIBUTE_QNAME);
|
||||
if (management != null) {
|
||||
if (management.trim().toLowerCase().equals("on") || Boolean.parseBoolean(management)) {
|
||||
LOGGER.warning(ManagementMessages.WSM_1006_CLIENT_MANAGEMENT_ENABLED());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,391 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.config.management.policy;
|
||||
|
||||
import com.sun.istack.internal.logging.Logger;
|
||||
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
||||
import com.sun.xml.internal.ws.policy.PolicyAssertion;
|
||||
import com.sun.xml.internal.ws.policy.PolicyMap;
|
||||
import com.sun.xml.internal.ws.policy.PolicyConstants;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.AssertionData;
|
||||
import com.sun.xml.internal.ws.policy.spi.AssertionCreationException;
|
||||
import com.sun.xml.internal.ws.resources.ManagementMessages;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* The server-side ManagedService policy assertion.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public class ManagedServiceAssertion extends ManagementAssertion {
|
||||
|
||||
public static final QName MANAGED_SERVICE_QNAME =
|
||||
new QName(PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "ManagedService");
|
||||
|
||||
private static final QName COMMUNICATION_SERVER_IMPLEMENTATIONS_PARAMETER_QNAME = new QName(
|
||||
PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "CommunicationServerImplementations");
|
||||
private static final QName COMMUNICATION_SERVER_IMPLEMENTATION_PARAMETER_QNAME = new QName(
|
||||
PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "CommunicationServerImplementation");
|
||||
private static final QName CONFIGURATOR_IMPLEMENTATION_PARAMETER_QNAME = new QName(
|
||||
PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "ConfiguratorImplementation");
|
||||
private static final QName CONFIG_SAVER_IMPLEMENTATION_PARAMETER_QNAME = new QName(
|
||||
PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "ConfigSaverImplementation");
|
||||
private static final QName CONFIG_READER_IMPLEMENTATION_PARAMETER_QNAME = new QName(
|
||||
PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "ConfigReaderImplementation");
|
||||
private static final QName CLASS_NAME_ATTRIBUTE_QNAME = new QName("className");
|
||||
/**
|
||||
* The name of the endpointDisposeDelay attribute.
|
||||
*/
|
||||
private static final QName ENDPOINT_DISPOSE_DELAY_ATTRIBUTE_QNAME = new QName("endpointDisposeDelay");
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ManagedServiceAssertion.class);
|
||||
|
||||
/**
|
||||
* Return ManagedService assertion if there is one associated with the endpoint.
|
||||
*
|
||||
* @param endpoint The endpoint. Must not be null.
|
||||
* @return The policy assertion if found. Null otherwise.
|
||||
* @throws WebServiceException If computing the effective policy of the endpoint failed.
|
||||
*/
|
||||
public static ManagedServiceAssertion getAssertion(WSEndpoint endpoint) throws WebServiceException {
|
||||
LOGGER.entering(endpoint);
|
||||
// getPolicyMap is deprecated because it is only supposed to be used by Metro code
|
||||
// and not by other clients.
|
||||
@SuppressWarnings("deprecation")
|
||||
final PolicyMap policyMap = endpoint.getPolicyMap();
|
||||
final ManagedServiceAssertion assertion = ManagementAssertion.getAssertion(MANAGED_SERVICE_QNAME,
|
||||
policyMap, endpoint.getServiceName(), endpoint.getPortName(), ManagedServiceAssertion.class);
|
||||
LOGGER.exiting(assertion);
|
||||
return assertion;
|
||||
}
|
||||
|
||||
public ManagedServiceAssertion(AssertionData data, Collection<PolicyAssertion> assertionParameters)
|
||||
throws AssertionCreationException {
|
||||
super(MANAGED_SERVICE_QNAME, data, assertionParameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the management attribute. True if unset or set to "true"
|
||||
* or "on". False otherwise.
|
||||
*
|
||||
* @return The value of the management attribute.
|
||||
*/
|
||||
public boolean isManagementEnabled() {
|
||||
final String management = this.getAttributeValue(MANAGEMENT_ATTRIBUTE_QNAME);
|
||||
boolean result = true;
|
||||
if (management != null) {
|
||||
if (management.trim().toLowerCase().equals("on")) {
|
||||
result = true;
|
||||
}
|
||||
else {
|
||||
result = Boolean.parseBoolean(management);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the endpointDisposeDelay attribute or the default value
|
||||
* otherwise.
|
||||
*
|
||||
* @param defaultDelay The default value that is returned if this attribute is
|
||||
* not set
|
||||
* @return The value of the endpointDisposeDelay attribute or the default value
|
||||
* otherwise.
|
||||
*/
|
||||
public long getEndpointDisposeDelay(final long defaultDelay) throws WebServiceException {
|
||||
long result = defaultDelay;
|
||||
final String delayText = getAttributeValue(ENDPOINT_DISPOSE_DELAY_ATTRIBUTE_QNAME);
|
||||
if (delayText != null) {
|
||||
try {
|
||||
result = Long.parseLong(delayText);
|
||||
} catch (NumberFormatException e) {
|
||||
throw LOGGER.logSevereException(new WebServiceException(
|
||||
ManagementMessages.WSM_1008_EXPECTED_INTEGER_DISPOSE_DELAY_VALUE(delayText), e));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of CommunicationServerImplementation elements that were set as
|
||||
* parameters of this assertion.
|
||||
*
|
||||
* @return A list of CommunicationServerImplementation elements that were set as
|
||||
* parameters of this assertion. May be empty.
|
||||
*/
|
||||
public Collection<ImplementationRecord> getCommunicationServerImplementations() {
|
||||
final Collection<ImplementationRecord> result = new LinkedList<ImplementationRecord>();
|
||||
final Iterator<PolicyAssertion> parameters = getParametersIterator();
|
||||
while (parameters.hasNext()) {
|
||||
final PolicyAssertion parameter = parameters.next();
|
||||
if (COMMUNICATION_SERVER_IMPLEMENTATIONS_PARAMETER_QNAME.equals(parameter.getName())) {
|
||||
final Iterator<PolicyAssertion> implementations = parameter.getParametersIterator();
|
||||
if (!implementations.hasNext()) {
|
||||
throw LOGGER.logSevereException(new WebServiceException(
|
||||
ManagementMessages.WSM_1005_EXPECTED_COMMUNICATION_CHILD()));
|
||||
}
|
||||
while (implementations.hasNext()) {
|
||||
final PolicyAssertion implementation = implementations.next();
|
||||
if (COMMUNICATION_SERVER_IMPLEMENTATION_PARAMETER_QNAME.equals(implementation.getName())) {
|
||||
result.add(getImplementation(implementation));
|
||||
}
|
||||
else {
|
||||
throw LOGGER.logSevereException(new WebServiceException(
|
||||
ManagementMessages.WSM_1004_EXPECTED_XML_TAG(
|
||||
COMMUNICATION_SERVER_IMPLEMENTATION_PARAMETER_QNAME, implementation.getName())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ConfiguratorImplementation that was set as parameter of this assertion.
|
||||
*
|
||||
* @return The ConfiguratorImplementation that was set as parameter of this assertion.
|
||||
* May be null.
|
||||
*/
|
||||
public ImplementationRecord getConfiguratorImplementation() {
|
||||
return findImplementation(CONFIGURATOR_IMPLEMENTATION_PARAMETER_QNAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ConfigSaverImplementation that was set as parameter of this assertion.
|
||||
*
|
||||
* @return The ConfigSaverImplementation that was set as parameter of this assertion.
|
||||
* May be null.
|
||||
*/
|
||||
public ImplementationRecord getConfigSaverImplementation() {
|
||||
return findImplementation(CONFIG_SAVER_IMPLEMENTATION_PARAMETER_QNAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ConfigReaderImplementation that was set as parameter of this assertion.
|
||||
*
|
||||
* @return The ConfigReaderImplementation that was set as parameter of this assertion.
|
||||
* May be null.
|
||||
*/
|
||||
public ImplementationRecord getConfigReaderImplementation() {
|
||||
return findImplementation(CONFIG_READER_IMPLEMENTATION_PARAMETER_QNAME);
|
||||
}
|
||||
|
||||
private ImplementationRecord findImplementation(QName implementationName) {
|
||||
final Iterator<PolicyAssertion> parameters = getParametersIterator();
|
||||
while (parameters.hasNext()) {
|
||||
final PolicyAssertion parameter = parameters.next();
|
||||
if (implementationName.equals(parameter.getName())) {
|
||||
return getImplementation(parameter);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private ImplementationRecord getImplementation(PolicyAssertion rootParameter) {
|
||||
final String className = rootParameter.getAttributeValue(CLASS_NAME_ATTRIBUTE_QNAME);
|
||||
final HashMap<QName, String> parameterMap = new HashMap<QName, String>();
|
||||
final Iterator<PolicyAssertion> implementationParameters = rootParameter.getParametersIterator();
|
||||
final Collection<NestedParameters> nestedParameters = new LinkedList<NestedParameters>();
|
||||
while (implementationParameters.hasNext()) {
|
||||
final PolicyAssertion parameterAssertion = implementationParameters.next();
|
||||
final QName parameterName = parameterAssertion.getName();
|
||||
if (parameterAssertion.hasParameters()) {
|
||||
final Map<QName, String> nestedParameterMap = new HashMap<QName, String>();
|
||||
final Iterator<PolicyAssertion> parameters = parameterAssertion.getParametersIterator();
|
||||
while (parameters.hasNext()) {
|
||||
final PolicyAssertion parameter = parameters.next();
|
||||
String value = parameter.getValue();
|
||||
if (value != null) {
|
||||
value = value.trim();
|
||||
}
|
||||
nestedParameterMap.put(parameter.getName(), value);
|
||||
}
|
||||
nestedParameters.add(new NestedParameters(parameterName, nestedParameterMap));
|
||||
}
|
||||
else {
|
||||
String value = parameterAssertion.getValue();
|
||||
if (value != null) {
|
||||
value = value.trim();
|
||||
}
|
||||
parameterMap.put(parameterName, value);
|
||||
}
|
||||
}
|
||||
return new ImplementationRecord(className, parameterMap, nestedParameters);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the implementation class name along with all parameters for the
|
||||
* implementation.
|
||||
*/
|
||||
public static class ImplementationRecord {
|
||||
|
||||
private final String implementation;
|
||||
private final Map<QName, String> parameters;
|
||||
private final Collection<NestedParameters> nestedParameters;
|
||||
|
||||
protected ImplementationRecord(String implementation, Map<QName, String> parameters,
|
||||
Collection<NestedParameters> nestedParameters) {
|
||||
this.implementation = implementation;
|
||||
this.parameters = parameters;
|
||||
this.nestedParameters = nestedParameters;
|
||||
}
|
||||
|
||||
public String getImplementation() {
|
||||
return this.implementation;
|
||||
}
|
||||
|
||||
/**
|
||||
* The parameters that were set for this implementation element.
|
||||
*
|
||||
* @return The parameters that were set for this implementation element.
|
||||
* May be null.
|
||||
*/
|
||||
public Map<QName, String> getParameters() {
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation elements may contain element parameters that contain
|
||||
* further parameters.
|
||||
*
|
||||
* @return The nested parameters that were set for this implementation element.
|
||||
* May be null.
|
||||
*/
|
||||
public Collection<NestedParameters> getNestedParameters() {
|
||||
return this.nestedParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final ImplementationRecord other = (ImplementationRecord) obj;
|
||||
if ((this.implementation == null) ?
|
||||
(other.implementation != null) : !this.implementation.equals(other.implementation)) {
|
||||
return false;
|
||||
}
|
||||
if (this.parameters != other.parameters && (this.parameters == null || !this.parameters.equals(other.parameters))) {
|
||||
return false;
|
||||
}
|
||||
if (this.nestedParameters != other.nestedParameters &&
|
||||
(this.nestedParameters == null || !this.nestedParameters.equals(other.nestedParameters))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 53 * hash + (this.implementation != null ? this.implementation.hashCode() : 0);
|
||||
hash = 53 * hash + (this.parameters != null ? this.parameters.hashCode() : 0);
|
||||
hash = 53 * hash + (this.nestedParameters != null ? this.nestedParameters.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder text = new StringBuilder("ImplementationRecord: ");
|
||||
text.append("implementation = \"").append(this.implementation).append("\", ");
|
||||
text.append("parameters = \"").append(this.parameters).append("\", ");
|
||||
text.append("nested parameters = \"").append(this.nestedParameters).append("\"");
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The nested parameters that may be set as part of an implementation element.
|
||||
*/
|
||||
public static class NestedParameters {
|
||||
|
||||
private final QName name;
|
||||
private final Map<QName, String> parameters;
|
||||
|
||||
private NestedParameters(QName name, Map<QName, String> parameters) {
|
||||
this.name = name;
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public QName getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Map<QName, String> getParameters() {
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final NestedParameters other = (NestedParameters) obj;
|
||||
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
|
||||
return false;
|
||||
}
|
||||
if (this.parameters != other.parameters && (this.parameters == null || !this.parameters.equals(other.parameters))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0);
|
||||
hash = 59 * hash + (this.parameters != null ? this.parameters.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder text = new StringBuilder("NestedParameters: ");
|
||||
text.append("name = \"").append(this.name).append("\", ");
|
||||
text.append("parameters = \"").append(this.parameters).append("\"");
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.config.management.policy;
|
||||
|
||||
import com.sun.istack.internal.logging.Logger;
|
||||
import com.sun.xml.internal.ws.policy.AssertionSet;
|
||||
import com.sun.xml.internal.ws.policy.Policy;
|
||||
import com.sun.xml.internal.ws.policy.PolicyAssertion;
|
||||
import com.sun.xml.internal.ws.policy.PolicyException;
|
||||
import com.sun.xml.internal.ws.policy.PolicyMap;
|
||||
import com.sun.xml.internal.ws.policy.PolicyMapKey;
|
||||
import com.sun.xml.internal.ws.policy.SimpleAssertion;
|
||||
import com.sun.xml.internal.ws.policy.sourcemodel.AssertionData;
|
||||
import com.sun.xml.internal.ws.policy.spi.AssertionCreationException;
|
||||
import com.sun.xml.internal.ws.resources.ManagementMessages;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
/**
|
||||
* Base class for the #ManagedClientAssertion and #ManagedServiceAssertion. Provides
|
||||
* convenience methods to directly access the policy assertion parameters.
|
||||
*
|
||||
* @author Fabian Ritzmann
|
||||
*/
|
||||
public abstract class ManagementAssertion extends SimpleAssertion {
|
||||
|
||||
/**
|
||||
* To be able to distinguish between explicit settings and no setting.
|
||||
*/
|
||||
public static enum Setting { NOT_SET, OFF, ON }
|
||||
|
||||
/**
|
||||
* The name of the management attribute.
|
||||
*/
|
||||
protected static final QName MANAGEMENT_ATTRIBUTE_QNAME = new QName("management");
|
||||
/**
|
||||
* The name of the monitoring attribute.
|
||||
*/
|
||||
protected static final QName MONITORING_ATTRIBUTE_QNAME = new QName("monitoring");
|
||||
|
||||
/**
|
||||
* The name of the id attribute.
|
||||
*/
|
||||
private static final QName ID_ATTRIBUTE_QNAME = new QName("id");
|
||||
/**
|
||||
* The name of the start attribute.
|
||||
*/
|
||||
private static final QName START_ATTRIBUTE_QNAME = new QName("start");
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ManagementAssertion.class);
|
||||
|
||||
/**
|
||||
* Return ManagementAssertion if one can be found in the policy map under
|
||||
* the given service and port name.
|
||||
*
|
||||
* @param <T> The implementation class of the assertion.
|
||||
* @param name The fully qualified name of the server or client assertion.
|
||||
* @param policyMap The policy map. May be null.
|
||||
* @param serviceName The WSDL service name. May not be null.
|
||||
* @param portName The WSDL port name. May not be null.
|
||||
* @param type The implementation class of the assertion.
|
||||
* @return An instance of ManagementAssertion or null.
|
||||
* @throws WebServiceException If computing the effective policy of the endpoint scope failed.
|
||||
*/
|
||||
protected static <T extends ManagementAssertion> T getAssertion(final QName name,
|
||||
final PolicyMap policyMap, QName serviceName, QName portName, Class<T> type)
|
||||
throws WebServiceException {
|
||||
try {
|
||||
PolicyAssertion assertion = null;
|
||||
if (policyMap != null) {
|
||||
final PolicyMapKey key = PolicyMap.createWsdlEndpointScopeKey(serviceName, portName);
|
||||
final Policy policy = policyMap.getEndpointEffectivePolicy(key);
|
||||
if (policy != null) {
|
||||
final Iterator<AssertionSet> assertionSets = policy.iterator();
|
||||
if (assertionSets.hasNext()) {
|
||||
final AssertionSet assertionSet = assertionSets.next();
|
||||
final Iterator<PolicyAssertion> assertions = assertionSet.get(name).iterator();
|
||||
if (assertions.hasNext()) {
|
||||
assertion = assertions.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return assertion == null ? null : assertion.getImplementation(type);
|
||||
} catch (PolicyException ex) {
|
||||
throw LOGGER.logSevereException(new WebServiceException(
|
||||
ManagementMessages.WSM_1001_FAILED_ASSERTION(name), ex));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ManagementAssertion instance.
|
||||
*
|
||||
* @param name The fully qualified name of the server or client assertion. Must
|
||||
* not be null.
|
||||
* @param data The assertion data. Must not be null.
|
||||
* @param assertionParameters Parameters of the assertion. May be null.
|
||||
* @throws AssertionCreationException Thrown if the creation of the assertion failed.
|
||||
*/
|
||||
protected ManagementAssertion(final QName name, AssertionData data, Collection<PolicyAssertion> assertionParameters)
|
||||
throws AssertionCreationException {
|
||||
super(data, assertionParameters);
|
||||
if (!name.equals(data.getName())) {
|
||||
throw LOGGER.logSevereException(new AssertionCreationException(data,
|
||||
ManagementMessages.WSM_1002_EXPECTED_MANAGEMENT_ASSERTION(name)));
|
||||
}
|
||||
if (isManagementEnabled() && !data.containsAttribute(ID_ATTRIBUTE_QNAME)) {
|
||||
throw LOGGER.logSevereException(new AssertionCreationException(data,
|
||||
ManagementMessages.WSM_1003_MANAGEMENT_ASSERTION_MISSING_ID(name)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the id attribute. May not be null.
|
||||
*
|
||||
* @return The value of the id attribute.
|
||||
*/
|
||||
public String getId() {
|
||||
return this.getAttributeValue((ID_ATTRIBUTE_QNAME));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the start attribute. May be null.
|
||||
*
|
||||
* @return The value of the start attribute.
|
||||
*/
|
||||
public String getStart() {
|
||||
return this.getAttributeValue((START_ATTRIBUTE_QNAME));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the managment attribute depending on whether this is
|
||||
* a client-side or server-side assertion.
|
||||
*
|
||||
* @return The value of the managment attribute.
|
||||
*/
|
||||
public abstract boolean isManagementEnabled();
|
||||
|
||||
/**
|
||||
* Returns the value of the monitoring attribute.
|
||||
*
|
||||
* @return The value of the monitoring attribute.
|
||||
*/
|
||||
public Setting monitoringAttribute() {
|
||||
final String monitoring = this.getAttributeValue(MONITORING_ATTRIBUTE_QNAME);
|
||||
Setting result = Setting.NOT_SET;
|
||||
if (monitoring != null) {
|
||||
if (monitoring.trim().toLowerCase().equals("on")
|
||||
|| Boolean.parseBoolean(monitoring)) {
|
||||
result = Setting.ON;
|
||||
}
|
||||
else {
|
||||
result = Setting.OFF;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.databinding;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import com.oracle.webservices.internal.api.databinding.JavaCallInfo;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.model.JavaMethod;
|
||||
|
||||
public interface ClientCallBridge {
|
||||
|
||||
Packet createRequestPacket(JavaCallInfo call);
|
||||
|
||||
JavaCallInfo readResponse(Packet packet, JavaCallInfo call) throws Throwable;
|
||||
|
||||
Method getMethod();
|
||||
|
||||
JavaMethod getOperationModel();
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.databinding;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import com.sun.xml.internal.ws.api.message.MessageContextFactory;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.pipe.ContentType;
|
||||
import com.sun.xml.internal.ws.wsdl.DispatchException;
|
||||
|
||||
/**
|
||||
* {@code Databinding} is the entry point for all the WebService databinding
|
||||
* runtime functionality. Primarily, a Databinding is to serialize/deserialize an
|
||||
* XML(SOAP) message to/from a JAVA method invocation and return value which
|
||||
* are represented as <code>JavaCallInfo</code> instances.
|
||||
* <p>
|
||||
* </p>
|
||||
* Each Databinding is associated with a <code>MessageFactory</code> instance
|
||||
* which can be used to create <code>Message</code> instances that can be
|
||||
* deserialized by the Databinding. The <code>MessageFactory</code> also supports
|
||||
* the conversion of Oracle Fabric Normalized messages.
|
||||
* <p>
|
||||
* </p>
|
||||
* <blockquote> Following is an example that creates a {@code Databinding} which
|
||||
* provides the operations to serialize/deserialize a JavaCallInfo to/from a
|
||||
* SOAP message:<br />
|
||||
*
|
||||
* <pre>
|
||||
* DatabindingFactory wsfac = DatabindingFactory();
|
||||
* Databinding rt = wsfac.createDatabinding(DatabindingConfig);
|
||||
* </pre>
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public interface Databinding extends com.oracle.webservices.internal.api.databinding.Databinding {
|
||||
|
||||
/**
|
||||
* Gets the MessageFactory instance associated with this WsRuntime
|
||||
*
|
||||
* @return the MessageFactory instance associated with this WsRuntime
|
||||
*/
|
||||
// MessageFactory getMessageFactory();
|
||||
|
||||
/**
|
||||
* Deserializes a request XML(SOAP) message to a JavaCallInfo instance
|
||||
* representing a JAVA method call.
|
||||
*
|
||||
* @param soap
|
||||
* the request message
|
||||
*
|
||||
* @return the JavaCallInfo representing a method call
|
||||
*/
|
||||
// JavaCallInfo deserializeRequest(Packet req);
|
||||
|
||||
EndpointCallBridge getEndpointBridge(Packet soap) throws DispatchException;
|
||||
|
||||
ClientCallBridge getClientBridge(Method method);
|
||||
|
||||
/**
|
||||
* Serializes a JavaCallInfo instance representing a JAVA method call to a
|
||||
* request XML(SOAP) message.
|
||||
*
|
||||
* @param call
|
||||
* the JavaCallInfo representing a method call
|
||||
*
|
||||
* @return the request XML(SOAP) message
|
||||
*/
|
||||
// Packet serializeRequest(JavaCallInfo call);
|
||||
|
||||
/**
|
||||
* Serializes a JavaCallInfo instance representing the return value or
|
||||
* exception of a JAVA method call to a response XML(SOAP) message.
|
||||
*
|
||||
* @param call
|
||||
* the JavaCallInfo representing the return value or exception of
|
||||
* a JAVA method call
|
||||
*
|
||||
* @return the response XML(SOAP) message
|
||||
*/
|
||||
// Packet serializeResponse(JavaCallInfo call);
|
||||
|
||||
/**
|
||||
* Deserializes a response XML(SOAP) message to a JavaCallInfo instance
|
||||
* representing the return value or exception of a JAVA method call.
|
||||
*
|
||||
* @param soap
|
||||
* the response message
|
||||
*
|
||||
* @param call
|
||||
* the JavaCallInfo instance to be updated
|
||||
*
|
||||
* @return the JavaCallInfo updated with the return value or exception of a
|
||||
* JAVA method call
|
||||
*/
|
||||
// JavaCallInfo deserializeResponse(Packet res, JavaCallInfo call);
|
||||
|
||||
/**
|
||||
* Gets the WSDL operation metadata of the specified JAVA method.
|
||||
*
|
||||
* @param method
|
||||
* the JAVA method
|
||||
* @return the operationMetadata
|
||||
*/
|
||||
// OperationMetadata getOperationMetadata(java.lang.reflect.Method method);
|
||||
|
||||
/**
|
||||
* Gets the WebServiceFeatures of this webservice endpoint.
|
||||
*
|
||||
* @return the features
|
||||
*/
|
||||
// WebServiceFeature[] getFeatures();
|
||||
|
||||
void generateWSDL(WSDLGenInfo info);
|
||||
|
||||
/**
|
||||
* @deprecated use MessageContextFactory
|
||||
*/
|
||||
public ContentType encode( Packet packet, OutputStream out ) throws IOException ;
|
||||
|
||||
/**
|
||||
* @deprecated use MessageContextFactory
|
||||
*/
|
||||
public void decode( InputStream in, String ct, Packet packet ) throws IOException;
|
||||
|
||||
public MessageContextFactory getMessageContextFactory();
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.databinding;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
import org.xml.sax.EntityResolver;
|
||||
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.WSFeatureList;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.binding.WebServiceFeatureList;
|
||||
|
||||
/**
|
||||
* DatabindingConfig contains the initial states for Databinding. After a Databinding
|
||||
* instance is created, all it's internal states should be considered
|
||||
* 'immutable' and therefore the operations on Databinding are thread-safe.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class DatabindingConfig {
|
||||
protected Class contractClass;
|
||||
protected Class endpointClass;
|
||||
protected Set<Class> additionalValueTypes = new HashSet<Class>();
|
||||
protected MappingInfo mappingInfo = new MappingInfo();
|
||||
protected URL wsdlURL;
|
||||
protected ClassLoader classLoader;
|
||||
protected Iterable<WebServiceFeature> features;
|
||||
protected WSBinding wsBinding;
|
||||
protected WSDLPort wsdlPort;
|
||||
protected MetadataReader metadataReader;
|
||||
protected Map<String, Object> properties = new HashMap<String, Object>();
|
||||
protected Source wsdlSource;
|
||||
protected EntityResolver entityResolver;
|
||||
|
||||
public Class getContractClass() {
|
||||
return contractClass;
|
||||
}
|
||||
public void setContractClass(Class contractClass) {
|
||||
this.contractClass = contractClass;
|
||||
}
|
||||
public Class getEndpointClass() {
|
||||
return endpointClass;
|
||||
}
|
||||
public void setEndpointClass(Class implBeanClass) {
|
||||
this.endpointClass = implBeanClass;
|
||||
}
|
||||
public MappingInfo getMappingInfo() {
|
||||
return mappingInfo;
|
||||
}
|
||||
public void setMappingInfo(MappingInfo mappingInfo) {
|
||||
this.mappingInfo = mappingInfo;
|
||||
}
|
||||
public URL getWsdlURL() {
|
||||
return wsdlURL;
|
||||
}
|
||||
public void setWsdlURL(URL wsdlURL) {
|
||||
this.wsdlURL = wsdlURL;
|
||||
}
|
||||
public ClassLoader getClassLoader() {
|
||||
return classLoader;
|
||||
}
|
||||
public void setClassLoader(ClassLoader classLoader) {
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
public Iterable<WebServiceFeature> getFeatures() {
|
||||
if (features == null && wsBinding != null) return wsBinding.getFeatures();
|
||||
return features;
|
||||
}
|
||||
public void setFeatures(WebServiceFeature[] features) {
|
||||
setFeatures(new WebServiceFeatureList(features));
|
||||
}
|
||||
public void setFeatures(Iterable<WebServiceFeature> features) {
|
||||
this.features = WebServiceFeatureList.toList(features);
|
||||
}
|
||||
public WSDLPort getWsdlPort() {
|
||||
return wsdlPort;
|
||||
}
|
||||
public void setWsdlPort(WSDLPort wsdlPort) {
|
||||
this.wsdlPort = wsdlPort;
|
||||
}
|
||||
public Set<Class> additionalValueTypes() {
|
||||
return additionalValueTypes;
|
||||
}
|
||||
public Map<String, Object> properties() {
|
||||
return properties;
|
||||
}
|
||||
public WSBinding getWSBinding() {
|
||||
return wsBinding;
|
||||
}
|
||||
public void setWSBinding(WSBinding wsBinding) {
|
||||
this.wsBinding = wsBinding;
|
||||
}
|
||||
public MetadataReader getMetadataReader() {
|
||||
return metadataReader;
|
||||
}
|
||||
public void setMetadataReader(MetadataReader reader) {
|
||||
this.metadataReader = reader;
|
||||
}
|
||||
|
||||
public Source getWsdlSource() {
|
||||
return wsdlSource;
|
||||
}
|
||||
public void setWsdlSource(Source wsdlSource) {
|
||||
this.wsdlSource = wsdlSource;
|
||||
}
|
||||
public EntityResolver getEntityResolver() {
|
||||
return entityResolver;
|
||||
}
|
||||
public void setEntityResolver(EntityResolver entityResolver) {
|
||||
this.entityResolver = entityResolver;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.databinding;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* WsFactory is the entry point of all the ws-databinding APIs. A WsFactory
|
||||
* instance can be used to create <code>WsTool</code>, <code>WsRuntime</code>,
|
||||
* <code>XsTool</code>, and <code>XsRuntime</code> instances.
|
||||
* <p>
|
||||
* </P>
|
||||
* <blockquote>
|
||||
* Following is an example that creates a {@code WsTool} which provides the
|
||||
* operations for "WSDL to JAVA" and "JAVA to WSDL":<br />
|
||||
* <pre>
|
||||
* WsFactory wsfac = WsFactory.newInstance();
|
||||
* WsTool tool = wsfac.createTool();
|
||||
* GenerationStatus status = tool.generateWsdl(javaToWsdkInfo);
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*
|
||||
* <blockquote>
|
||||
* Following is an example that creates a {@code WsRuntime} which provides the
|
||||
* operations to serialize/deserialize a JavaCallInfo to/from a SOAP message:<br />
|
||||
* <pre>
|
||||
* WsFactory wsfac = WsFactory.newInstance();
|
||||
* WsRuntime rt = wsfac.createRuntime(wsRuntimeConfig);
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*
|
||||
* @see com.sun.xml.internal.ws.api.databinding.Databinding
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public abstract class DatabindingFactory extends com.oracle.webservices.internal.api.databinding.DatabindingFactory {
|
||||
|
||||
/**
|
||||
* Creates a new instance of a <code>WsTool</code>.
|
||||
*
|
||||
* @return New instance of a <code>WsTool</code>
|
||||
*/
|
||||
// abstract public WsTool createTool();
|
||||
|
||||
/**
|
||||
* Creates a new instance of a <code>WsRuntime</code> which is initialized
|
||||
* with the specified configuration object.
|
||||
*
|
||||
* @param config
|
||||
* the EndpointRuntimeConfig to init this WsRuntime
|
||||
* @return New instance of a <code>WsRuntime</code>
|
||||
*/
|
||||
abstract public com.oracle.webservices.internal.api.databinding.Databinding createRuntime(DatabindingConfig config);
|
||||
|
||||
/**
|
||||
* Creates a new instance of a <code>XsTool</code>.
|
||||
*
|
||||
* @return New instance of a <code>XsTool</code>
|
||||
*/
|
||||
// abstract public XsTool createXsTool(String mode);
|
||||
|
||||
/**
|
||||
* Creates a new instance of a <code>XsRuntime</code>.
|
||||
*
|
||||
* @return New instance of a <code>XsRuntime</code>
|
||||
*/
|
||||
// abstract public XsRuntime createXsRuntime(String mode);
|
||||
|
||||
/**
|
||||
* Access properties on the <code>WsFactory</code> instance.
|
||||
*
|
||||
* @return properties of this WsFactory
|
||||
*/
|
||||
abstract public Map<String, Object> properties();
|
||||
|
||||
/**
|
||||
* The default implementation class name.
|
||||
*/
|
||||
static final String ImplClass = com.sun.xml.internal.ws.db.DatabindingFactoryImpl.class.getName();
|
||||
|
||||
/**
|
||||
* Create a new instance of a <code>WsFactory</code>. This static method
|
||||
* creates a new factory instance.
|
||||
*
|
||||
* Once an application has obtained a reference to a <code>WsFactory</code>
|
||||
* it can use the factory to configure and obtain <code>WsTool</code> and
|
||||
* <code>WsRuntime</code> instances.
|
||||
*
|
||||
* @return New instance of a <code>WsFactory</code>
|
||||
*/
|
||||
static public DatabindingFactory newInstance() {
|
||||
try {
|
||||
Class<?> cls = Class.forName(ImplClass);
|
||||
return (DatabindingFactory) cls.newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.databinding;
|
||||
|
||||
import com.oracle.webservices.internal.api.databinding.JavaCallInfo;
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
import com.sun.xml.internal.ws.api.model.JavaMethod;
|
||||
|
||||
public interface EndpointCallBridge {
|
||||
|
||||
public JavaCallInfo deserializeRequest(Packet req);
|
||||
|
||||
//Change the return type to??
|
||||
public Packet serializeResponse(JavaCallInfo call);
|
||||
|
||||
JavaMethod getOperationModel();
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.databinding;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* On the client or service-requestor side, a JavaCallInfo object represents a
|
||||
* method call on the service proxy to be serialized as a SOAP request message
|
||||
* to be sent to the service. A SOAP response message returned to the service
|
||||
* client is deserialized as an update to the JavaCallInfo object which is used
|
||||
* to generated the request.
|
||||
* <p>
|
||||
* </p>
|
||||
* On the server or service provider side, a SOAP request message is
|
||||
* deserialized to a JavaCallInfo object which can be used to determine which
|
||||
* method to call, and get the parameter values to call the back-end service
|
||||
* implementation object. The return value or exception returned from the
|
||||
* service implementation should be set to the JavaCallInfo object which then
|
||||
* can be used to serialize to a A SOAP response or fault message to be sent
|
||||
* back to the service client.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class JavaCallInfo implements com.oracle.webservices.internal.api.databinding.JavaCallInfo {
|
||||
|
||||
private Method method;
|
||||
private Object[] parameters;
|
||||
private Object returnValue;
|
||||
private Throwable exception;
|
||||
|
||||
public JavaCallInfo() {
|
||||
}
|
||||
|
||||
public JavaCallInfo(Method m, Object[] args) {
|
||||
method = m;
|
||||
parameters = args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the method of this JavaCallInfo
|
||||
*
|
||||
* @return the method
|
||||
*/
|
||||
public Method getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the method of this JavaCallInfo
|
||||
*
|
||||
* @param method
|
||||
* the method to set
|
||||
*/
|
||||
public void setMethod(Method method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameters of this JavaCallInfo
|
||||
*
|
||||
* @return the parameters
|
||||
*/
|
||||
public Object[] getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parameters of this JavaCallInfo
|
||||
*
|
||||
* @param parameters
|
||||
* the parameters to set
|
||||
*/
|
||||
public void setParameters(Object[] parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the returnValue of this JavaCallInfo
|
||||
*
|
||||
* @return the returnValue
|
||||
*/
|
||||
public Object getReturnValue() {
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the returnValue of this JavaCallInfo
|
||||
*
|
||||
* @param returnValue
|
||||
* the returnValue to set
|
||||
*/
|
||||
public void setReturnValue(Object returnValue) {
|
||||
this.returnValue = returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exception of this JavaCallInfo
|
||||
*
|
||||
* @return the exception
|
||||
*/
|
||||
public Throwable getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the exception of this JavaCallInfo
|
||||
*
|
||||
* @param exception
|
||||
* the exception to set
|
||||
*/
|
||||
public void setException(Throwable exception) {
|
||||
this.exception = exception;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.databinding;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import com.sun.xml.internal.ws.api.BindingID;
|
||||
|
||||
/**
|
||||
* A MappingInfo object is the collection of all the properties of the mapping
|
||||
* between a JAVA contract class (SEI) and it's corresponding WSDL artifacts
|
||||
* (wsdl:portType and wsdl:binding). A MappingInfo object can be used to provide
|
||||
* additional mapping metadata for WSDL generation and the runtime of WebService
|
||||
* databinding.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class MappingInfo {
|
||||
protected String targetNamespace;
|
||||
protected String databindingMode;
|
||||
protected SoapBodyStyle soapBodyStyle;
|
||||
protected BindingID bindingID;
|
||||
protected QName serviceName;
|
||||
protected QName portName;
|
||||
protected String defaultSchemaNamespaceSuffix;
|
||||
|
||||
public String getTargetNamespace() {
|
||||
return targetNamespace;
|
||||
}
|
||||
public void setTargetNamespace(String targetNamespace) {
|
||||
this.targetNamespace = targetNamespace;
|
||||
}
|
||||
public String getDatabindingMode() {
|
||||
return databindingMode;
|
||||
}
|
||||
public void setDatabindingMode(String databindingMode) {
|
||||
this.databindingMode = databindingMode;
|
||||
}
|
||||
public SoapBodyStyle getSoapBodyStyle() {
|
||||
return soapBodyStyle;
|
||||
}
|
||||
public void setSoapBodyStyle(SoapBodyStyle soapBodyStyle) {
|
||||
this.soapBodyStyle = soapBodyStyle;
|
||||
}
|
||||
public BindingID getBindingID() {
|
||||
return bindingID;
|
||||
}
|
||||
public void setBindingID(BindingID bindingID) {
|
||||
this.bindingID = bindingID;
|
||||
}
|
||||
public QName getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
public void setServiceName(QName serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
public QName getPortName() {
|
||||
return portName;
|
||||
}
|
||||
public void setPortName(QName portName) {
|
||||
this.portName = portName;
|
||||
}
|
||||
public String getDefaultSchemaNamespaceSuffix() {
|
||||
return defaultSchemaNamespaceSuffix;
|
||||
}
|
||||
public void setDefaultSchemaNamespaceSuffix(String defaultSchemaNamespaceSuffix) {
|
||||
this.defaultSchemaNamespaceSuffix = defaultSchemaNamespaceSuffix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.databinding;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* MetadataReader
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public interface MetadataReader {
|
||||
|
||||
public Annotation[] getAnnotations(Method m) ;
|
||||
|
||||
public Annotation[][] getParameterAnnotations(final Method method);
|
||||
|
||||
public <A extends Annotation> A getAnnotation(final Class<A> annType, final Method m);
|
||||
|
||||
public <A extends Annotation> A getAnnotation(final Class<A> annType, final Class<?> cls);
|
||||
|
||||
public Annotation[] getAnnotations(Class<?> c);
|
||||
|
||||
public void getProperties(final Map<String, Object> prop, final Class<?> cls);
|
||||
|
||||
public void getProperties(final Map<String, Object> prop, final Method method);
|
||||
|
||||
public void getProperties(final Map<String, Object> prop, final Method method, int pos);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.databinding;
|
||||
|
||||
/**
|
||||
* The SoapBodyStyle represents the possible choices of the mapping styles
|
||||
* between the SOAP body of a wsdl:operation input/output messages and JAVA
|
||||
* method parameters and return/output values.
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public enum SoapBodyStyle {
|
||||
|
||||
/**
|
||||
* Bare style mapping of a document style with literal use wsdl:operation
|
||||
*/
|
||||
DocumentBare,
|
||||
|
||||
/**
|
||||
* Wrapper style mapping of a document style with literal use wsdl:operation
|
||||
*/
|
||||
DocumentWrapper,
|
||||
|
||||
/**
|
||||
* The mapping style of a RPC style with literal use wsdl:operation
|
||||
*/
|
||||
RpcLiteral,
|
||||
|
||||
/**
|
||||
* The mapping style of a RPC style with encoded use wsdl:operation.
|
||||
*
|
||||
* Note: this is not offically supported in JAX-WS.
|
||||
*/
|
||||
RpcEncoded,
|
||||
|
||||
/**
|
||||
* The mapping style is not specified.
|
||||
*/
|
||||
Unspecificed;
|
||||
|
||||
public boolean isDocument() {
|
||||
return (this.equals(DocumentBare) || this.equals(DocumentWrapper));
|
||||
}
|
||||
|
||||
public boolean isRpc() {
|
||||
return (this.equals(RpcLiteral) || this.equals(RpcEncoded));
|
||||
}
|
||||
|
||||
public boolean isLiteral() {
|
||||
return (this.equals(RpcLiteral) || this.isDocument());
|
||||
}
|
||||
|
||||
public boolean isBare() {
|
||||
return (this.equals(DocumentBare));
|
||||
}
|
||||
|
||||
public boolean isDocumentWrapper() {
|
||||
return (this.equals(DocumentWrapper));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.databinding;
|
||||
|
||||
import com.oracle.webservices.internal.api.databinding.WSDLResolver;
|
||||
import com.sun.xml.internal.ws.api.server.Container;
|
||||
import com.sun.xml.internal.ws.api.wsdl.writer.WSDLGeneratorExtension;
|
||||
|
||||
/**
|
||||
* WSDLGenInfo provides the WSDL generation options
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class WSDLGenInfo {
|
||||
WSDLResolver wsdlResolver;
|
||||
Container container;
|
||||
boolean inlineSchemas;
|
||||
boolean secureXmlProcessingDisabled;
|
||||
WSDLGeneratorExtension[] extensions;
|
||||
|
||||
public WSDLResolver getWsdlResolver() {
|
||||
return wsdlResolver;
|
||||
}
|
||||
public void setWsdlResolver(WSDLResolver wsdlResolver) {
|
||||
this.wsdlResolver = wsdlResolver;
|
||||
}
|
||||
public Container getContainer() {
|
||||
return container;
|
||||
}
|
||||
public void setContainer(Container container) {
|
||||
this.container = container;
|
||||
}
|
||||
public boolean isInlineSchemas() {
|
||||
return inlineSchemas;
|
||||
}
|
||||
public void setInlineSchemas(boolean inlineSchemas) {
|
||||
this.inlineSchemas = inlineSchemas;
|
||||
}
|
||||
public WSDLGeneratorExtension[] getExtensions() {
|
||||
if (extensions == null) return new WSDLGeneratorExtension[0];
|
||||
return extensions;
|
||||
}
|
||||
public void setExtensions(WSDLGeneratorExtension[] extensions) {
|
||||
this.extensions = extensions;
|
||||
}
|
||||
|
||||
public void setSecureXmlProcessingDisabled(boolean secureXmlProcessingDisabled) {
|
||||
this.secureXmlProcessingDisabled = secureXmlProcessingDisabled;
|
||||
}
|
||||
|
||||
public boolean isSecureXmlProcessingDisabled() {
|
||||
return secureXmlProcessingDisabled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.fastinfoset;
|
||||
|
||||
import com.sun.xml.internal.ws.api.FeatureConstructor;
|
||||
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
|
||||
import com.sun.org.glassfish.gmbal.ManagedAttribute;
|
||||
import com.sun.org.glassfish.gmbal.ManagedData;
|
||||
|
||||
/**
|
||||
* Enable or disable Fast Infoset on a Web service.
|
||||
* <p>
|
||||
* The following describes the affects of this feature with respect
|
||||
* to being enabled or disabled:
|
||||
* <ul>
|
||||
* <li> ENABLED: In this Mode, Fast Infoset will be enabled.
|
||||
* <li> DISABLED: In this Mode, Fast Infoset will be disabled and the
|
||||
* Web service will not process incoming messages or produce outgoing
|
||||
* messages encoded using Fast Infoset.
|
||||
* </ul>
|
||||
* <p>
|
||||
* If this feature is not present on a Web service then the default behaviour
|
||||
* is equivalent to this feature being present and enabled.
|
||||
* @author Paul.Sandoz@Sun.Com
|
||||
*/
|
||||
@ManagedData
|
||||
public class FastInfosetFeature extends WebServiceFeature {
|
||||
/**
|
||||
* Constant value identifying the {@link FastInfosetFeature}
|
||||
*/
|
||||
public static final String ID = "http://java.sun.com/xml/ns/jaxws/fastinfoset";
|
||||
|
||||
/**
|
||||
* Create a {@link FastInfosetFeature}. The instance created will be enabled.
|
||||
*/
|
||||
public FastInfosetFeature() {
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link FastInfosetFeature}
|
||||
*
|
||||
* @param enabled specifies whether this feature should
|
||||
* be enabled or not.
|
||||
*/
|
||||
@FeatureConstructor({"enabled"})
|
||||
public FastInfosetFeature(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ManagedAttribute
|
||||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
84
jdkSrc/jdk8/com/sun/xml/internal/ws/api/ha/HaInfo.java
Normal file
84
jdkSrc/jdk8/com/sun/xml/internal/ws/api/ha/HaInfo.java
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.ha;
|
||||
|
||||
import com.sun.xml.internal.ws.api.message.Packet;
|
||||
|
||||
/**
|
||||
* This class has HA information
|
||||
* <p>
|
||||
*
|
||||
* This would help a loadbalancer to put the request(in case of a fail-over)
|
||||
* on a replica instance that has all the related data. Even if there is no
|
||||
* loadbalancer, a backing store could locate the information by directly
|
||||
* going to the correct replica instance. This would also help any part of
|
||||
* the runtime to know about failover case(and in-turn may invalidate
|
||||
* local caches).
|
||||
*
|
||||
* <p>
|
||||
* To achieve this functionality, it carries two pieces of information:
|
||||
* <ol>
|
||||
* <li>key - Related {@link com.sun.org.glassfish.ha.store.api.BackingStore} keys can
|
||||
* use this info for their HashableKey impl. First store creates this object,
|
||||
* and subsequent related stores use the same key.
|
||||
* <li>replicaInstance - where the related info is replicated
|
||||
* </ol>
|
||||
*
|
||||
* <p>
|
||||
* This can be accessed from {@link Packet} using {@link Packet#HA_INFO}
|
||||
* property by the runtime. This object is created typically
|
||||
* <ul>
|
||||
* <li> When a store happens for the first time
|
||||
* <li> A subsequent inbound transport creates from cookies
|
||||
* <li> A fail-over request stores the data to a different replica
|
||||
* </ul>
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
* @since JAX-WS RI 2.2.2
|
||||
*/
|
||||
public class HaInfo {
|
||||
private final String replicaInstance;
|
||||
private final String key;
|
||||
private final boolean failOver;
|
||||
|
||||
public HaInfo(String key, String replicaInstance, boolean failOver) {
|
||||
this.key = key;
|
||||
this.replicaInstance = replicaInstance;
|
||||
this.failOver = failOver;
|
||||
}
|
||||
|
||||
public String getReplicaInstance() {
|
||||
return replicaInstance;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public boolean isFailOver() {
|
||||
return failOver;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.ha;
|
||||
|
||||
|
||||
/**
|
||||
* Provides a way to tell the runtime about stickiness of requests. In a
|
||||
* HA environment, a client's requests need to land on the same instance so
|
||||
* that a {@link com.sun.org.glassfish.ha.store.api.BackingStore} entry for a key is
|
||||
* accessed/modified from the same instance.
|
||||
*
|
||||
* <p>
|
||||
* A web service feature may implement this interface. JAX-WS runtime
|
||||
* checks if any feature needs stickiness of requests, and if HA is configured
|
||||
* ({@link HighAvailabilityProvider#isHaEnvironmentConfigured()}), it will take
|
||||
* an appropriate action. For example, in servlet transport, it would create
|
||||
* JSESSIONID cookie so that a typical loadbalancer would stick the subsequent
|
||||
* client requests to the same instance.
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
* @since JAX-WS RI 2.2.2
|
||||
*/
|
||||
public interface StickyFeature {
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.handler;
|
||||
|
||||
import javax.xml.ws.handler.Handler;
|
||||
import javax.xml.namespace.QName;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>MessageHandler</code> class extends <code>Handler</code>
|
||||
* to provide typesafety for the message context parameter and add a method
|
||||
* to obtain access to the headers that may be processed by the handler.
|
||||
* Its provides similar functionality as a SOAPHandler but provides RI's
|
||||
* Message in the MessageContext.
|
||||
*
|
||||
* @author Rama Pulavarthi
|
||||
* @since JAX-WS 2.1.3
|
||||
*/
|
||||
public interface MessageHandler<C extends MessageHandlerContext> extends Handler<C> {
|
||||
|
||||
|
||||
/** Gets the header blocks that can be processed by this Handler
|
||||
* instance.
|
||||
*
|
||||
* @return Set of <code>QNames</code> of header blocks processed by this
|
||||
* handler instance. <code>QName</code> is the qualified
|
||||
* name of the outermost element of the Header block.
|
||||
**/
|
||||
Set<QName> getHeaders();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.handler;
|
||||
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.message.Message;
|
||||
import com.sun.xml.internal.ws.api.model.SEIModel;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
|
||||
import javax.xml.ws.handler.MessageContext;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The <code>MessageHandlerContext</code> interface extends
|
||||
* <code>MessageContext</code> to provide easy access to the contained message.
|
||||
*
|
||||
* This context provides access to RI's <code>Message</code> model for efficient access
|
||||
* to various things like accessing headers etc. It also provides access to
|
||||
* binding information as <code>WSBinding</code>.
|
||||
*
|
||||
* @author Rama Pulavarthi
|
||||
* @since JAX-WS 2.1.3
|
||||
*/
|
||||
public interface MessageHandlerContext extends MessageContext {
|
||||
/**
|
||||
* Gets the message from this message context
|
||||
*
|
||||
* @return The contained message; returns <code>null</code> if no
|
||||
* message is present in this message context
|
||||
*/
|
||||
public Message getMessage();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the message in this message context
|
||||
*/
|
||||
public void setMessage(Message message);
|
||||
|
||||
/**
|
||||
* @see javax.xml.ws.handler.soap.SOAPMessageContext#getRoles()
|
||||
*/
|
||||
public Set<String> getRoles();
|
||||
|
||||
|
||||
/**
|
||||
* Provides access to <code>WSBinding</code> which can be used in various ways.
|
||||
* for example: <code>WSBinding#getSOAPVersion</code> to get SOAP version of the binding.
|
||||
* <code>WSBinding#isFeatureEnabled(AddressingFeature)</code> to check if addressing is enabled
|
||||
*/
|
||||
public WSBinding getWSBinding();
|
||||
|
||||
/**
|
||||
* Provides access to <code>SEIModel</code>.
|
||||
*/
|
||||
public @Nullable SEIModel getSEIModel();
|
||||
|
||||
/**
|
||||
* Gets the {@link WSDLPort} that represents the port.
|
||||
* @return
|
||||
* returns the WSDLModel of the port that the client/endpoint binds to.
|
||||
* null when the Service is not configured with WSDL information.
|
||||
*/
|
||||
public @Nullable WSDLPort getPort();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.message;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import javax.xml.ws.soap.SOAPBinding;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.ws.addressing.WsaTubeHelper;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingPropertySet;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.addressing.OneWayFeature;
|
||||
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.message.RelatesToHeader;
|
||||
import com.sun.xml.internal.ws.message.StringHeader;
|
||||
import com.sun.xml.internal.ws.resources.AddressingMessages;
|
||||
import com.sun.xml.internal.ws.resources.ClientMessages;
|
||||
|
||||
public class AddressingUtils {
|
||||
//TODO is MessageHeaders to be implicitly assumed? Or moved to utility class and taken out from interface?
|
||||
public static void fillRequestAddressingHeaders(MessageHeaders headers, Packet packet, AddressingVersion av, SOAPVersion sv, boolean oneway, String action) {
|
||||
fillRequestAddressingHeaders(headers, packet, av, sv, oneway, action, false);
|
||||
}
|
||||
public static void fillRequestAddressingHeaders(MessageHeaders headers, Packet packet, AddressingVersion av, SOAPVersion sv, boolean oneway, String action, boolean mustUnderstand) {
|
||||
fillCommonAddressingHeaders(headers, packet, av, sv, action, mustUnderstand);
|
||||
|
||||
// wsa:ReplyTo
|
||||
// null or "true" is equivalent to request/response MEP
|
||||
if (!oneway) {
|
||||
WSEndpointReference epr = av.anonymousEpr;
|
||||
if (headers.get(av.replyToTag, false) == null) {
|
||||
headers.add(epr.createHeader(av.replyToTag));
|
||||
}
|
||||
|
||||
// wsa:FaultTo
|
||||
if (headers.get(av.faultToTag, false) == null) {
|
||||
headers.add(epr.createHeader(av.faultToTag));
|
||||
}
|
||||
|
||||
// wsa:MessageID
|
||||
if (packet.getMessage().getHeaders().get(av.messageIDTag, false) == null) {
|
||||
if (headers.get(av.messageIDTag, false) == null) {
|
||||
Header h = new StringHeader(av.messageIDTag, Message.generateMessageID());
|
||||
headers.add(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// private void fillRequestAddressingHeaders(Packet packet, AddressingVersion av, SOAPVersion sv, OneWayFeature oneWayFeature, boolean oneway, String action);
|
||||
public static void fillRequestAddressingHeaders(MessageHeaders headers, WSDLPort wsdlPort, WSBinding binding, Packet packet) {
|
||||
if (binding == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_BINDING());
|
||||
}
|
||||
|
||||
if (binding.isFeatureEnabled(SuppressAutomaticWSARequestHeadersFeature.class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//See if WSA headers are already set by the user.
|
||||
MessageHeaders hl = packet.getMessage().getHeaders();
|
||||
String action = AddressingUtils.getAction(hl, binding.getAddressingVersion(), binding.getSOAPVersion());
|
||||
if (action != null) {
|
||||
//assume that all the WSA headers are set by the user
|
||||
return;
|
||||
}
|
||||
AddressingVersion addressingVersion = binding.getAddressingVersion();
|
||||
//seiModel is passed as null as it is not needed.
|
||||
WsaTubeHelper wsaHelper = addressingVersion.getWsaHelper(wsdlPort, null, binding);
|
||||
|
||||
// wsa:Action
|
||||
String effectiveInputAction = wsaHelper.getEffectiveInputAction(packet);
|
||||
if (effectiveInputAction == null || effectiveInputAction.equals("") && binding.getSOAPVersion() == SOAPVersion.SOAP_11) {
|
||||
throw new WebServiceException(ClientMessages.INVALID_SOAP_ACTION());
|
||||
}
|
||||
boolean oneway = !packet.expectReply;
|
||||
if (wsdlPort != null) {
|
||||
// if WSDL has <wsaw:Anonymous>prohibited</wsaw:Anonymous>, then throw an error
|
||||
// as anonymous ReplyTo MUST NOT be added in that case. BindingProvider need to
|
||||
// disable AddressingFeature and MemberSubmissionAddressingFeature and hand-craft
|
||||
// the SOAP message with non-anonymous ReplyTo/FaultTo.
|
||||
if (!oneway && packet.getMessage() != null && packet.getWSDLOperation() != null) {
|
||||
WSDLBoundOperation wbo = wsdlPort.getBinding().get(packet.getWSDLOperation());
|
||||
if (wbo != null && wbo.getAnonymous() == WSDLBoundOperation.ANONYMOUS.prohibited) {
|
||||
throw new WebServiceException(AddressingMessages.WSAW_ANONYMOUS_PROHIBITED());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OneWayFeature oneWayFeature = binding.getFeature(OneWayFeature.class);
|
||||
final AddressingPropertySet addressingPropertySet = packet.getSatellite(AddressingPropertySet.class);
|
||||
oneWayFeature = addressingPropertySet == null ? oneWayFeature : new OneWayFeature(addressingPropertySet, addressingVersion);
|
||||
|
||||
if (oneWayFeature == null || !oneWayFeature.isEnabled()) {
|
||||
// standard oneway
|
||||
fillRequestAddressingHeaders(headers, packet, addressingVersion, binding.getSOAPVersion(), oneway, effectiveInputAction, AddressingVersion.isRequired(binding));
|
||||
} else {
|
||||
// custom oneway
|
||||
fillRequestAddressingHeaders(headers, packet, addressingVersion, binding.getSOAPVersion(), oneWayFeature, oneway, effectiveInputAction);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getAction(@NotNull MessageHeaders headers, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
if (av == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
|
||||
}
|
||||
|
||||
String action = null;
|
||||
Header h = getFirstHeader(headers, av.actionTag, true, sv);
|
||||
if (h != null) {
|
||||
action = h.getStringContent();
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
public static WSEndpointReference getFaultTo(@NotNull MessageHeaders headers, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
if (av == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
|
||||
}
|
||||
|
||||
Header h = getFirstHeader(headers, av.faultToTag, true, sv);
|
||||
WSEndpointReference faultTo = null;
|
||||
if (h != null) {
|
||||
try {
|
||||
faultTo = h.readAsEPR(av);
|
||||
} catch (XMLStreamException e) {
|
||||
throw new WebServiceException(AddressingMessages.FAULT_TO_CANNOT_PARSE(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return faultTo;
|
||||
}
|
||||
|
||||
public static String getMessageID(@NotNull MessageHeaders headers, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
if (av == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
|
||||
}
|
||||
|
||||
Header h = getFirstHeader(headers, av.messageIDTag, true, sv);
|
||||
String messageId = null;
|
||||
if (h != null) {
|
||||
messageId = h.getStringContent();
|
||||
}
|
||||
|
||||
return messageId;
|
||||
}
|
||||
public static String getRelatesTo(@NotNull MessageHeaders headers, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
if (av == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
|
||||
}
|
||||
|
||||
Header h = getFirstHeader(headers, av.relatesToTag, true, sv);
|
||||
String relatesTo = null;
|
||||
if (h != null) {
|
||||
relatesTo = h.getStringContent();
|
||||
}
|
||||
|
||||
return relatesTo;
|
||||
}
|
||||
public static WSEndpointReference getReplyTo(@NotNull MessageHeaders headers, @NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
if (av == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
|
||||
}
|
||||
|
||||
Header h = getFirstHeader(headers, av.replyToTag, true, sv);
|
||||
WSEndpointReference replyTo;
|
||||
if (h != null) {
|
||||
try {
|
||||
replyTo = h.readAsEPR(av);
|
||||
} catch (XMLStreamException e) {
|
||||
throw new WebServiceException(AddressingMessages.REPLY_TO_CANNOT_PARSE(), e);
|
||||
}
|
||||
} else {
|
||||
replyTo = av.anonymousEpr;
|
||||
}
|
||||
|
||||
return replyTo;
|
||||
}
|
||||
public static String getTo(MessageHeaders headers, AddressingVersion av, SOAPVersion sv) {
|
||||
if (av == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
|
||||
}
|
||||
|
||||
Header h = getFirstHeader(headers, av.toTag, true, sv);
|
||||
String to;
|
||||
if (h != null) {
|
||||
to = h.getStringContent();
|
||||
} else {
|
||||
to = av.anonymousUri;
|
||||
}
|
||||
|
||||
return to;
|
||||
}
|
||||
|
||||
public static Header getFirstHeader(MessageHeaders headers, QName name, boolean markUnderstood, SOAPVersion sv) {
|
||||
if (sv == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_SOAP_VERSION());
|
||||
}
|
||||
|
||||
Iterator<Header> iter = headers.getHeaders(name.getNamespaceURI(), name.getLocalPart(), markUnderstood);
|
||||
while (iter.hasNext()) {
|
||||
Header h = iter.next();
|
||||
if (h.getRole(sv).equals(sv.implicitRole)) {
|
||||
return h;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void fillRequestAddressingHeaders(@NotNull MessageHeaders headers, @NotNull Packet packet, @NotNull AddressingVersion av, @NotNull SOAPVersion sv, @NotNull OneWayFeature oneWayFeature, boolean oneway, @NotNull String action) {
|
||||
if (!oneway&&!oneWayFeature.isUseAsyncWithSyncInvoke() && Boolean.TRUE.equals(packet.isSynchronousMEP)) {
|
||||
fillRequestAddressingHeaders(headers, packet, av, sv, oneway, action);
|
||||
} else {
|
||||
fillCommonAddressingHeaders(headers, packet, av, sv, action, false);
|
||||
|
||||
boolean isMessageIdAdded = false;
|
||||
|
||||
// wsa:ReplyTo
|
||||
// add if it doesn't already exist and OneWayFeature requests a specific ReplyTo
|
||||
if (headers.get(av.replyToTag, false) == null) {
|
||||
WSEndpointReference replyToEpr = oneWayFeature.getReplyTo();
|
||||
if (replyToEpr != null) {
|
||||
headers.add(replyToEpr.createHeader(av.replyToTag));
|
||||
// add wsa:MessageID only for non-null ReplyTo
|
||||
if (packet.getMessage().getHeaders().get(av.messageIDTag, false) == null) {
|
||||
// if header doesn't exist, method getID creates a new random id
|
||||
String newID = oneWayFeature.getMessageId() == null ? Message.generateMessageID() : oneWayFeature.getMessageId();
|
||||
headers.add(new StringHeader(av.messageIDTag, newID));
|
||||
isMessageIdAdded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the user sets a messageId, use it.
|
||||
final String messageId = oneWayFeature.getMessageId();
|
||||
if (!isMessageIdAdded && messageId != null) {
|
||||
headers.add(new StringHeader(av.messageIDTag, messageId));
|
||||
}
|
||||
|
||||
// wsa:FaultTo
|
||||
// add if it doesn't already exist and OneWayFeature requests a specific FaultTo
|
||||
if (headers.get(av.faultToTag, false) == null) {
|
||||
WSEndpointReference faultToEpr = oneWayFeature.getFaultTo();
|
||||
if (faultToEpr != null) {
|
||||
headers.add(faultToEpr.createHeader(av.faultToTag));
|
||||
// add wsa:MessageID only for non-null FaultTo
|
||||
if (headers.get(av.messageIDTag, false) == null) {
|
||||
headers.add(new StringHeader(av.messageIDTag, Message.generateMessageID()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// wsa:From
|
||||
if (oneWayFeature.getFrom() != null) {
|
||||
headers.addOrReplace(oneWayFeature.getFrom().createHeader(av.fromTag));
|
||||
}
|
||||
|
||||
// wsa:RelatesTo
|
||||
if (oneWayFeature.getRelatesToID() != null) {
|
||||
headers.addOrReplace(new RelatesToHeader(av.relatesToTag, oneWayFeature.getRelatesToID()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates wsa:To, wsa:Action and wsa:MessageID header on the client
|
||||
*
|
||||
* @param packet request packet
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @param action Action Message Addressing Property value
|
||||
* @throws IllegalArgumentException if any of the parameters is null.
|
||||
*/
|
||||
private static void fillCommonAddressingHeaders(MessageHeaders headers, Packet packet, @NotNull AddressingVersion av, @NotNull SOAPVersion sv, @NotNull String action, boolean mustUnderstand) {
|
||||
if (packet == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_PACKET());
|
||||
}
|
||||
|
||||
if (av == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ADDRESSING_VERSION());
|
||||
}
|
||||
|
||||
if (sv == null) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_SOAP_VERSION());
|
||||
}
|
||||
|
||||
if (action == null && !sv.httpBindingId.equals(SOAPBinding.SOAP12HTTP_BINDING)) {
|
||||
throw new IllegalArgumentException(AddressingMessages.NULL_ACTION());
|
||||
}
|
||||
|
||||
// wsa:To
|
||||
if (headers.get(av.toTag, false) == null) {
|
||||
StringHeader h = new StringHeader(av.toTag, packet.endpointAddress.toString());
|
||||
headers.add(h);
|
||||
}
|
||||
|
||||
// wsa:Action
|
||||
if (action != null) {
|
||||
packet.soapAction = action;
|
||||
if (headers.get(av.actionTag, false) == null) {
|
||||
//As per WS-I BP 1.2/2.0, if one of the WSA headers is MU, then all WSA headers should be treated as MU.,
|
||||
// so just set MU on action header
|
||||
StringHeader h = new StringHeader(av.actionTag, action, sv, mustUnderstand);
|
||||
headers.add(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
100
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Attachment.java
Normal file
100
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Attachment.java
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.transform.Source;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Attachment.
|
||||
*/
|
||||
public interface Attachment {
|
||||
|
||||
/**
|
||||
* Content ID of the attachment. Uniquely identifies an attachment.
|
||||
*
|
||||
* http://www.ietf.org/rfc/rfc2392.txt (which is referred by the ws-i attachment profile
|
||||
* http://www.ws-i.org/Profiles/AttachmentsProfile-1.0.html)
|
||||
*
|
||||
* content-id = url-addr-spec
|
||||
* url-addr-spec = addr-spec ; URL encoding of RFC 822 addr-spec
|
||||
* cid-url = "cid" ":" content-id
|
||||
*
|
||||
* A "cid" URL is converted to the corresponding Content-ID message header [MIME] by
|
||||
* removing the "cid:" prefix, converting the % encoded character to their equivalent
|
||||
* US-ASCII characters, and enclosing the remaining parts with an angle bracket pair,
|
||||
* "<" and ">". For example, "cid:foo4%25foo1@bar.net" corresponds to
|
||||
* Content-ID: <foo4%25foo1@bar.net>
|
||||
*
|
||||
* @return
|
||||
* The content ID like "foo-bar-zot@abc.com", without
|
||||
* surrounding '<' and '>' used as the transfer syntax.
|
||||
*/
|
||||
@NotNull String getContentId();
|
||||
|
||||
/**
|
||||
* Gets the MIME content-type of this attachment.
|
||||
*/
|
||||
String getContentType();
|
||||
|
||||
/**
|
||||
* Gets the attachment as an exact-length byte array.
|
||||
*/
|
||||
byte[] asByteArray();
|
||||
|
||||
/**
|
||||
* Gets the attachment as a {@link DataHandler}.
|
||||
*/
|
||||
DataHandler asDataHandler();
|
||||
|
||||
/**
|
||||
* Gets the attachment as a {@link Source}.
|
||||
* Note that there's no guarantee that the attachment is actually an XML.
|
||||
*/
|
||||
Source asSource();
|
||||
|
||||
/**
|
||||
* Obtains this attachment as an {@link InputStream}.
|
||||
*/
|
||||
InputStream asInputStream();
|
||||
|
||||
/**
|
||||
* Writes the contents of the attachment into the given stream.
|
||||
*/
|
||||
void writeTo(OutputStream os) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes this attachment to the given {@link SOAPMessage}.
|
||||
*/
|
||||
void writeTo(SOAPMessage saaj) throws SOAPException;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Attachment extended interface exposing custom MIME headers.
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public interface AttachmentEx extends Attachment {
|
||||
/**
|
||||
* MIME header
|
||||
*/
|
||||
public interface MimeHeader {
|
||||
/**
|
||||
* MIME header name
|
||||
* @return name
|
||||
*/
|
||||
public String getName();
|
||||
/**
|
||||
* MIME header value
|
||||
* @return value
|
||||
*/
|
||||
public String getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterator of custom MIME headers associated with this attachment
|
||||
* @return MIME header iterator
|
||||
*/
|
||||
public @NotNull Iterator<MimeHeader> getMimeHeaders();
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.message;
|
||||
|
||||
import com.sun.istack.internal.Nullable;
|
||||
|
||||
/**
|
||||
* A set of {@link Attachment} on a {@link Message}.
|
||||
*
|
||||
* <p>
|
||||
* A particular attention is made to ensure that attachments
|
||||
* can be read and parsed lazily as requested.
|
||||
*
|
||||
* @see Message#getAttachments()
|
||||
*/
|
||||
public interface AttachmentSet extends Iterable<Attachment> {
|
||||
/**
|
||||
* Gets the attachment by the content ID.
|
||||
*
|
||||
* @param contentId
|
||||
* The content ID like "foo-bar-zot@abc.com", without
|
||||
* surrounding '<' and '>' used as the transfer syntax.
|
||||
*
|
||||
* @return null
|
||||
* if no such attachment exist.
|
||||
*/
|
||||
@Nullable
|
||||
Attachment get(String contentId);
|
||||
|
||||
/**
|
||||
* Returns true if there's no attachment.
|
||||
*/
|
||||
boolean isEmpty();
|
||||
|
||||
/**
|
||||
* Adds an attachment to this set.
|
||||
*
|
||||
* <p>
|
||||
* Note that it's OK for an {@link Attachment} to belong to
|
||||
* more than one {@link AttachmentSet} (which is in fact
|
||||
* necessary when you wrap a {@link Message} into another.
|
||||
*
|
||||
* @param att
|
||||
* must not be null.
|
||||
*/
|
||||
public void add(Attachment att);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.message;
|
||||
|
||||
import com.sun.xml.internal.ws.util.exception.JAXWSExceptionBase;
|
||||
import com.sun.xml.internal.ws.protocol.soap.VersionMismatchException;
|
||||
|
||||
/**
|
||||
* This class represents an Exception that needs to be marshalled
|
||||
* with a specific protocol wire format. For example, the SOAP's
|
||||
* VersionMismatchFault needs to be written with a correct fault code.
|
||||
* In that case, decoder could throw {@link VersionMismatchException},
|
||||
* and the corresponding fault {@link Message} from {@link ExceptionHasMessage#getFaultMessage()}
|
||||
* is sent on the wire.
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
*/
|
||||
public abstract class ExceptionHasMessage extends JAXWSExceptionBase {
|
||||
|
||||
public ExceptionHasMessage(String key, Object... args) {
|
||||
super(key, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exception into a fault Message
|
||||
*
|
||||
* @return Message for this exception
|
||||
*/
|
||||
public abstract Message getFaultMessage();
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.bind.api.Bridge;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.spi.db.XMLBridge;
|
||||
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
/**
|
||||
* A <code>FilterMessageImpl</code> contains some other Message, which it uses
|
||||
* as its basic source of message data, possibly transforming the data along
|
||||
* the way or providing additional functionality.
|
||||
*
|
||||
* <p>
|
||||
* The class <code>FilterMessageImpl</code> itself simply overrides
|
||||
* all the methods of <code>Message</code> and invokes them on
|
||||
* contained Message delegate. Subclasses of <code>FilterMessageImpl</code>
|
||||
* may further override some of these methods and may also provide
|
||||
* additional methods and fields.
|
||||
*
|
||||
* @author Jitendra Kotamraju
|
||||
*/
|
||||
public class FilterMessageImpl extends Message {
|
||||
private final Message delegate;
|
||||
|
||||
protected FilterMessageImpl(Message delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public boolean hasHeaders() {
|
||||
return delegate.hasHeaders();
|
||||
}
|
||||
|
||||
public @NotNull MessageHeaders getHeaders() {
|
||||
return delegate.getHeaders();
|
||||
}
|
||||
|
||||
public @NotNull AttachmentSet getAttachments() {
|
||||
return delegate.getAttachments();
|
||||
}
|
||||
|
||||
protected boolean hasAttachments() {
|
||||
return delegate.hasAttachments();
|
||||
}
|
||||
|
||||
public boolean isOneWay(@NotNull WSDLPort port) {
|
||||
return delegate.isOneWay(port);
|
||||
}
|
||||
|
||||
public @Nullable String getPayloadLocalPart() {
|
||||
return delegate.getPayloadLocalPart();
|
||||
}
|
||||
|
||||
public String getPayloadNamespaceURI() {
|
||||
return delegate.getPayloadNamespaceURI();
|
||||
}
|
||||
|
||||
public boolean hasPayload() {
|
||||
return delegate.hasPayload();
|
||||
}
|
||||
|
||||
public boolean isFault() {
|
||||
return delegate.isFault();
|
||||
}
|
||||
|
||||
public @Nullable QName getFirstDetailEntryName() {
|
||||
return delegate.getFirstDetailEntryName();
|
||||
}
|
||||
|
||||
public Source readEnvelopeAsSource() {
|
||||
return delegate.readEnvelopeAsSource();
|
||||
}
|
||||
|
||||
public Source readPayloadAsSource() {
|
||||
return delegate.readPayloadAsSource();
|
||||
}
|
||||
|
||||
public SOAPMessage readAsSOAPMessage() throws SOAPException {
|
||||
return delegate.readAsSOAPMessage();
|
||||
}
|
||||
|
||||
public SOAPMessage readAsSOAPMessage(Packet packet, boolean inbound) throws SOAPException {
|
||||
return delegate.readAsSOAPMessage(packet, inbound);
|
||||
}
|
||||
|
||||
public <T> T readPayloadAsJAXB(Unmarshaller unmarshaller) throws JAXBException {
|
||||
return (T)delegate.readPayloadAsJAXB(unmarshaller);
|
||||
}
|
||||
/** @deprecated */
|
||||
public <T> T readPayloadAsJAXB(Bridge<T> bridge) throws JAXBException {
|
||||
return delegate.readPayloadAsJAXB(bridge);
|
||||
}
|
||||
|
||||
public <T> T readPayloadAsJAXB(XMLBridge<T> bridge) throws JAXBException {
|
||||
return delegate.readPayloadAsJAXB(bridge);
|
||||
}
|
||||
|
||||
public XMLStreamReader readPayload() throws XMLStreamException {
|
||||
return delegate.readPayload();
|
||||
}
|
||||
|
||||
public void consume() {
|
||||
delegate.consume();
|
||||
}
|
||||
|
||||
public void writePayloadTo(XMLStreamWriter sw) throws XMLStreamException {
|
||||
delegate.writePayloadTo(sw);
|
||||
}
|
||||
|
||||
public void writeTo(XMLStreamWriter sw) throws XMLStreamException {
|
||||
delegate.writeTo(sw);
|
||||
}
|
||||
|
||||
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
|
||||
delegate.writeTo(contentHandler, errorHandler);
|
||||
}
|
||||
|
||||
public Message copy() {
|
||||
return delegate.copy();
|
||||
}
|
||||
|
||||
public @NotNull String getID(@NotNull WSBinding binding) {
|
||||
return delegate.getID(binding);
|
||||
}
|
||||
|
||||
public @NotNull String getID(AddressingVersion av, SOAPVersion sv) {
|
||||
return delegate.getID(av, sv);
|
||||
}
|
||||
|
||||
public SOAPVersion getSOAPVersion() {
|
||||
return delegate.getSOAPVersion();
|
||||
}
|
||||
}
|
||||
334
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Header.java
Normal file
334
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Header.java
Normal file
@@ -0,0 +1,334 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.bind.api.Bridge;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
|
||||
import com.sun.xml.internal.ws.spi.db.XMLBridge;
|
||||
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* A SOAP header.
|
||||
*
|
||||
* <p>
|
||||
* A header is immutable, but unlike body it can be read
|
||||
* multiple times.
|
||||
* The {@link Header} abstraction hides how the header
|
||||
* data is represented in memory; instead, it commits to
|
||||
* the ability to write itself to XML infoset.
|
||||
*
|
||||
* <p>
|
||||
* When a message is received from the transport and
|
||||
* being processed, the processor needs to "peek"
|
||||
* some information of a header, such as the tag name,
|
||||
* the mustUnderstand attribute, and so on. Therefore,
|
||||
* the {@link Header} interface exposes those information
|
||||
* as properties, so that they can be checked without
|
||||
* replaying the infoset, which is efficiently but still
|
||||
* costly.
|
||||
*
|
||||
* <p>
|
||||
* A {@link Header} may belong to more than one {@link HeaderList}
|
||||
* due to wrapping of {@link Message}.
|
||||
*
|
||||
* @see HeaderList
|
||||
* @see Headers
|
||||
*/
|
||||
public interface Header {
|
||||
// TODO: Vivek pointed out that the only time we are looking at
|
||||
// mustUnderstand and role are when we do the mustUnderstand error check
|
||||
// (that is, to find out if there's any header with @mustUnderstand that
|
||||
// has appropriate role for us.)
|
||||
// if that's the case, it might be better if we define this whole operation
|
||||
// as one method, instead of exposing two properties.
|
||||
|
||||
/**
|
||||
* Checks if this header is ignorable for us (IOW, make sure
|
||||
* that this header has a problematic "mustUnderstand" header value
|
||||
* that we have to reject.)
|
||||
*
|
||||
* <p>
|
||||
* This method is used as a part of the
|
||||
* <a href="HeaderList.html#MU">mustUnderstanx processing</a>.
|
||||
* At the end of the processing, the JAX-WS identifies a list of {@link Header}s
|
||||
* that were not understood. This method is invoked on those {@link Header}s,
|
||||
* to verify that we don't need to report an error for it.
|
||||
*
|
||||
* <p>
|
||||
* specifically, this method has to perform the following tasks:
|
||||
*
|
||||
* <ul>
|
||||
* <li>If this header does not have <tt>mustUnderstand</tt> as "1" nor "true",
|
||||
* then this method must return true.
|
||||
* <li>Otherwise, check the role attribute (for SOAP 1.2) or the actor attribute (for SOAP 1.1).
|
||||
* When those attributes are absent, the default values have to be assumed.
|
||||
* See {@link #getRole(SOAPVersion)} for how the values are defaulted.
|
||||
* Now, see if the {@code roles} set contains the value.
|
||||
* If so, this method must return false (indicating that an error is in order.)
|
||||
* <li>Otherwise return true (since we don't play the role this header is intended for.)
|
||||
* </ul>
|
||||
*
|
||||
* @param soapVersion
|
||||
* The caller specifies the SOAP version that the pipeline is working against.
|
||||
* Often each {@link Header} implementation already knows the SOAP version
|
||||
* anyway, but this allows some {@link Header}s to avoid keeping it.
|
||||
* That's why this redundant parameter is passed in.
|
||||
* @param roles
|
||||
* The set of role values that the current JAX-WS pipeline is assuming.
|
||||
* Note that SOAP 1.1 and SOAP 1.2 use different strings for the same role,
|
||||
* and the caller is responsible for supplying a proper value depending on the
|
||||
* active SOAP version in use.
|
||||
*
|
||||
* @return
|
||||
* true if no error needs to be reported. False if an error needs to be raised.
|
||||
* See the method javadoc for more discussion.
|
||||
*/
|
||||
public boolean isIgnorable(@NotNull SOAPVersion soapVersion, @NotNull Set<String> roles);
|
||||
|
||||
/**
|
||||
* Gets the value of the soap:role attribute (or soap:actor for SOAP 1.1).
|
||||
*
|
||||
* <p>
|
||||
* If the attribute is omitted, the value defaults to {@link SOAPVersion#implicitRole}.
|
||||
*
|
||||
* @param soapVersion
|
||||
* The caller specifies the SOAP version that the pipeline is working against.
|
||||
* Often each {@link Header} implementation already knows the SOAP version
|
||||
* anyway, but this allows some {@link Header}s to avoid keeping it.
|
||||
* That's why this redundant parameter is passed in.
|
||||
* @return
|
||||
* never null. This string need not be interned.
|
||||
*/
|
||||
public @NotNull String getRole(@NotNull SOAPVersion soapVersion);
|
||||
|
||||
/**
|
||||
* True if this header is to be relayed if not processed.
|
||||
* For SOAP 1.1 messages, this method always return false.
|
||||
*
|
||||
* <p>
|
||||
* IOW, this method returns true if there's @soap:relay='true'
|
||||
* is present.
|
||||
*
|
||||
* <h3>Implementation Note</h3>
|
||||
* <p>
|
||||
* The implementation needs to check for both "true" and "1",
|
||||
* but because attribute values are normalized, it doesn't have
|
||||
* to consider " true", " 1 ", and so on.
|
||||
*
|
||||
* @return
|
||||
* false.
|
||||
*/
|
||||
public boolean isRelay();
|
||||
|
||||
/**
|
||||
* Gets the namespace URI of this header element.
|
||||
*
|
||||
* @return
|
||||
* this string must be interned.
|
||||
*/
|
||||
public @NotNull String getNamespaceURI();
|
||||
|
||||
/**
|
||||
* Gets the local name of this header element.
|
||||
*
|
||||
* @return
|
||||
* this string must be interned.
|
||||
*/
|
||||
public @NotNull String getLocalPart();
|
||||
|
||||
/**
|
||||
* Gets the attribute value on the header element.
|
||||
*
|
||||
* @param nsUri
|
||||
* The namespace URI of the attribute. Can be empty.
|
||||
* @param localName
|
||||
* The local name of the attribute.
|
||||
*
|
||||
* @return
|
||||
* if the attribute is found, return the whitespace normalized value.
|
||||
* (meaning no leading/trailing space, no consequtive whitespaces in-between.)
|
||||
* Otherwise null. Note that the XML parsers are responsible for
|
||||
* whitespace-normalizing attributes, so {@link Header} implementation
|
||||
* doesn't have to do anything.
|
||||
*/
|
||||
@Nullable String getAttribute(@NotNull String nsUri, @NotNull String localName);
|
||||
|
||||
/**
|
||||
* Gets the attribute value on the header element.
|
||||
*
|
||||
* <p>
|
||||
* This is a convenience method that calls into {@link #getAttribute(String, String)}
|
||||
*
|
||||
* @param name
|
||||
* Never null.
|
||||
*
|
||||
* @see #getAttribute(String, String)
|
||||
*/
|
||||
@Nullable String getAttribute(@NotNull QName name);
|
||||
|
||||
/**
|
||||
* Reads the header as a {@link XMLStreamReader}.
|
||||
*
|
||||
* <p>
|
||||
* The returned parser points at the start element of this header.
|
||||
* (IOW, {@link XMLStreamReader#getEventType()} would return
|
||||
* {@link XMLStreamReader#START_ELEMENT}.
|
||||
*
|
||||
* <h3>Performance Expectation</h3>
|
||||
* <p>
|
||||
* For some {@link Header} implementations, this operation
|
||||
* is a non-trivial operation. Therefore, use of this method
|
||||
* is discouraged unless the caller is interested in reading
|
||||
* the whole header.
|
||||
*
|
||||
* <p>
|
||||
* Similarly, if the caller wants to use this method only to do
|
||||
* the API conversion (such as simply firing SAX events from
|
||||
* {@link XMLStreamReader}), then the JAX-WS team requests
|
||||
* that you talk to us.
|
||||
*
|
||||
* <p>
|
||||
* {@link Message}s that come from tranport usually provides
|
||||
* a reasonably efficient implementation of this method.
|
||||
*
|
||||
* @return
|
||||
* must not null.
|
||||
*/
|
||||
public XMLStreamReader readHeader() throws XMLStreamException;
|
||||
|
||||
/**
|
||||
* Reads the header as a JAXB object by using the given unmarshaller.
|
||||
*/
|
||||
public <T> T readAsJAXB(Unmarshaller unmarshaller) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Reads the header as a JAXB object by using the given unmarshaller.
|
||||
* @deprecated
|
||||
*/
|
||||
public <T> T readAsJAXB(Bridge<T> bridge) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Reads the header as a data-bond object
|
||||
*/
|
||||
public <T> T readAsJAXB(XMLBridge<T> bridge) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Reads this header as an {@link WSEndpointReference}.
|
||||
*
|
||||
* @param expected
|
||||
* The version of the addressing used to parse the EPR.
|
||||
* If the actual infoset and this doesn't agree, then
|
||||
* you'll get an {@link WebServiceException} stating that fact.
|
||||
*
|
||||
* @return
|
||||
* On a successful return, this method never returns null.
|
||||
*/
|
||||
public @NotNull WSEndpointReference readAsEPR(AddressingVersion expected) throws XMLStreamException;
|
||||
|
||||
/**
|
||||
* Writes out the header as a fragment.
|
||||
*
|
||||
* @throws XMLStreamException
|
||||
* if the operation fails for some reason. This leaves the
|
||||
* writer to an undefined state.
|
||||
*/
|
||||
public void writeTo(XMLStreamWriter w) throws XMLStreamException;
|
||||
|
||||
/**
|
||||
* Writes out the header to the given SOAPMessage.
|
||||
*
|
||||
* <p>
|
||||
* Sometimes a {@link Message} needs to produce itself
|
||||
* as {@link SOAPMessage}, in which case each header needs
|
||||
* to turn itself into a header.
|
||||
*
|
||||
* @throws SOAPException
|
||||
* if the operation fails for some reason. This leaves the
|
||||
* writer to an undefined state.
|
||||
*/
|
||||
public void writeTo(SOAPMessage saaj) throws SOAPException;
|
||||
|
||||
/**
|
||||
* Writes out the header as SAX events.
|
||||
*
|
||||
* <p>
|
||||
* Sometimes a {@link Message} needs to produce SAX events,
|
||||
* and this method is necessary for headers to participate to it.
|
||||
*
|
||||
* <p>
|
||||
* A header is responsible for producing the SAX events for its part,
|
||||
* including <tt>startPrefixMapping</tt> and <tt>endPrefixMapping</tt>,
|
||||
* but not startDocument/endDocument.
|
||||
*
|
||||
* <p>
|
||||
* Note that SAX contract requires that any error that does NOT originate
|
||||
* from {@link ContentHandler} (meaning any parsing error and etc) must
|
||||
* be first reported to {@link ErrorHandler}. If the SAX event production
|
||||
* cannot be continued and the processing needs to abort, the code may
|
||||
* then throw the same {@link SAXParseException} reported to {@link ErrorHandler}.
|
||||
*
|
||||
* @param contentHandler
|
||||
* The {@link ContentHandler} that receives SAX events.
|
||||
*
|
||||
* @param errorHandler
|
||||
* The {@link ErrorHandler} that receives parsing errors.
|
||||
*/
|
||||
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException;
|
||||
|
||||
/**
|
||||
* Used to obtain value XYZ from a header that looks like
|
||||
* "<header>XYZ</header>". The primary use of this header
|
||||
* for now is to access certain Addressing headers quickly.
|
||||
*
|
||||
* @throws WebServiceException
|
||||
* If the structure of the header is more complicated than
|
||||
* a simple string header.
|
||||
*
|
||||
* @return
|
||||
* Can be empty but always non-null.
|
||||
*/
|
||||
public @NotNull String getStringContent();
|
||||
}
|
||||
976
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/HeaderList.java
Normal file
976
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/HeaderList.java
Normal file
@@ -0,0 +1,976 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.message;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.api.pipe.Pipe;
|
||||
import com.sun.xml.internal.ws.binding.SOAPBindingImpl;
|
||||
import com.sun.xml.internal.ws.protocol.soap.ClientMUTube;
|
||||
import com.sun.xml.internal.ws.protocol.soap.ServerMUTube;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A list of {@link Header}s on a {@link Message}.
|
||||
*
|
||||
* <p>
|
||||
* This list can be modified to add headers
|
||||
* from outside a {@link Message}, this is necessary
|
||||
* since intermediate processing layers often need to
|
||||
* put additional headers.
|
||||
*
|
||||
* <p>
|
||||
* Following the SOAP convention, the order among headers
|
||||
* are not significant. However, {@link Codec}s are
|
||||
* expected to preserve the order of headers in the input
|
||||
* message as much as possible.
|
||||
*
|
||||
*
|
||||
* <a name="MU"></a>
|
||||
* <h3>MustUnderstand Processing</h3>
|
||||
* <p>
|
||||
* To perform SOAP mustUnderstang processing correctly, we need to keep
|
||||
* track of headers that are understood and headers that are not.
|
||||
* This is a collaborative process among {@link Pipe}s, thus it's something
|
||||
* a {@link Pipe} author needs to keep in mind.
|
||||
*
|
||||
* <p>
|
||||
* Specifically, when a {@link Pipe} sees a header and processes it
|
||||
* (that is, if it did enough computing with the header to claim that
|
||||
* the header is understood), then it should mark the corresponding
|
||||
* header as "understood". For example, when a pipe that handles JAX-WSA
|
||||
* examins the <wsa:To> header, it can claim that it understood the header.
|
||||
* But for example, if a pipe that does the signature verification checks
|
||||
* <wsa:To> for a signature, that would not be considered as "understood".
|
||||
*
|
||||
* <p>
|
||||
* There are two ways to mark a header as understood:
|
||||
*
|
||||
* <ol>
|
||||
* <li>Use one of the <tt>getXXX</tt> methods that take a
|
||||
* boolean <tt>markAsUnderstood</tt> parameter.
|
||||
* Most often, a {@link Pipe} knows it's going to understand a header
|
||||
* as long as it's present, so this is the easiest and thus the preferred way.
|
||||
*
|
||||
* For example, if JAX-WSA looks for <wsa:To>, then it can set
|
||||
* <tt>markAsUnderstand</tt> to true, to do the obtaining of a header
|
||||
* and marking at the same time.
|
||||
*
|
||||
* <li>Call {@link #understood(int)}.
|
||||
* If under a rare circumstance, a pipe cannot determine whether
|
||||
* it can understand it or not when you are fetching a header, then
|
||||
* you can use this method afterward to mark it as understood.
|
||||
* </ol>
|
||||
*
|
||||
* <p>
|
||||
* Intuitively speaking, at the end of the day, if a header is not
|
||||
* understood but {@link Header#isIgnorable(SOAPVersion, java.util.Set)} is false, a bad thing
|
||||
* will happen. The actual implementation of the checking is more complicated,
|
||||
* for that see {@link ClientMUTube}/{@link ServerMUTube}.
|
||||
*
|
||||
* @see Message#getHeaders()
|
||||
*/
|
||||
public class HeaderList extends ArrayList<Header> implements MessageHeaders {
|
||||
|
||||
private static final long serialVersionUID = -6358045781349627237L;
|
||||
/**
|
||||
* Bit set to keep track of which headers are understood.
|
||||
* <p>
|
||||
* The first 32 headers use this field, and the rest will use
|
||||
* {@link #moreUnderstoodBits}. The expectation is that
|
||||
* most of the time a SOAP message will only have up to 32 headers,
|
||||
* so we can avoid allocating separate objects for {@link BitSet}.
|
||||
*/
|
||||
private int understoodBits;
|
||||
/**
|
||||
* If there are more than 32 headers, we use this {@link BitSet}
|
||||
* to keep track of whether those headers are understood.
|
||||
* Lazily allocated.
|
||||
*/
|
||||
private BitSet moreUnderstoodBits = null;
|
||||
|
||||
private SOAPVersion soapVersion;
|
||||
|
||||
/**
|
||||
* This method is deprecated - instead use this one:
|
||||
* public HeaderList(SOAPVersion)
|
||||
* Creates an empty {@link HeaderList}.
|
||||
*/
|
||||
@Deprecated
|
||||
public HeaderList() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty {@link HeaderList} with the given soap version
|
||||
* @param soapVersion
|
||||
*/
|
||||
public HeaderList(SOAPVersion soapVersion) {
|
||||
this.soapVersion = soapVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
*/
|
||||
public HeaderList(HeaderList that) {
|
||||
super(that);
|
||||
this.understoodBits = that.understoodBits;
|
||||
if (that.moreUnderstoodBits != null) {
|
||||
this.moreUnderstoodBits = (BitSet) that.moreUnderstoodBits.clone();
|
||||
}
|
||||
}
|
||||
|
||||
public HeaderList(MessageHeaders that) {
|
||||
super(that.asList());
|
||||
if (that instanceof HeaderList) {
|
||||
HeaderList hThat = (HeaderList) that;
|
||||
this.understoodBits = hThat.understoodBits;
|
||||
if (hThat.moreUnderstoodBits != null) {
|
||||
this.moreUnderstoodBits = (BitSet) hThat.moreUnderstoodBits.clone();
|
||||
}
|
||||
} else {
|
||||
Set<QName> understood = that.getUnderstoodHeaders();
|
||||
if (understood != null) {
|
||||
for (QName qname : understood) {
|
||||
understood(qname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The total number of headers.
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return super.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasHeaders() {
|
||||
return !isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all the headers.
|
||||
* @deprecated throws UnsupportedOperationException from some HeaderList implementations - better iterate over items one by one
|
||||
*/
|
||||
@Deprecated
|
||||
public void addAll(Header... headers) {
|
||||
addAll(Arrays.asList(headers));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Header} at the specified index.
|
||||
*
|
||||
* <p>
|
||||
* This method does not mark the returned {@link Header} as understood.
|
||||
*
|
||||
* @see #understood(int)
|
||||
*/
|
||||
@Override
|
||||
public Header get(int index) {
|
||||
return super.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the {@link Header} at the specified index as
|
||||
* <a href="#MU">"understood"</a>.
|
||||
*/
|
||||
public void understood(int index) {
|
||||
// check that index is in range
|
||||
if (index >= size()) {
|
||||
throw new ArrayIndexOutOfBoundsException(index);
|
||||
}
|
||||
|
||||
if (index < 32) {
|
||||
understoodBits |= 1 << index;
|
||||
} else {
|
||||
if (moreUnderstoodBits == null) {
|
||||
moreUnderstoodBits = new BitSet();
|
||||
}
|
||||
moreUnderstoodBits.set(index - 32);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a {@link Header} at the given index
|
||||
* was <a href="#MU">"understood"</a>.
|
||||
*/
|
||||
public boolean isUnderstood(int index) {
|
||||
// check that index is in range
|
||||
if (index >= size()) {
|
||||
throw new ArrayIndexOutOfBoundsException(index);
|
||||
}
|
||||
|
||||
if (index < 32) {
|
||||
return understoodBits == (understoodBits | (1 << index));
|
||||
} else {
|
||||
if (moreUnderstoodBits == null) {
|
||||
return false;
|
||||
}
|
||||
return moreUnderstoodBits.get(index - 32);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the specified {@link Header} as <a href="#MU">"understood"</a>.
|
||||
*
|
||||
* @deprecated
|
||||
* By the definition of {@link ArrayList}, this operation requires
|
||||
* O(n) search of the array, and thus inherently inefficient.
|
||||
*
|
||||
* Because of this, if you are developing a {@link Pipe} for
|
||||
* a performance sensitive environment, do not use this method.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if the given header is not {@link #contains(Object) contained}
|
||||
* in this header.
|
||||
*/
|
||||
@Override
|
||||
public void understood(@NotNull Header header) {
|
||||
int sz = size();
|
||||
for (int i = 0; i < sz; i++) {
|
||||
if (get(i) == header) {
|
||||
understood(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first {@link Header} of the specified name.
|
||||
*
|
||||
* @param markAsUnderstood
|
||||
* If this parameter is true, the returned header will
|
||||
* be marked as <a href="#MU">"understood"</a>.
|
||||
* @return null if not found.
|
||||
*/
|
||||
@Override
|
||||
public @Nullable Header get(@NotNull String nsUri, @NotNull String localName, boolean markAsUnderstood) {
|
||||
int len = size();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Header h = get(i);
|
||||
if (h.getLocalPart().equals(localName) && h.getNamespaceURI().equals(nsUri)) {
|
||||
if (markAsUnderstood) {
|
||||
understood(i);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #get(String, String, boolean)}
|
||||
*/
|
||||
public Header get(String nsUri, String localName) {
|
||||
return get(nsUri, localName, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first {@link Header} of the specified name.
|
||||
*
|
||||
* @param markAsUnderstood
|
||||
* If this parameter is true, the returned header will
|
||||
* be marked as <a href="#MU">"understood"</a>.
|
||||
* @return null
|
||||
* if not found.
|
||||
*/
|
||||
@Override
|
||||
public @Nullable Header get(@NotNull QName name, boolean markAsUnderstood) {
|
||||
return get(name.getNamespaceURI(), name.getLocalPart(), markAsUnderstood);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #get(QName)}
|
||||
*/
|
||||
public
|
||||
@Nullable
|
||||
Header get(@NotNull QName name) {
|
||||
return get(name, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #getHeaders(String, String, boolean)}
|
||||
*/
|
||||
public Iterator<Header> getHeaders(final String nsUri, final String localName) {
|
||||
return getHeaders(nsUri, localName, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the {@link Header}s of the specified name,
|
||||
* including duplicates (if any.)
|
||||
*
|
||||
* @param markAsUnderstood
|
||||
* If this parameter is true, the returned headers will
|
||||
* be marked as <a href="#MU">"understood"</a> when they are returned
|
||||
* from {@link Iterator#next()}.
|
||||
* @return empty iterator if not found.
|
||||
*/
|
||||
public
|
||||
@NotNull
|
||||
@Override
|
||||
Iterator<Header> getHeaders(@NotNull final String nsUri, @NotNull final String localName, final boolean markAsUnderstood) {
|
||||
return new Iterator<Header>() {
|
||||
|
||||
int idx = 0;
|
||||
Header next;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (next == null) {
|
||||
fetch();
|
||||
}
|
||||
return next != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Header next() {
|
||||
if (next == null) {
|
||||
fetch();
|
||||
if (next == null) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
|
||||
if (markAsUnderstood) {
|
||||
assert get(idx - 1) == next;
|
||||
understood(idx - 1);
|
||||
}
|
||||
|
||||
Header r = next;
|
||||
next = null;
|
||||
return r;
|
||||
}
|
||||
|
||||
private void fetch() {
|
||||
while (idx < size()) {
|
||||
Header h = get(idx++);
|
||||
if (h.getLocalPart().equals(localName) && h.getNamespaceURI().equals(nsUri)) {
|
||||
next = h;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getHeaders(String, String, boolean)
|
||||
*/
|
||||
public
|
||||
@NotNull
|
||||
@Override
|
||||
Iterator<Header> getHeaders(@NotNull QName headerName, final boolean markAsUnderstood) {
|
||||
return getHeaders(headerName.getNamespaceURI(), headerName.getLocalPart(), markAsUnderstood);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* use {@link #getHeaders(String, boolean)}.
|
||||
*/
|
||||
public
|
||||
@NotNull
|
||||
Iterator<Header> getHeaders(@NotNull final String nsUri) {
|
||||
return getHeaders(nsUri, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an iteration of headers {@link Header} in the specified namespace,
|
||||
* including duplicates (if any.)
|
||||
*
|
||||
* @param markAsUnderstood
|
||||
* If this parameter is true, the returned headers will
|
||||
* be marked as <a href="#MU">"understood"</a> when they are returned
|
||||
* from {@link Iterator#next()}.
|
||||
* @return
|
||||
* empty iterator if not found.
|
||||
*/
|
||||
public
|
||||
@NotNull
|
||||
@Override
|
||||
Iterator<Header> getHeaders(@NotNull final String nsUri, final boolean markAsUnderstood) {
|
||||
return new Iterator<Header>() {
|
||||
|
||||
int idx = 0;
|
||||
Header next;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (next == null) {
|
||||
fetch();
|
||||
}
|
||||
return next != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Header next() {
|
||||
if (next == null) {
|
||||
fetch();
|
||||
if (next == null) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
|
||||
if (markAsUnderstood) {
|
||||
assert get(idx - 1) == next;
|
||||
understood(idx - 1);
|
||||
}
|
||||
|
||||
Header r = next;
|
||||
next = null;
|
||||
return r;
|
||||
}
|
||||
|
||||
private void fetch() {
|
||||
while (idx < size()) {
|
||||
Header h = get(idx++);
|
||||
if (h.getNamespaceURI().equals(nsUri)) {
|
||||
next = h;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of WS-Addressing <code>To</code> header. The <code>version</code>
|
||||
* identifies the WS-Addressing version and the header returned is targeted at
|
||||
* the current implicit role. Caches the value for subsequent invocation.
|
||||
* Duplicate <code>To</code> headers are detected earlier.
|
||||
*
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @throws IllegalArgumentException if either <code>av</code> or <code>sv</code> is null.
|
||||
* @return Value of WS-Addressing To header, anonymous URI if no header is present
|
||||
*/
|
||||
public String getTo(AddressingVersion av, SOAPVersion sv) {
|
||||
return AddressingUtils.getTo(this, av, sv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of WS-Addressing <code>Action</code> header. The <code>version</code>
|
||||
* identifies the WS-Addressing version and the header returned is targeted at
|
||||
* the current implicit role. Caches the value for subsequent invocation.
|
||||
* Duplicate <code>Action</code> headers are detected earlier.
|
||||
*
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @throws IllegalArgumentException if either <code>av</code> or <code>sv</code> is null.
|
||||
* @return Value of WS-Addressing Action header, null if no header is present
|
||||
*/
|
||||
public String getAction(@NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
return AddressingUtils.getAction(this, av, sv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of WS-Addressing <code>ReplyTo</code> header. The <code>version</code>
|
||||
* identifies the WS-Addressing version and the header returned is targeted at
|
||||
* the current implicit role. Caches the value for subsequent invocation.
|
||||
* Duplicate <code>ReplyTo</code> headers are detected earlier.
|
||||
*
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @throws IllegalArgumentException if either <code>av</code> or <code>sv</code> is null.
|
||||
* @return Value of WS-Addressing ReplyTo header, null if no header is present
|
||||
*/
|
||||
public WSEndpointReference getReplyTo(@NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
return AddressingUtils.getReplyTo(this, av, sv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of WS-Addressing <code>FaultTo</code> header. The <code>version</code>
|
||||
* identifies the WS-Addressing version and the header returned is targeted at
|
||||
* the current implicit role. Caches the value for subsequent invocation.
|
||||
* Duplicate <code>FaultTo</code> headers are detected earlier.
|
||||
*
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @throws IllegalArgumentException if either <code>av</code> or <code>sv</code> is null.
|
||||
* @return Value of WS-Addressing FaultTo header, null if no header is present
|
||||
*/
|
||||
public WSEndpointReference getFaultTo(@NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
return AddressingUtils.getFaultTo(this, av, sv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of WS-Addressing <code>MessageID</code> header. The <code>version</code>
|
||||
* identifies the WS-Addressing version and the header returned is targeted at
|
||||
* the current implicit role. Caches the value for subsequent invocation.
|
||||
* Duplicate <code>MessageID</code> headers are detected earlier.
|
||||
*
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @throws WebServiceException if either <code>av</code> or <code>sv</code> is null.
|
||||
* @return Value of WS-Addressing MessageID header, null if no header is present
|
||||
*/
|
||||
public String getMessageID(@NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
return AddressingUtils.getMessageID(this, av, sv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of WS-Addressing <code>RelatesTo</code> header. The <code>version</code>
|
||||
* identifies the WS-Addressing version and the header returned is targeted at
|
||||
* the current implicit role. Caches the value for subsequent invocation.
|
||||
* Duplicate <code>RelatesTo</code> headers are detected earlier.
|
||||
*
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @throws WebServiceException if either <code>av</code> or <code>sv</code> is null.
|
||||
* @return Value of WS-Addressing RelatesTo header, null if no header is present
|
||||
*/
|
||||
public String getRelatesTo(@NotNull AddressingVersion av, @NotNull SOAPVersion sv) {
|
||||
return AddressingUtils.getRelatesTo(this, av, sv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a set of outbound WS-Addressing headers on the client with the
|
||||
* specified Action Message Addressing Property value.
|
||||
* <p><p>
|
||||
* This method needs to be invoked right after such a Message is
|
||||
* created which is error prone but so far only MEX, RM and JAX-WS
|
||||
* creates a request so this ugliness is acceptable. This method is also used
|
||||
* to create protocol messages that are not associated with any {@link WSBinding}
|
||||
* and {@link WSDLPort}.
|
||||
*
|
||||
* @param packet request packet
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @param oneway Indicates if the message exchange pattern is oneway
|
||||
* @param action Action Message Addressing Property value
|
||||
* @param mustUnderstand to indicate if the addressing headers are set with mustUnderstand attribute
|
||||
*/
|
||||
public void fillRequestAddressingHeaders(Packet packet, AddressingVersion av, SOAPVersion sv, boolean oneway, String action, boolean mustUnderstand) {
|
||||
AddressingUtils.fillRequestAddressingHeaders(this, packet, av, sv, oneway, action, mustUnderstand);
|
||||
}
|
||||
|
||||
public void fillRequestAddressingHeaders(Packet packet, AddressingVersion av, SOAPVersion sv, boolean oneway, String action) {
|
||||
AddressingUtils.fillRequestAddressingHeaders(this, packet, av, sv, oneway, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a set of outbound WS-Addressing headers on the client with the
|
||||
* default Action Message Addressing Property value.
|
||||
* <p><p>
|
||||
* This method needs to be invoked right after such a Message is
|
||||
* created which is error prone but so far only MEX, RM and JAX-WS
|
||||
* creates a request so this ugliness is acceptable. If more components
|
||||
* are identified using this, then we may revisit this.
|
||||
* <p><p>
|
||||
* This method is used if default Action Message Addressing Property is to
|
||||
* be used. See
|
||||
* {@link #fillRequestAddressingHeaders(Packet, com.sun.xml.internal.ws.api.addressing.AddressingVersion, com.sun.xml.internal.ws.api.SOAPVersion, boolean, String)}
|
||||
* if non-default Action is to be used, for example when creating a protocol message not
|
||||
* associated with {@link WSBinding} and {@link WSDLPort}.
|
||||
* This method uses SOAPAction as the Action unless set expplicitly in the wsdl.
|
||||
* @param wsdlPort request WSDL port
|
||||
* @param binding request WSBinding
|
||||
* @param packet request packet
|
||||
*/
|
||||
public void fillRequestAddressingHeaders(WSDLPort wsdlPort, @NotNull WSBinding binding, Packet packet) {
|
||||
AddressingUtils.fillRequestAddressingHeaders(this, wsdlPort, binding, packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new {@link Header}.
|
||||
*
|
||||
* <p>
|
||||
* Order doesn't matter in headers, so this method
|
||||
* does not make any guarantee as to where the new header
|
||||
* is inserted.
|
||||
*
|
||||
* @return
|
||||
* always true. Don't use the return value.
|
||||
*/
|
||||
@Override
|
||||
public boolean add(Header header) {
|
||||
return super.add(header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the first {@link Header} of the specified name.
|
||||
* @param nsUri namespace URI of the header to remove
|
||||
* @param localName local part of the FQN of the header to remove
|
||||
*
|
||||
* @return null if not found.
|
||||
*/
|
||||
public
|
||||
@Nullable
|
||||
@Override
|
||||
Header remove(@NotNull String nsUri, @NotNull String localName) {
|
||||
int len = size();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Header h = get(i);
|
||||
if (h.getLocalPart().equals(localName) && h.getNamespaceURI().equals(nsUri)) {
|
||||
return remove(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces an existing {@link Header} or adds a new {@link Header}.
|
||||
*
|
||||
* <p>
|
||||
* Order doesn't matter in headers, so this method
|
||||
* does not make any guarantee as to where the new header
|
||||
* is inserted.
|
||||
*
|
||||
* @return
|
||||
* always true. Don't use the return value.
|
||||
*/
|
||||
@Override
|
||||
public boolean addOrReplace(Header header) {
|
||||
for (int i=0; i < size(); i++) {
|
||||
Header hdr = get(i);
|
||||
if (hdr.getNamespaceURI().equals(header.getNamespaceURI()) &&
|
||||
hdr.getLocalPart().equals(header.getLocalPart())) {
|
||||
// Put the new header in the old position. Call super versions
|
||||
// internally to avoid UnsupportedOperationException
|
||||
removeInternal(i);
|
||||
addInternal(i, header);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return add(header);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replace(Header old, Header header) {
|
||||
for (int i=0; i < size(); i++) {
|
||||
Header hdr = get(i);
|
||||
if (hdr.getNamespaceURI().equals(header.getNamespaceURI()) &&
|
||||
hdr.getLocalPart().equals(header.getLocalPart())) {
|
||||
// Put the new header in the old position. Call super versions
|
||||
// internally to avoid UnsupportedOperationException
|
||||
removeInternal(i);
|
||||
addInternal(i, header);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
protected void addInternal(int index, Header header) {
|
||||
super.add(index, header);
|
||||
}
|
||||
|
||||
protected Header removeInternal(int index) {
|
||||
return super.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the first {@link Header} of the specified name.
|
||||
*
|
||||
* @param name fully qualified name of the header to remove
|
||||
*
|
||||
* @return null if not found.
|
||||
*/
|
||||
public
|
||||
@Nullable
|
||||
@Override
|
||||
Header remove(@NotNull QName name) {
|
||||
return remove(name.getNamespaceURI(), name.getLocalPart());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the first {@link Header} of the specified name.
|
||||
*
|
||||
* @param index index of the header to remove
|
||||
*
|
||||
* @return removed header
|
||||
*/
|
||||
@Override
|
||||
public Header remove(int index) {
|
||||
removeUnderstoodBit(index);
|
||||
return super.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the "understood" bit for header on the position specified by {@code index} parameter
|
||||
* from the set of understood header bits.
|
||||
*
|
||||
* @param index position of the bit to remove
|
||||
*/
|
||||
private void removeUnderstoodBit(int index) {
|
||||
assert index < size();
|
||||
|
||||
if (index < 32) {
|
||||
/**
|
||||
* Let
|
||||
* R be the bit to be removed
|
||||
* M be a more significant "upper" bit than bit R
|
||||
* L be a less significant "lower" bit than bit R
|
||||
*
|
||||
* Then following 3 lines of code produce these results:
|
||||
*
|
||||
* old understoodBits = MMMMMMMMMMMMRLLLLLLLLLLLLLLLLLLL
|
||||
*
|
||||
* shiftedUpperBits = 0MMMMMMMMMMMM0000000000000000000
|
||||
*
|
||||
* lowerBits = 0000000000000LLLLLLLLLLLLLLLLLLL
|
||||
*
|
||||
* new understoodBits = 0MMMMMMMMMMMMLLLLLLLLLLLLLLLLLLL
|
||||
*
|
||||
* The R bit is removed and all the upper bits are shifted right (unsigned)
|
||||
*/
|
||||
int shiftedUpperBits = understoodBits >>> -31 + index << index;
|
||||
int lowerBits = understoodBits << -index >>> 31 - index >>> 1;
|
||||
understoodBits = shiftedUpperBits | lowerBits;
|
||||
|
||||
if (moreUnderstoodBits != null && moreUnderstoodBits.cardinality() > 0) {
|
||||
if (moreUnderstoodBits.get(0)) {
|
||||
understoodBits |= 0x80000000;
|
||||
}
|
||||
|
||||
moreUnderstoodBits.clear(0);
|
||||
for (int i = moreUnderstoodBits.nextSetBit(1); i > 0; i = moreUnderstoodBits.nextSetBit(i + 1)) {
|
||||
moreUnderstoodBits.set(i - 1);
|
||||
moreUnderstoodBits.clear(i);
|
||||
}
|
||||
}
|
||||
} else if (moreUnderstoodBits != null && moreUnderstoodBits.cardinality() > 0) {
|
||||
index -= 32;
|
||||
moreUnderstoodBits.clear(index);
|
||||
for (int i = moreUnderstoodBits.nextSetBit(index); i >= 1; i = moreUnderstoodBits.nextSetBit(i + 1)) {
|
||||
moreUnderstoodBits.set(i - 1);
|
||||
moreUnderstoodBits.clear(i);
|
||||
}
|
||||
}
|
||||
|
||||
// remove bit set if the new size will be < 33 => we fit all bits into int
|
||||
if (size() - 1 <= 33 && moreUnderstoodBits != null) {
|
||||
moreUnderstoodBits = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a single instance of the specified element from this
|
||||
* header list, if it is present. More formally,
|
||||
* removes a header <tt>h</tt> such that <tt>(o==null ? h==null :
|
||||
* o.equals(h))</tt>, if the header list contains one or more such
|
||||
* headers. Returns <tt>true</tt> if the list contained the
|
||||
* specified element (or equivalently, if the list changed as a
|
||||
* result of the call).<p>
|
||||
*
|
||||
* @param o element to be removed from this list, if present.
|
||||
* @return <tt>true</tt> if the list contained the specified element.
|
||||
* @see #remove(javax.xml.namespace.QName)
|
||||
*/
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
if (o != null) {
|
||||
for (int index = 0; index < this.size(); index++) {
|
||||
if (o.equals(this.get(index))) {
|
||||
remove(index);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Header remove(Header h) {
|
||||
if (remove((Object) h)) {
|
||||
return h;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy.
|
||||
*
|
||||
* This handles null {@link HeaderList} correctly.
|
||||
*
|
||||
* @param original
|
||||
* Can be null, in which case null will be returned.
|
||||
*/
|
||||
public static HeaderList copy(MessageHeaders original) {
|
||||
if (original == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new HeaderList(original);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy.
|
||||
*
|
||||
* This handles null {@link HeaderList} correctly.
|
||||
*
|
||||
* @param original
|
||||
* Can be null, in which case null will be returned.
|
||||
*/
|
||||
public static HeaderList copy(HeaderList original) {
|
||||
return copy((MessageHeaders) original);
|
||||
}
|
||||
|
||||
public void readResponseAddressingHeaders(WSDLPort wsdlPort, WSBinding binding) {
|
||||
// read Action
|
||||
// String wsaAction = getAction(binding.getAddressingVersion(), binding.getSOAPVersion());
|
||||
// TODO: validate client-inbound Action
|
||||
}
|
||||
|
||||
@Override
|
||||
public void understood(QName name) {
|
||||
get(name, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void understood(String nsUri, String localName) {
|
||||
get(nsUri, localName, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<QName> getUnderstoodHeaders() {
|
||||
Set<QName> understoodHdrs = new HashSet<QName>();
|
||||
for (int i = 0; i < size(); i++) {
|
||||
if (isUnderstood(i)) {
|
||||
Header header = get(i);
|
||||
understoodHdrs.add(new QName(header.getNamespaceURI(), header.getLocalPart()));
|
||||
}
|
||||
}
|
||||
return understoodHdrs;
|
||||
// throw new UnsupportedOperationException("getUnderstoodHeaders() is not implemented by HeaderList");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderstood(Header header) {
|
||||
return isUnderstood(header.getNamespaceURI(), header.getLocalPart());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderstood(String nsUri, String localName) {
|
||||
for (int i = 0; i < size(); i++) {
|
||||
Header h = get(i);
|
||||
if (h.getLocalPart().equals(localName) && h.getNamespaceURI().equals(nsUri)) {
|
||||
return isUnderstood(i);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnderstood(QName name) {
|
||||
return isUnderstood(name.getNamespaceURI(), name.getLocalPart());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<QName> getNotUnderstoodHeaders(Set<String> roles, Set<QName> knownHeaders, WSBinding binding) {
|
||||
Set<QName> notUnderstoodHeaders = null;
|
||||
if (roles == null) {
|
||||
roles = new HashSet<String>();
|
||||
}
|
||||
SOAPVersion effectiveSoapVersion = getEffectiveSOAPVersion(binding);
|
||||
roles.add(effectiveSoapVersion.implicitRole);
|
||||
for (int i = 0; i < size(); i++) {
|
||||
if (!isUnderstood(i)) {
|
||||
Header header = get(i);
|
||||
if (!header.isIgnorable(effectiveSoapVersion, roles)) {
|
||||
QName qName = new QName(header.getNamespaceURI(), header.getLocalPart());
|
||||
if (binding == null) {
|
||||
//if binding is null, no further checks needed...we already
|
||||
//know this header is not understood from the isUnderstood
|
||||
//check above
|
||||
if (notUnderstoodHeaders == null) {
|
||||
notUnderstoodHeaders = new HashSet<QName>();
|
||||
}
|
||||
notUnderstoodHeaders.add(qName);
|
||||
} else {
|
||||
// if the binding is not null, see if the binding can understand it
|
||||
if (binding instanceof SOAPBindingImpl && !((SOAPBindingImpl) binding).understandsHeader(qName)) {
|
||||
if (!knownHeaders.contains(qName)) {
|
||||
//logger.info("Element not understood=" + qName);
|
||||
if (notUnderstoodHeaders == null) {
|
||||
notUnderstoodHeaders = new HashSet<QName>();
|
||||
}
|
||||
notUnderstoodHeaders.add(qName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return notUnderstoodHeaders;
|
||||
}
|
||||
|
||||
private SOAPVersion getEffectiveSOAPVersion(WSBinding binding) {
|
||||
SOAPVersion mySOAPVersion = (soapVersion != null) ? soapVersion : binding.getSOAPVersion();
|
||||
if (mySOAPVersion == null) {
|
||||
mySOAPVersion = SOAPVersion.SOAP_11;
|
||||
}
|
||||
return mySOAPVersion;
|
||||
}
|
||||
|
||||
public void setSoapVersion(SOAPVersion soapVersion) {
|
||||
this.soapVersion = soapVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Header> getHeaders() {
|
||||
return iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Header> asList() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
185
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Headers.java
Normal file
185
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Headers.java
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.xml.internal.bind.api.Bridge;
|
||||
import com.sun.xml.internal.bind.api.JAXBRIContext;
|
||||
import com.sun.xml.internal.bind.v2.runtime.MarshallerImpl;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.pipe.Pipe;
|
||||
import com.sun.xml.internal.ws.message.DOMHeader;
|
||||
import com.sun.xml.internal.ws.message.StringHeader;
|
||||
import com.sun.xml.internal.ws.message.jaxb.JAXBHeader;
|
||||
import com.sun.xml.internal.ws.message.saaj.SAAJHeader;
|
||||
import com.sun.xml.internal.ws.message.stream.StreamHeader11;
|
||||
import com.sun.xml.internal.ws.message.stream.StreamHeader12;
|
||||
import com.sun.xml.internal.ws.spi.db.BindingContext;
|
||||
import com.sun.xml.internal.ws.spi.db.BindingContextFactory;
|
||||
import com.sun.xml.internal.ws.spi.db.XMLBridge;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.SOAPHeaderElement;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
|
||||
/**
|
||||
* Factory methods for various {@link Header} implementations.
|
||||
*
|
||||
* <p>
|
||||
* This class provides various methods to create different
|
||||
* flavors of {@link Header} classes that store data
|
||||
* in different formats.
|
||||
*
|
||||
* <p>
|
||||
* This is a part of the JAX-WS RI internal API so that
|
||||
* {@link Pipe} implementations can reuse the implementations
|
||||
* done inside the JAX-WS without having a strong dependency
|
||||
* to the actual class.
|
||||
*
|
||||
* <p>
|
||||
* If you find some of the useful convenience methods missing
|
||||
* from this class, please talk to us.
|
||||
*
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class Headers {
|
||||
private Headers() {}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #create(BindingContext, Object)} instead.
|
||||
*/
|
||||
public static Header create(SOAPVersion soapVersion, Marshaller m, Object o) {
|
||||
return new JAXBHeader(BindingContextFactory.getBindingContext(m),o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Header} backed a by a JAXB bean.
|
||||
*/
|
||||
public static Header create(JAXBContext context, Object o) {
|
||||
return new JAXBHeader(BindingContextFactory.create(context),o);
|
||||
}
|
||||
|
||||
public static Header create(BindingContext context, Object o) {
|
||||
return new JAXBHeader(context,o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Header} backed a by a JAXB bean, with the given tag name.
|
||||
*
|
||||
* See {@link #create(SOAPVersion, Marshaller, Object)} for the meaning
|
||||
* of other parameters.
|
||||
*
|
||||
* @param tagName
|
||||
* The name of the newly created header. Must not be null.
|
||||
* @param o
|
||||
* The JAXB bean that represents the contents of the header. Must not be null.
|
||||
*/
|
||||
public static Header create(SOAPVersion soapVersion, Marshaller m, QName tagName, Object o) {
|
||||
return create(soapVersion,m,new JAXBElement(tagName,o.getClass(),o));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Header} backed a by a JAXB bean.
|
||||
* @deprecated
|
||||
*/
|
||||
public static Header create(Bridge bridge, Object jaxbObject) {
|
||||
return new JAXBHeader(new com.sun.xml.internal.ws.db.glassfish.BridgeWrapper(null,bridge), jaxbObject);
|
||||
}
|
||||
|
||||
public static Header create(XMLBridge bridge, Object jaxbObject) {
|
||||
return new JAXBHeader(bridge, jaxbObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Header} backed by a SAAJ object.
|
||||
*/
|
||||
public static Header create(SOAPHeaderElement header) {
|
||||
return new SAAJHeader(header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Header} backed by an {@link Element}.
|
||||
*/
|
||||
public static Header create( Element node ) {
|
||||
return new DOMHeader<Element>(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use {@link #create(Element)}
|
||||
*/
|
||||
public static Header create( SOAPVersion soapVersion, Element node ) {
|
||||
return create(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Header} that reads from {@link XMLStreamReader}.
|
||||
*
|
||||
* <p>
|
||||
* Note that the header implementation will read the entire data
|
||||
* into memory anyway, so this might not be as efficient as you might hope.
|
||||
*/
|
||||
public static Header create( SOAPVersion soapVersion, XMLStreamReader reader ) throws XMLStreamException {
|
||||
switch(soapVersion) {
|
||||
case SOAP_11:
|
||||
return new StreamHeader11(reader);
|
||||
case SOAP_12:
|
||||
return new StreamHeader12(reader);
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Header} that that has a single text value in it
|
||||
* (IOW, of the form <foo>text</foo>.)
|
||||
*
|
||||
* @param name QName of the header element
|
||||
* @param value text value of the header
|
||||
*/
|
||||
public static Header create(QName name, String value) {
|
||||
return new StringHeader(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Header} that that has a single text value in it
|
||||
* (IOW, of the form <foo>text</foo>.)
|
||||
*
|
||||
* @param name QName of the header element
|
||||
* @param value text value of the header
|
||||
*/
|
||||
public static Header createMustUnderstand(@NotNull SOAPVersion soapVersion, @NotNull QName name,@NotNull String value) {
|
||||
return new StringHeader(name, value,soapVersion,true);
|
||||
}
|
||||
}
|
||||
789
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Message.java
Normal file
789
jdkSrc/jdk8/com/sun/xml/internal/ws/api/message/Message.java
Normal file
@@ -0,0 +1,789 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.message;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.bind.api.Bridge;
|
||||
import com.sun.xml.internal.ws.api.BindingID;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
||||
import com.sun.xml.internal.ws.api.model.JavaMethod;
|
||||
import com.sun.xml.internal.ws.api.model.SEIModel;
|
||||
import com.sun.xml.internal.ws.api.model.WSDLOperationMapping;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundPortType;
|
||||
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.api.pipe.Pipe;
|
||||
import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory;
|
||||
import com.sun.xml.internal.ws.client.dispatch.DispatchImpl;
|
||||
import com.sun.xml.internal.ws.message.AttachmentSetImpl;
|
||||
import com.sun.xml.internal.ws.message.StringHeader;
|
||||
import com.sun.xml.internal.ws.message.jaxb.JAXBMessage;
|
||||
import com.sun.xml.internal.ws.spi.db.XMLBridge;
|
||||
import com.sun.xml.internal.ws.fault.SOAPFaultBuilder;
|
||||
import com.sun.xml.internal.org.jvnet.staxex.XMLStreamReaderEx;
|
||||
import com.sun.xml.internal.org.jvnet.staxex.XMLStreamWriterEx;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.soap.MimeHeaders;
|
||||
import javax.xml.soap.SOAPException;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.ws.Dispatch;
|
||||
import javax.xml.ws.WebServiceException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents a SOAP message.
|
||||
*
|
||||
*
|
||||
* <h2>What is a message?</h2>
|
||||
* <p>
|
||||
* A {@link Message} consists of the following:
|
||||
*
|
||||
* <ol>
|
||||
* <li>
|
||||
* Random-accessible list of headers.
|
||||
* a header is a representation of an element inside
|
||||
* <soap:Header>.
|
||||
* It can be read multiple times,
|
||||
* can be added or removed, but it is not modifiable.
|
||||
* See {@link HeaderList} for more about headers.
|
||||
*
|
||||
* <li>
|
||||
* The payload of the message, which is a representation
|
||||
* of an element inside <soap:Body>.
|
||||
* the payload is streamed, and therefore it can be
|
||||
* only read once (or can be only written to something once.)
|
||||
* once a payload is used, a message is said to be <b>consumed</b>.
|
||||
* A message {@link #hasPayload() may not have any payload.}
|
||||
*
|
||||
* <li>
|
||||
* Attachments.
|
||||
* TODO: can attachments be streamed? I suspect so.
|
||||
* does anyone need to read attachment twice?
|
||||
*
|
||||
* </ol>
|
||||
*
|
||||
*
|
||||
* <h2>How does this abstraction work?</h2>
|
||||
* <p>
|
||||
* The basic idea behind the {@link Message} is to hide the actual
|
||||
* data representation. For example, a {@link Message} might be
|
||||
* constructed on top of an {@link InputStream} from the accepted HTTP connection,
|
||||
* or it might be constructed on top of a JAXB object as a result
|
||||
* of the method invocation through {@link Proxy}. There will be
|
||||
* a {@link Message} implementation for each of those cases.
|
||||
*
|
||||
* <p>
|
||||
* This interface provides a lot of methods that access the payload
|
||||
* in many different forms, and implementations can implement those
|
||||
* methods in the best possible way.
|
||||
*
|
||||
* <p>
|
||||
* A particular attention is paid to make sure that a {@link Message}
|
||||
* object can be constructed on a stream that is not fully read yet.
|
||||
* We believe this improves the turn-around time on the server side.
|
||||
*
|
||||
* <p>
|
||||
* It is often useful to wrap a {@link Message} into another {@link Message},
|
||||
* for example to encrypt the body, or to verify the signature as the body
|
||||
* is read.
|
||||
*
|
||||
* <p>
|
||||
* This representation is also used for a REST-ful XML message.
|
||||
* In such case we'll construct a {@link Message} with empty
|
||||
* attachments and headers, and when serializing all headers
|
||||
* and attachments will be ignored.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <h2>Message and XOP</h2>
|
||||
* <p>
|
||||
* XOP is considered as an {@link Codec}, and therefore when you are looking at
|
||||
* {@link Message}, you'll never see <xop:Include> or any such elements
|
||||
* (instead you'll see the base64 data inlined.) If a consumer of infoset isn't
|
||||
* interested in handling XOP by himself, this allows him to work with XOP
|
||||
* correctly even without noticing it.
|
||||
*
|
||||
* <p>
|
||||
* For producers and consumers that are interested in accessing the binary data
|
||||
* more efficiently, they can use {@link XMLStreamReaderEx} and
|
||||
* {@link XMLStreamWriterEx}.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <h2>Message lifespan</h2>
|
||||
* <p>
|
||||
* Often {@link Packet} include information local to a particular
|
||||
* invocaion (such as {@code HttpServletRequest}, from this angle, it makes sense
|
||||
* to tie a lifespan of a message to one pipeline invocation.
|
||||
* <p>
|
||||
* On the other hand, if you think about WS-RM, it often needs to hold on to
|
||||
* a message longer than a pipeline invocation (you might get an HTTP request,
|
||||
* get a message X, get a second HTTP request, get another message Y, and
|
||||
* only then you might want to process X.)
|
||||
* <p>
|
||||
* TODO: what do we do about this?
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* TODO: can body element have foreign attributes? maybe ID for security?
|
||||
* Yes, when the SOAP body is signed there will be an ID attribute present
|
||||
* But in this case any security based impl may need access
|
||||
* to the concrete representation.
|
||||
* TODO: HTTP headers?
|
||||
* Yes. Abstracted as transport-based properties.
|
||||
* TODO: who handles SOAP 1.1 and SOAP 1.2 difference?
|
||||
* As separate channel implementations responsible for the creation of the
|
||||
* message?
|
||||
* TODO: session?
|
||||
* TODO: Do we need to expose SOAPMessage explicitly?
|
||||
* SOAPMessage could be the concrete representation but is it necessary to
|
||||
* transform between different concrete representations?
|
||||
* Perhaps this comes down to how use channels for creation and processing.
|
||||
* TODO: Do we need to distinguish better between creation and processing?
|
||||
* Do we really need the requirement that a created message can be resused
|
||||
* for processing. Shall we bifurcate?
|
||||
*
|
||||
* TODO: SOAP version issue
|
||||
* SOAP version is determined by the context, so message itself doesn't carry it around (?)
|
||||
*
|
||||
* TODO: wrapping message needs easier. in particular properties and attachments.
|
||||
* </pre>
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class Message {
|
||||
|
||||
/**
|
||||
* Returns true if headers are present in the message.
|
||||
*
|
||||
* @return
|
||||
* true if headers are present.
|
||||
*/
|
||||
public abstract boolean hasHeaders();
|
||||
|
||||
/**
|
||||
* Gets all the headers of this message.
|
||||
*
|
||||
* <h3>Implementation Note</h3>
|
||||
* <p>
|
||||
* {@link Message} implementation is allowed to defer
|
||||
* the construction of {@link MessageHeaders} object. So
|
||||
* if you only want to check for the existence of any header
|
||||
* element, use {@link #hasHeaders()}.
|
||||
*
|
||||
* @return
|
||||
* always return the same non-null object.
|
||||
*/
|
||||
public abstract @NotNull MessageHeaders getHeaders();
|
||||
|
||||
/**
|
||||
* Gets the attachments of this message
|
||||
* (attachments live outside a message.)
|
||||
*/
|
||||
public @NotNull AttachmentSet getAttachments() {
|
||||
if (attachmentSet == null) {
|
||||
attachmentSet = new AttachmentSetImpl();
|
||||
}
|
||||
return attachmentSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimization hint for the derived class to check
|
||||
* if we may have some attachments.
|
||||
*/
|
||||
protected boolean hasAttachments() {
|
||||
return attachmentSet!=null;
|
||||
}
|
||||
|
||||
protected AttachmentSet attachmentSet;
|
||||
|
||||
private WSDLBoundOperation operation = null;
|
||||
|
||||
private WSDLOperationMapping wsdlOperationMapping = null;
|
||||
|
||||
private MessageMetadata messageMetadata = null;
|
||||
|
||||
public void setMessageMedadata(MessageMetadata metadata) {
|
||||
messageMetadata = metadata;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the operation of which this message is an instance of.
|
||||
*
|
||||
* <p>
|
||||
* This method relies on {@link WSDLBoundPortType#getOperation(String, String)} but
|
||||
* it does so in an efficient way.
|
||||
*
|
||||
* @deprecated It is not always possible to uniquely identify the WSDL Operation from just the
|
||||
* information in the Message. Instead, Use {@link com.sun.xml.internal.ws.api.message.Packet#getWSDLOperation()}
|
||||
* to get it correctly.
|
||||
*
|
||||
* <p>
|
||||
* This method works only for a request. A pipe can determine an operation for a request,
|
||||
* and then keep it in a local variable to use it with a response, so there should be
|
||||
* no need to find out operation from a response (besides, there might not be any response!).
|
||||
*
|
||||
* @param boundPortType
|
||||
* This represents the port for which this message is used.
|
||||
* Most {@link Pipe}s should get this information when they are created,
|
||||
* since a pippeline always work against a particular type of {@link WSDLPort}.
|
||||
*
|
||||
* @return
|
||||
* Null if the operation was not found. This is possible, for example when a protocol
|
||||
* message is sent through a pipeline, or when we receive an invalid request on the server,
|
||||
* or when we are on the client and the user appliation sends a random DOM through
|
||||
* {@link Dispatch}, so this error needs to be handled gracefully.
|
||||
*/
|
||||
@Deprecated
|
||||
public final @Nullable WSDLBoundOperation getOperation(@NotNull WSDLBoundPortType boundPortType) {
|
||||
if (operation == null && messageMetadata != null) {
|
||||
if (wsdlOperationMapping == null) wsdlOperationMapping = messageMetadata.getWSDLOperationMapping();
|
||||
if (wsdlOperationMapping != null) operation = wsdlOperationMapping.getWSDLBoundOperation();
|
||||
}
|
||||
if(operation==null)
|
||||
operation = boundPortType.getOperation(getPayloadNamespaceURI(),getPayloadLocalPart());
|
||||
return operation;
|
||||
}
|
||||
|
||||
/**
|
||||
* The same as {@link #getOperation(WSDLBoundPortType)} but
|
||||
* takes {@link WSDLPort} for convenience.
|
||||
*
|
||||
* @deprecated It is not always possible to uniquely identify the WSDL Operation from just the
|
||||
* information in the Message. Instead, Use {@link com.sun.xml.internal.ws.api.message.Packet#getWSDLOperation()}
|
||||
* to get it correctly.
|
||||
*/
|
||||
@Deprecated
|
||||
public final @Nullable WSDLBoundOperation getOperation(@NotNull WSDLPort port) {
|
||||
return getOperation(port.getBinding());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the java Method of which this message is an instance of.
|
||||
*
|
||||
* It is not always possible to uniquely identify the WSDL Operation from just the
|
||||
* information in the Message. Instead, Use {@link com.sun.xml.internal.ws.api.message.Packet#getWSDLOperation()}
|
||||
* to get the QName of the associated wsdl operation correctly.
|
||||
*
|
||||
* <p>
|
||||
* This method works only for a request. A pipe can determine a {@link Method}
|
||||
* for a request, and then keep it in a local variable to use it with a response,
|
||||
* so there should be no need to find out operation from a response (besides,
|
||||
* there might not be any response!).
|
||||
*
|
||||
* @param seiModel
|
||||
* This represents the java model for the endpoint
|
||||
* Some server {@link Pipe}s would get this information when they are created.
|
||||
*
|
||||
* @return
|
||||
* Null if there is no corresponding Method for this message. This is
|
||||
* possible, for example when a protocol message is sent through a
|
||||
* pipeline, or when we receive an invalid request on the server,
|
||||
* or when we are on the client and the user appliation sends a random
|
||||
* DOM through {@link Dispatch}, so this error needs to be handled
|
||||
* gracefully.
|
||||
*/
|
||||
@Deprecated
|
||||
public final @Nullable JavaMethod getMethod(@NotNull SEIModel seiModel) {
|
||||
if (wsdlOperationMapping == null && messageMetadata != null) {
|
||||
wsdlOperationMapping = messageMetadata.getWSDLOperationMapping();
|
||||
}
|
||||
if (wsdlOperationMapping != null) {
|
||||
return wsdlOperationMapping.getJavaMethod();
|
||||
}
|
||||
//fall back to the original logic which could be incorrect ...
|
||||
String localPart = getPayloadLocalPart();
|
||||
String nsUri;
|
||||
if (localPart == null) {
|
||||
localPart = "";
|
||||
nsUri = "";
|
||||
} else {
|
||||
nsUri = getPayloadNamespaceURI();
|
||||
}
|
||||
QName name = new QName(nsUri, localPart);
|
||||
return seiModel.getJavaMethod(name);
|
||||
}
|
||||
|
||||
private Boolean isOneWay;
|
||||
|
||||
/**
|
||||
* Returns true if this message is a request message for a
|
||||
* one way operation according to the given WSDL. False otherwise.
|
||||
*
|
||||
* <p>
|
||||
* This method is functionally equivalent as doing
|
||||
* {@code getOperation(port).getOperation().isOneWay()}
|
||||
* (with proper null check and all.) But this method
|
||||
* can sometimes work faster than that (for example,
|
||||
* on the client side when used with SEI.)
|
||||
*
|
||||
* @param port
|
||||
* {@link Message}s are always created under the context of
|
||||
* one {@link WSDLPort} and they never go outside that context.
|
||||
* Pass in that "governing" {@link WSDLPort} object here.
|
||||
* We chose to receive this as a parameter instead of
|
||||
* keeping {@link WSDLPort} in a message, just to save the storage.
|
||||
*
|
||||
* <p>
|
||||
* The implementation of this method involves caching the return
|
||||
* value, so the behavior is undefined if multiple callers provide
|
||||
* different {@link WSDLPort} objects, which is a bug of the caller.
|
||||
*/
|
||||
public boolean isOneWay(@NotNull WSDLPort port) {
|
||||
if(isOneWay==null) {
|
||||
// we don't know, so compute.
|
||||
WSDLBoundOperation op = getOperation(port);
|
||||
if(op!=null)
|
||||
isOneWay = op.getOperation().isOneWay();
|
||||
else
|
||||
// the contract is to return true only when it's known to be one way.
|
||||
isOneWay = false;
|
||||
}
|
||||
return isOneWay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an assertion that this {@link Message} is
|
||||
* a request message for an one-way operation according
|
||||
* to the context WSDL.
|
||||
*
|
||||
* <p>
|
||||
* This method is really only intended to be invoked from within
|
||||
* the JAX-WS runtime, and not by any code building on top of it.
|
||||
*
|
||||
* <p>
|
||||
* This method can be invoked only when the caller "knows" what
|
||||
* WSDL says. Also, there's no point in invoking this method if the caller
|
||||
* is doing {@code getOperation(port).getOperation().isOneWay()},
|
||||
* or sniffing the payload tag name.
|
||||
* In particular, this includes {@link DispatchImpl}.
|
||||
*
|
||||
* <p>
|
||||
* Once called, this allows {@link #isOneWay(WSDLPort)} method
|
||||
* to return a value quickly.
|
||||
*
|
||||
* @see #isOneWay(WSDLPort)
|
||||
*/
|
||||
public final void assertOneWay(boolean value) {
|
||||
// if two callers make different assertions, that's a bug.
|
||||
// this is an assertion, not a runtime check because
|
||||
// nobody outside JAX-WS should be using this.
|
||||
assert isOneWay==null || isOneWay==value;
|
||||
|
||||
isOneWay = value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the local name of the payload element.
|
||||
*
|
||||
* @return
|
||||
* null if a {@link Message} doesn't have any payload.
|
||||
*/
|
||||
public abstract @Nullable String getPayloadLocalPart();
|
||||
|
||||
/**
|
||||
* Gets the namespace URI of the payload element.
|
||||
*
|
||||
* @return
|
||||
* null if a {@link Message} doesn't have any payload.
|
||||
*/
|
||||
public abstract String getPayloadNamespaceURI();
|
||||
// I'm not putting @Nullable on it because doing null check on getPayloadLocalPart() should be suffice
|
||||
|
||||
/**
|
||||
* Returns true if a {@link Message} has a payload.
|
||||
*
|
||||
* <p>
|
||||
* A message without a payload is a SOAP message that looks like:
|
||||
* <pre><xmp>
|
||||
* <S:Envelope>
|
||||
* <S:Header>
|
||||
* ...
|
||||
* </S:Header>
|
||||
* <S:Body />
|
||||
* </S:Envelope>
|
||||
* </xmp></pre>
|
||||
*/
|
||||
public abstract boolean hasPayload();
|
||||
|
||||
/**
|
||||
* Returns true if this message is a fault.
|
||||
*
|
||||
* <p>
|
||||
* Just a convenience method built on {@link #getPayloadNamespaceURI()}
|
||||
* and {@link #getPayloadLocalPart()}.
|
||||
*/
|
||||
public boolean isFault() {
|
||||
// TODO: is SOAP version a property of a Message?
|
||||
// or is it defined by external factors?
|
||||
// how do I compare?
|
||||
String localPart = getPayloadLocalPart();
|
||||
if(localPart==null || !localPart.equals("Fault"))
|
||||
return false;
|
||||
|
||||
String nsUri = getPayloadNamespaceURI();
|
||||
return nsUri.equals(SOAPVersion.SOAP_11.nsUri) || nsUri.equals(SOAPVersion.SOAP_12.nsUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* It gives S:Envelope/S:Body/S:Fault/detail 's first child's name. Should
|
||||
* be called for messages that have SOAP Fault.
|
||||
*
|
||||
* <p> This implementation is expensive so concrete implementations are
|
||||
* expected to override this one.
|
||||
*
|
||||
* @return first detail entry's name, if there is one
|
||||
* else null
|
||||
*/
|
||||
public @Nullable QName getFirstDetailEntryName() {
|
||||
assert isFault();
|
||||
Message msg = copy();
|
||||
try {
|
||||
SOAPFaultBuilder fault = SOAPFaultBuilder.create(msg);
|
||||
return fault.getFirstDetailEntryName();
|
||||
} catch (JAXBException e) {
|
||||
throw new WebServiceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Consumes this message including the envelope.
|
||||
* returns it as a {@link Source} object.
|
||||
*/
|
||||
public abstract Source readEnvelopeAsSource();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the payload as a {@link Source} object.
|
||||
*
|
||||
* This consumes the message.
|
||||
*
|
||||
* @return
|
||||
* if there's no payload, this method returns null.
|
||||
*/
|
||||
public abstract Source readPayloadAsSource();
|
||||
|
||||
/**
|
||||
* Creates the equivalent {@link SOAPMessage} from this message.
|
||||
*
|
||||
* This consumes the message.
|
||||
*
|
||||
* @throws SOAPException
|
||||
* if there's any error while creating a {@link SOAPMessage}.
|
||||
*/
|
||||
public abstract SOAPMessage readAsSOAPMessage() throws SOAPException;
|
||||
|
||||
/**
|
||||
* Creates the equivalent {@link SOAPMessage} from this message. It also uses
|
||||
* transport specific headers from Packet during the SOAPMessage construction
|
||||
* so that {@link SOAPMessage#getMimeHeaders()} gives meaningful transport
|
||||
* headers.
|
||||
*
|
||||
* This consumes the message.
|
||||
*
|
||||
* @throws SOAPException
|
||||
* if there's any error while creating a {@link SOAPMessage}.
|
||||
*/
|
||||
public SOAPMessage readAsSOAPMessage(Packet packet, boolean inbound) throws SOAPException {
|
||||
return readAsSOAPMessage();
|
||||
}
|
||||
|
||||
public static Map<String, List<String>> getTransportHeaders(Packet packet) {
|
||||
return getTransportHeaders(packet, packet.getState().isInbound());
|
||||
}
|
||||
|
||||
public static Map<String, List<String>> getTransportHeaders(Packet packet, boolean inbound) {
|
||||
Map<String, List<String>> headers = null;
|
||||
String key = inbound ? Packet.INBOUND_TRANSPORT_HEADERS : Packet.OUTBOUND_TRANSPORT_HEADERS;
|
||||
if (packet.supports(key)) {
|
||||
headers = (Map<String, List<String>>)packet.get(key);
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
public static void addSOAPMimeHeaders(MimeHeaders mh, Map<String, List<String>> headers) {
|
||||
for(Map.Entry<String, List<String>> e : headers.entrySet()) {
|
||||
if (!e.getKey().equalsIgnoreCase("Content-Type")) {
|
||||
for(String value : e.getValue()) {
|
||||
mh.addHeader(e.getKey(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Reads the payload as a JAXB object by using the given unmarshaller.
|
||||
*
|
||||
* This consumes the message.
|
||||
*
|
||||
* @throws JAXBException
|
||||
* If JAXB reports an error during the processing.
|
||||
*/
|
||||
public abstract <T> T readPayloadAsJAXB(Unmarshaller unmarshaller) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Reads the payload as a JAXB object according to the given {@link Bridge}.
|
||||
*
|
||||
* This consumes the message.
|
||||
*
|
||||
* @deprecated
|
||||
* @return null
|
||||
* if there's no payload.
|
||||
* @throws JAXBException
|
||||
* If JAXB reports an error during the processing.
|
||||
*/
|
||||
public abstract <T> T readPayloadAsJAXB(Bridge<T> bridge) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Reads the payload as a Data-Bond object
|
||||
*
|
||||
* This consumes the message.
|
||||
*
|
||||
* @return null
|
||||
* if there's no payload.
|
||||
* @throws JAXBException
|
||||
* If JAXB reports an error during the processing.
|
||||
*/
|
||||
public abstract <T> T readPayloadAsJAXB(XMLBridge<T> bridge) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Reads the payload as a {@link XMLStreamReader}
|
||||
*
|
||||
* This consumes the message. The caller is encouraged to call
|
||||
* {@link XMLStreamReaderFactory#recycle(XMLStreamReader)} when finished using
|
||||
* the instance.
|
||||
*
|
||||
* @return
|
||||
* If there's no payload, this method returns null.
|
||||
* Otherwise always non-null valid {@link XMLStreamReader} that points to
|
||||
* the payload tag name.
|
||||
*/
|
||||
public abstract XMLStreamReader readPayload() throws XMLStreamException;
|
||||
|
||||
/**
|
||||
* Marks the message as consumed, without actually reading the contents.
|
||||
*
|
||||
* <p>
|
||||
* This method provides an opportunity for implementations to reuse
|
||||
* any reusable resources needed for representing the payload.
|
||||
*
|
||||
* <p>
|
||||
* This method may not be called more than once since it may have
|
||||
* released the reusable resources.
|
||||
*/
|
||||
public void consume() {}
|
||||
|
||||
/**
|
||||
* Writes the payload to StAX.
|
||||
*
|
||||
* This method writes just the payload of the message to the writer.
|
||||
* This consumes the message.
|
||||
* The implementation will not write
|
||||
* {@link XMLStreamWriter#writeStartDocument()}
|
||||
* nor
|
||||
* {@link XMLStreamWriter#writeEndDocument()}
|
||||
*
|
||||
* <p>
|
||||
* If there's no payload, this method is no-op.
|
||||
*
|
||||
* @throws XMLStreamException
|
||||
* If the {@link XMLStreamWriter} reports an error,
|
||||
* or some other errors happen during the processing.
|
||||
*/
|
||||
public abstract void writePayloadTo(XMLStreamWriter sw) throws XMLStreamException;
|
||||
|
||||
/**
|
||||
* Writes the whole SOAP message (but not attachments)
|
||||
* to the given writer.
|
||||
*
|
||||
* This consumes the message.
|
||||
*
|
||||
* @throws XMLStreamException
|
||||
* If the {@link XMLStreamWriter} reports an error,
|
||||
* or some other errors happen during the processing.
|
||||
*/
|
||||
public abstract void writeTo(XMLStreamWriter sw) throws XMLStreamException;
|
||||
|
||||
/**
|
||||
* Writes the whole SOAP envelope as SAX events.
|
||||
*
|
||||
* <p>
|
||||
* This consumes the message.
|
||||
*
|
||||
* @param contentHandler
|
||||
* must not be nulll.
|
||||
* @param errorHandler
|
||||
* must not be null.
|
||||
* any error encountered during the SAX event production must be
|
||||
* first reported to this error handler. Fatal errors can be then
|
||||
* thrown as {@link SAXParseException}. {@link SAXException}s thrown
|
||||
* from {@link ErrorHandler} should propagate directly through this method.
|
||||
*/
|
||||
public abstract void writeTo( ContentHandler contentHandler, ErrorHandler errorHandler ) throws SAXException;
|
||||
|
||||
// TODO: do we need a method that reads payload as a fault?
|
||||
// do we want a separte streaming representation of fault?
|
||||
// or would SOAPFault in SAAJ do?
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates a copy of a {@link Message}.
|
||||
*
|
||||
* <p>
|
||||
* This method creates a new {@link Message} whose header/payload/attachments/properties
|
||||
* are identical to this {@link Message}. Once created, the created {@link Message}
|
||||
* and the original {@link Message} behaves independently --- adding header/
|
||||
* attachment to one {@link Message} doesn't affect another {@link Message}
|
||||
* at all.
|
||||
*
|
||||
* <p>
|
||||
* This method does <b>NOT</b> consume a message.
|
||||
*
|
||||
* <p>
|
||||
* To enable efficient copy operations, there's a few restrictions on
|
||||
* how copied message can be used.
|
||||
*
|
||||
* <ol>
|
||||
* <li>The original and the copy may not be
|
||||
* used concurrently by two threads (this allows two {@link Message}s
|
||||
* to share some internal resources, such as JAXB marshallers.)
|
||||
* Note that it's OK for the original and the copy to be processed
|
||||
* by two threads, as long as they are not concurrent.
|
||||
*
|
||||
* <li>The copy has the same 'life scope'
|
||||
* as the original (this allows shallower copy, such as
|
||||
* JAXB beans wrapped in {@link JAXBMessage}.)
|
||||
* </ol>
|
||||
*
|
||||
* <p>
|
||||
* A 'life scope' of a message created during a message processing
|
||||
* in a pipeline is until a pipeline processes the next message.
|
||||
* A message cannot be kept beyond its life scope.
|
||||
*
|
||||
* (This experimental design is to allow message objects to be reused
|
||||
* --- feedback appreciated.)
|
||||
*
|
||||
*
|
||||
*
|
||||
* <h3>Design Rationale</h3>
|
||||
* <p>
|
||||
* Since a {@link Message} body is read-once, sometimes
|
||||
* (such as when you do fail-over, or WS-RM) you need to
|
||||
* create an idential copy of a {@link Message}.
|
||||
*
|
||||
* <p>
|
||||
* The actual copy operation depends on the layout
|
||||
* of the data in memory, hence it's best to be done by
|
||||
* the {@link Message} implementation itself.
|
||||
*
|
||||
* <p>
|
||||
* The restrictions placed on the use of copied {@link Message} can be
|
||||
* relaxed if necessary, but it will make the copy method more expensive.
|
||||
*/
|
||||
// TODO: update the class javadoc with 'lifescope'
|
||||
// and move the discussion about life scope there.
|
||||
public abstract Message copy();
|
||||
|
||||
/**
|
||||
* Retuns a unique id for the message. The id can be used for various things,
|
||||
* like debug assistance, logging, and MIME encoding(say for boundary).
|
||||
*
|
||||
* <p>
|
||||
* This method will check the existence of the addressing <MessageID> header,
|
||||
* and if present uses that value. Otherwise it generates one from UUID.random(),
|
||||
* and return it without adding a new header. But it doesn't add a <MessageID>
|
||||
* to the header list since we expect them to be added before calling this
|
||||
* method.
|
||||
*
|
||||
* <p>
|
||||
* Addressing tube will go do a separate verification on inbound
|
||||
* headers to make sure that <MessageID> header is present when it's
|
||||
* supposed to be.
|
||||
*
|
||||
* @param binding object created by {@link BindingID#createBinding()}
|
||||
*
|
||||
* @return unique id for the message
|
||||
* @deprecated
|
||||
*/
|
||||
public @NotNull String getID(@NotNull WSBinding binding) {
|
||||
return getID(binding.getAddressingVersion(), binding.getSOAPVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retuns a unique id for the message.
|
||||
* <p><p>
|
||||
* @see {@link #getID(com.sun.xml.internal.ws.api.WSBinding)} for detailed description.
|
||||
* @param av WS-Addressing version
|
||||
* @param sv SOAP version
|
||||
* @return unique id for the message
|
||||
* @deprecated
|
||||
*/
|
||||
public @NotNull String getID(AddressingVersion av, SOAPVersion sv) {
|
||||
String uuid = null;
|
||||
if (av != null) {
|
||||
uuid = AddressingUtils.getMessageID(getHeaders(), av, sv);
|
||||
}
|
||||
if (uuid == null) {
|
||||
uuid = generateMessageID();
|
||||
getHeaders().add(new StringHeader(av.messageIDTag, uuid));
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a UUID suitable for use as a MessageID value
|
||||
* @return generated UUID
|
||||
*/
|
||||
public static String generateMessageID() {
|
||||
return "uuid:" + UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public SOAPVersion getSOAPVersion() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.message;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.soap.MimeHeader;
|
||||
import javax.xml.soap.MimeHeaders;
|
||||
import javax.xml.soap.SOAPMessage;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.ws.WebServiceFeature;
|
||||
import javax.xml.ws.soap.MTOMFeature;
|
||||
|
||||
import com.oracle.webservices.internal.api.EnvelopeStyle;
|
||||
import com.oracle.webservices.internal.api.EnvelopeStyleFeature;
|
||||
import com.oracle.webservices.internal.api.message.MessageContext;
|
||||
import com.sun.xml.internal.ws.api.SOAPVersion;
|
||||
import com.sun.xml.internal.ws.api.WSFeatureList;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codec;
|
||||
import com.sun.xml.internal.ws.api.pipe.Codecs;
|
||||
import static com.sun.xml.internal.ws.transport.http.HttpAdapter.fixQuotesAroundSoapAction;
|
||||
|
||||
/**
|
||||
* The MessageContextFactory implements com.oracle.webservices.internal.api.message.MessageContextFactory as
|
||||
* a factory of Packet and public facade of Codec(s).
|
||||
*
|
||||
* @author shih-chang.chen@oracle.com
|
||||
*/
|
||||
public class MessageContextFactory extends com.oracle.webservices.internal.api.message.MessageContextFactory {
|
||||
|
||||
private WSFeatureList features;
|
||||
private Codec soapCodec;
|
||||
private Codec xmlCodec;
|
||||
private EnvelopeStyleFeature envelopeStyle;
|
||||
private EnvelopeStyle.Style singleSoapStyle;
|
||||
|
||||
public MessageContextFactory(WebServiceFeature[] wsf) {
|
||||
this(new com.sun.xml.internal.ws.binding.WebServiceFeatureList(wsf));
|
||||
}
|
||||
|
||||
public MessageContextFactory(WSFeatureList wsf) {
|
||||
features = wsf;
|
||||
envelopeStyle = features.get(EnvelopeStyleFeature.class);
|
||||
if (envelopeStyle == null) {//Default to SOAP11
|
||||
envelopeStyle = new EnvelopeStyleFeature(new EnvelopeStyle.Style[]{EnvelopeStyle.Style.SOAP11});
|
||||
features.mergeFeatures(new WebServiceFeature[]{envelopeStyle}, false);
|
||||
}
|
||||
for (EnvelopeStyle.Style s : envelopeStyle.getStyles()) {
|
||||
if (s.isXML()) {
|
||||
if (xmlCodec == null) xmlCodec = Codecs.createXMLCodec(features);
|
||||
} else {
|
||||
if (soapCodec == null) soapCodec = Codecs.createSOAPBindingCodec(features);
|
||||
singleSoapStyle = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected com.oracle.webservices.internal.api.message.MessageContextFactory newFactory(WebServiceFeature... f) {
|
||||
return new com.sun.xml.internal.ws.api.message.MessageContextFactory(f);
|
||||
}
|
||||
|
||||
|
||||
public com.oracle.webservices.internal.api.message.MessageContext createContext() {
|
||||
return packet(null);
|
||||
}
|
||||
|
||||
public com.oracle.webservices.internal.api.message.MessageContext createContext(SOAPMessage soap) {
|
||||
throwIfIllegalMessageArgument(soap);
|
||||
return packet(Messages.create(soap));
|
||||
}
|
||||
|
||||
public MessageContext createContext(Source m, com.oracle.webservices.internal.api.EnvelopeStyle.Style envelopeStyle) {
|
||||
throwIfIllegalMessageArgument(m);
|
||||
return packet(Messages.create(m, SOAPVersion.from(envelopeStyle)));
|
||||
}
|
||||
|
||||
public com.oracle.webservices.internal.api.message.MessageContext createContext(Source m) {
|
||||
throwIfIllegalMessageArgument(m);
|
||||
return packet(Messages.create(m, SOAPVersion.from(singleSoapStyle)));
|
||||
}
|
||||
|
||||
public com.oracle.webservices.internal.api.message.MessageContext createContext(InputStream in, String contentType) throws IOException {
|
||||
throwIfIllegalMessageArgument(in);
|
||||
//TODO when do we use xmlCodec?
|
||||
Packet p = packet(null);
|
||||
soapCodec.decode(in, contentType, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated http://java.net/jira/browse/JAX_WS-1077
|
||||
*/
|
||||
@Deprecated
|
||||
public com.oracle.webservices.internal.api.message.MessageContext createContext(InputStream in, MimeHeaders headers) throws IOException {
|
||||
String contentType = getHeader(headers, "Content-Type");
|
||||
Packet packet = (Packet) createContext(in, contentType);
|
||||
packet.acceptableMimeTypes = getHeader(headers, "Accept");
|
||||
packet.soapAction = fixQuotesAroundSoapAction(getHeader(headers, "SOAPAction"));
|
||||
// packet.put(Packet.INBOUND_TRANSPORT_HEADERS, toMap(headers));
|
||||
return packet;
|
||||
}
|
||||
|
||||
static String getHeader(MimeHeaders headers, String name) {
|
||||
String[] values = headers.getHeader(name);
|
||||
return (values != null && values.length > 0) ? values[0] : null;
|
||||
}
|
||||
|
||||
static Map<String, List<String>> toMap(MimeHeaders headers) {
|
||||
HashMap<String, List<String>> map = new HashMap<String, List<String>>();
|
||||
for (Iterator<MimeHeader> i = headers.getAllHeaders(); i.hasNext();) {
|
||||
MimeHeader mh = i.next();
|
||||
List<String> values = map.get(mh.getName());
|
||||
if (values == null) {
|
||||
values = new ArrayList<String>();
|
||||
map.put(mh.getName(), values);
|
||||
}
|
||||
values.add(mh.getValue());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public MessageContext createContext(Message m) {
|
||||
throwIfIllegalMessageArgument(m);
|
||||
return packet(m);
|
||||
}
|
||||
|
||||
private Packet packet(Message m) {
|
||||
final Packet p = new Packet();
|
||||
//TODO when do we use xmlCodec?
|
||||
p.codec = soapCodec;
|
||||
if (m != null) p.setMessage(m);
|
||||
MTOMFeature mf = features.get(MTOMFeature.class);
|
||||
if (mf != null) {
|
||||
p.setMtomFeature(mf);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
private void throwIfIllegalMessageArgument(Object message)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
if (message == null) {
|
||||
throw new IllegalArgumentException("null messages are not allowed. Consider using MessageContextFactory.createContext()");
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public com.oracle.webservices.internal.api.message.MessageContext doCreate() {
|
||||
return packet(null);
|
||||
}
|
||||
@Deprecated
|
||||
public com.oracle.webservices.internal.api.message.MessageContext doCreate(SOAPMessage m) {
|
||||
return createContext(m);
|
||||
}
|
||||
@Deprecated
|
||||
public com.oracle.webservices.internal.api.message.MessageContext doCreate(Source x, SOAPVersion soapVersion) {
|
||||
return packet(Messages.create(x, soapVersion));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.ws.api.message;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import com.sun.xml.internal.ws.api.WSBinding;
|
||||
|
||||
/**
|
||||
* Interface representing all the headers of a {@link Message}
|
||||
*/
|
||||
public interface MessageHeaders {
|
||||
public void understood(Header header);
|
||||
public void understood(QName name);
|
||||
public void understood(String nsUri, String localName);
|
||||
public Header get(String nsUri, String localName, boolean markAsUnderstood);
|
||||
public Header get(QName name, boolean markAsUnderstood);
|
||||
public Iterator<Header> getHeaders(String nsUri, String localName, final boolean markAsUnderstood);
|
||||
/**
|
||||
* Get all headers in specified namespace
|
||||
* @param nsUri
|
||||
* @param markAsUnderstood
|
||||
* @return
|
||||
*/
|
||||
public Iterator<Header> getHeaders(String nsUri, final boolean markAsUnderstood);
|
||||
public Iterator<Header> getHeaders(QName headerName, final boolean markAsUnderstood);
|
||||
public Iterator<Header> getHeaders();
|
||||
public boolean hasHeaders();
|
||||
public boolean add(Header header);
|
||||
public Header remove(QName name);
|
||||
public Header remove(String nsUri, String localName);
|
||||
//DONT public Header remove(Header header);
|
||||
public void replace(Header old, Header header);
|
||||
|
||||
/**
|
||||
* Replaces an existing {@link Header} or adds a new {@link Header}.
|
||||
*
|
||||
* <p>
|
||||
* Order doesn't matter in headers, so this method
|
||||
* does not make any guarantee as to where the new header
|
||||
* is inserted.
|
||||
*
|
||||
* @return
|
||||
* always true. Don't use the return value.
|
||||
*/
|
||||
public boolean addOrReplace(Header header);
|
||||
|
||||
/**
|
||||
* Return a Set of QNames of headers that have been explicitly marked as understood.
|
||||
* If none have been marked, this method could return null
|
||||
*/
|
||||
public Set<QName> getUnderstoodHeaders();
|
||||
|
||||
/**
|
||||
* Returns a Set of QNames of headers that satisfy ALL the following conditions:
|
||||
* (a) Have mustUnderstand = true
|
||||
* (b) have NOT been explicitly marked as understood
|
||||
* (c) If roles argument is non-null, the header has isIgnorable = false
|
||||
* for the roles argument and SOAP version
|
||||
* (d) If non-null binding is passed in, are NOT understood by the binding
|
||||
* (e) If (d) is met, the header is NOT in the knownHeaders list passed in
|
||||
*
|
||||
* @param roles
|
||||
* @param knownHeaders
|
||||
* @param binding
|
||||
* @return
|
||||
*/
|
||||
public Set<QName> getNotUnderstoodHeaders(Set<String> roles, Set<QName> knownHeaders, WSBinding binding);
|
||||
|
||||
/**
|
||||
* True if the header has been explicitly marked understood, false otherwise
|
||||
* @param header
|
||||
* @return
|
||||
*/
|
||||
public boolean isUnderstood(Header header);
|
||||
|
||||
/**
|
||||
* True if the header has been explicitly marked understood, false otherwise
|
||||
* @param header
|
||||
* @return
|
||||
*/
|
||||
public boolean isUnderstood(QName header);
|
||||
|
||||
/**
|
||||
* True if the header has been explicitly marked understood, false otherwise
|
||||
* @param header
|
||||
* @return
|
||||
*/
|
||||
public boolean isUnderstood(String nsUri, String header);
|
||||
|
||||
/**
|
||||
* Returns <code>Header</code> instances in a <code>List</code>.
|
||||
* @return <code>List</code> containing <code>Header</code> instances
|
||||
*/
|
||||
public List<Header> asList();
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user