diff options
Diffstat (limited to 'bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport')
9 files changed, 0 insertions, 941 deletions
diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/HTTPTransportException.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/HTTPTransportException.java deleted file mode 100644 index c424c359a..000000000 --- a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/HTTPTransportException.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable - *******************************************************************************/ -package org.eclipse.wst.ws.internal.explorer.transport; - -import java.util.Map; - -/** - * A type of TransportException that can be thrown when the transport protocol - * is HTTP. The status code of the HTTP response is captured in this - * exception and passed up to the Web Services Explorer. - */ -public class HTTPTransportException extends TransportException { - - private static final long serialVersionUID = 8277180731798858877L; - - private int statusCode; - private Map headers; - - /** - * Constructor. - * - * @param statusCode The HTTP status code. - * @param message A message about the problem that occurred. - * @param headers A map of the HTTP headers. - */ - public HTTPTransportException(int statusCode, String message, Map headers) { - super(message); - this.statusCode = statusCode; - this.headers = headers; - } - - /** - * Returns the HTTP status code used to create this exception. - * - * @return The HTTP status code. - */ - public int getStatusCode() { - return statusCode; - } - - /** - * Retrieve the HTTP header for the given key - * - * @param key The key value. - * @return The HTTP header value for key, or null if there is no such header. - */ - public String getHeader(String key) { - Object value = headers.get(key); - if (value != null) - return value.toString(); - else - return null; - } -} diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/IDeserializer.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/IDeserializer.java deleted file mode 100644 index 248a20a35..000000000 --- a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/IDeserializer.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable - *******************************************************************************/ -package org.eclipse.wst.ws.internal.explorer.transport; - -/** - * The IDeserializer is responsible for taking an XML string and deserializing it - * into values to populate an ISOAPMessage. - */ -public interface IDeserializer { - - /** - * Deserialize the XML string into the ISOAPMessage. The part parameter tells the method - * which part of the message (the envelope or the contents of the header or body) the XML - * string represents. Note that "contents" refers to the list of elements inside the header - * or body, and not the header or body element itself. - * - * @param part One of {@link ISOAPMessage#ENVELOPE}, {@link ISOAPMessage#HEADER_CONTENT}, or - * {@link ISOAPMessage#BODY_CONTENT}. - * @param xml The XML string to deserialize. - * @param message The ISOAPMessage to deserialize into. - * @throws TransportException - */ - public void deserialize(int part, String xml, ISOAPMessage message) throws TransportException; -} diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPMessage.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPMessage.java deleted file mode 100644 index 6cd0ad6ad..000000000 --- a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPMessage.java +++ /dev/null @@ -1,220 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable - *******************************************************************************/ -package org.eclipse.wst.ws.internal.explorer.transport; - -import java.util.Map; - -import org.w3c.dom.Element; - -/** - * The ISOAPMessage represents a SOAP message in a web service invocation made by the - * Web Services Explorer's transport stack. - * <br/> - * <br/> - * The setters of ISOAPMessage are called by Web Services Explorer to populate the - * message before sending. WSE does not guarantee that all message elements it sets - * will have the same owner document. - */ -public interface ISOAPMessage { - - /** - * ISOAPMessage defines this property for storing the SOAP action value in - * a web service invocation. This property will be set by Web Services Explorer - * prior to passing the message to {@link ISOAPTransport#send(String, String, String, ISOAPMessage)} - */ - String PROP_SOAP_ACTION = "prop_soap_action"; - - /** - * This value is used when serializing and deserializing a message. It indicates the operation - * is working with the entire SOAP envelope element. - */ - int ENVELOPE = 0; - - /** - * This value is used when serializing and deserializing a message. It indicates the operation - * is working with the elements inside the SOAP header element. - */ - int HEADER_CONTENT = 1; - - /** - * This value is used when serializing and deserializing a message. It indicates the operation - * is working with the elements inside the SOAP body element. - */ - int BODY_CONTENT = 2; - - /** - * Returns the MessageContext associated with this message. The MessageContext is created - * by the Web Services Explorer and passed to the transport stack during message creation. - * Implementers of ISOAPMessage should store a reference to the MessageContext. - * - * @return The MessageContext encasulating information about the web service operation. - * @see ISOAPTransport#newMessage(MessageContext) - */ - public MessageContext getMessageContext(); - - /** - * Sets a property in this ISOAPMessage. - * - * @param key The key (name) of the property - * @param value The value of the property. - */ - public void setProperty(String key, Object value); - - /** - * Retrieves a property from this ISOAPMessage. - * - * @param key The key (name) of the property to retrieve. - * @return The value assoicated with the given key, or null if there's no such property. - */ - public Object getProperty(String key); - - /** - * The namespace table holds the namespace declaraions that are on the envelope element - * of the SOAP message. The table's keys are the namespace URIs and the values are the - * associated namespace prefixes. - * <br/> - * <br/> - * The effect of calling this method is that the declarations in the namespace table - * argument should add to or replace the declarations on the envelope. This API does - * not specify what happens to existing declarations on the envelope which are not - * in the namespace table passed in. - * - * @param namespaceTable The namespace table - */ - public void setNamespaceTable(Map namespaceTable); - - /** - * Returns a table of the namespace declarations that are on the envelope element of the - * SOAP message. The table's keys are the namespace URIs and the values are the - * associated namespace prefixes. - * <br/> - * <br/> - * The namespace table returned by this method may be modified by the Web Services - * Explorer and later updated back to the message via the setNamesapceTable() method. - * - * @return A table of namespace URIs to prefixes on the SOAP envelope. - */ - public Map getNamespaceTable(); - - /** - * Sets the envelope element of this message. - * - * @param envelope The envelope element. - */ - public void setEnvelope(Element envelope); - - /** - * Returns the envelope element of this message. The deep parameter dictates whether - * the method returns the whole envelope with all its descendants or just the envelope - * element itself. - * - * @param deep If true, the envelope and its descendants are returned, otherwise only - * the envelope element itself is returned. - * @return An element. - */ - public Element getEnvelope(boolean deep); - - /** - * Sets the header element of this message. - * - * @param header The header element. - */ - public void setHeader(Element header); - - /** - * Returns the header element of this message. The deep parameter dictates whether - * the method returns the whole header with all its descendants or just the header - * element itself. - * - * @param deep If true, the header and its descendants are returned, otherwise only - * the header element itself is returned. - * @return An element. - */ - public Element getHeader(boolean deep); - - /** - * Sets an array of elements that goes into the message's header. - * - * @param headerContent An array of elements. - */ - public void setHeaderContent(Element[] headerContent); - - /** - * Returns the array of elements that are inside the message's header. - * - * @return An array of elements. - */ - public Element[] getHeaderContent(); - - /** - * Sets the body element of this message. For an RPC style message, the first child - * element of the body should be the RPC wrapper element. - * - * @param body The body element. - */ - public void setBody(Element body); - - /** - * Returns the body of this message. The deep parameter dictates whether - * the method returns the whole body with all its descendants elements or just the - * body. For an RPC style message, the first child element of the - * body should be the RPC wrapper element, regardless of the value of the deep - * parameter. - * - * @param deep If true, the body and its descendants are returned, otherwise only - * the body (and the RPC wrapper element if the message is RPC style) is returned. - * @return An element. - */ - public Element getBody(boolean deep); - - /** - * Sets an array of elements that goes into the message's body. For an RPC style - * message, the body contents are the elements inside the RPC wrapper element. - * - * @param bodyContent An array of elements. - */ - public void setBodyContent(Element[] bodyContent); - - /** - * Returns the array of elements that are inside the message's body. For an RPC style - * message, the body contents are the elements inside the RPC wrapper element. - * - * @return An array of elements. - */ - public Element[] getBodyContent(); - - /** - * Set the fault element for this message, if any. - * - * @param fault A fault element. - */ - public void setFault(Element fault); - - /** - * Returns the fault element, if any. - * - * @return The fault element or null if no fault has occurred. - */ - public Element getFault(); - - /** - * Returns the XML serialized form of this ISOAPMessage. - * - * @return An XML string. - * @see ISerializer - * @throws TransportException - */ - public String toXML() throws TransportException; - -} diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPTransport.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPTransport.java deleted file mode 100644 index 7d2a3f9c9..000000000 --- a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPTransport.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable - *******************************************************************************/ -package org.eclipse.wst.ws.internal.explorer.transport; - -/** - * The ISOAPTransport is the core piece of the Web Services Explorer transport stack. - * It is responsible for invoking the web service and it also acts as the factory for - * creating ISerialier, IDeserializer, and ISOAPMessage instances which make up the - * rest of the WSE transport. - */ -public interface ISOAPTransport { - - /** - * Factory method for ISerializer. - * - * @return An instance of ISerializer. - */ - public ISerializer newSerializer(); - - /** - * Factory method for IDeserializer. - * - * @return An instance of IDeserializer. - */ - public IDeserializer newDeserializer(); - - /** - * Factory method for ISOAPMessage. - * - * @param context MessageContext encapsulating information about the web service operation. - * @return An instance of ISOAPMessage. - * @throws TransportException - */ - public ISOAPMessage newMessage(MessageContext context) throws TransportException; - - /** - * Invokes the web service operation by sending the SOAP message, then parsing the results - * into a response ISOAPMessage. - * - * @param url The endpoint URL. - * @param username Username to use for basic auth protected endpoints. Set to null if not required. - * @param password Password to use for basic auth protected endpoints. Set to null if not required. - * @param message The SOAP request message. - * @return An ISOAPMesage representing the response from the web service invocation. - * @throws TransportException - */ - public ISOAPMessage send(String url, String username, String password, ISOAPMessage message) throws TransportException; -} diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPTransportProvider.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPTransportProvider.java deleted file mode 100644 index 1de3dc2e2..000000000 --- a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/ISOAPTransportProvider.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable - *******************************************************************************/ -package org.eclipse.wst.ws.internal.explorer.transport; - -/** - * ISOAPTransportProvider is a factory for creating ISOAPTransport objects. - * Anyone who wishes to extend the org.eclipse.wst.ws.explorer.wseTransportProvider - * extension-point must provide an implementation for this interface. - */ -public interface ISOAPTransportProvider { - - /** - * Method for obtaining a new ISOAPTransport from this provider. - * This method should never return null. - * - * @return A new ISOAPTransport object. - */ - public ISOAPTransport newTransport(); -} diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/ISerializer.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/ISerializer.java deleted file mode 100644 index 5db69fb6d..000000000 --- a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/ISerializer.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable - *******************************************************************************/ -package org.eclipse.wst.ws.internal.explorer.transport; - -/** - * The ISerializer is responsible for taking an ISOAPMessage and serializing it - * into an XML string. - */ -public interface ISerializer { - - /** - * Serialize the ISOAPMessage into an XML string. The part parameter tells the method - * which part of the message (the envelope or the contents of the header or body) to - * serialize. Note that "contents" refers to the list of elements inside the header - * or body, and not the header or body element itself. - * - * @param part One of {@link ISOAPMessage#ENVELOPE}, {@link ISOAPMessage#HEADER_CONTENT}, or - * {@link ISOAPMessage#BODY_CONTENT}. - * @param message The ISOAPMessage to serialize. - * @return An XML string. - * @throws TransportException - */ - public String serialize(int part, ISOAPMessage message) throws TransportException; -} diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/MessageContext.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/MessageContext.java deleted file mode 100644 index 3e327cbab..000000000 --- a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/MessageContext.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable - *******************************************************************************/ -package org.eclipse.wst.ws.internal.explorer.transport; - -import javax.wsdl.BindingOperation; -import javax.wsdl.Definition; -import javax.wsdl.extensions.ExtensibilityElement; - -/** - * A MessageContext object holds information about the message that is to be - * sent on a web service invocation. This information is passed to the - * ISOAPTransport so that it can construct an appropriate ISOAPMessage to - * handle the invocation. - */ -public class MessageContext { - - private Definition definition; - private ExtensibilityElement bindingProtocol; - private BindingOperation bindingOperation; - private boolean documentStyle; - - /** - * Sets a reference to the WSDL definition. - * - * @param definition The WSDL definition. - */ - public void setDefinition(Definition definition) { - this.definition = definition; - } - - /** - * Returns the WSDL definition. - * - * @return The WSDL definition. - */ - public Definition getDefinition() { - return definition; - } - - /** - * Sets a reference to the binding extensibility element in the WSDL document. - * For a web service that uses the SOAP protocol, this will be an instance of - * javax.wsdl.extensions.soap.SOAPBinding - * - * @param bindingProtocol The binding extensibility element. - */ - public void setBindingProtocol(ExtensibilityElement bindingProtocol) { - this.bindingProtocol = bindingProtocol; - } - - /** - * Returns the binding extensibility element. - * - * @return The binding extensibility element. - */ - public ExtensibilityElement getBindingProtocol() { - return bindingProtocol; - } - - /** - * Sets a reference to the binding operation element in the WSDL document. - * - * @param bindingOperation The binding operation element. - */ - public void setBindingOperation(BindingOperation bindingOperation) { - this.bindingOperation = bindingOperation; - } - - /** - * Returns the binding operation element. - * - * @return The binding operation element. - */ - public BindingOperation getBindingOperation() { - return bindingOperation; - } - - /** - * Sets the flag on whether the message created from this MessageContext - * is document style or not. - * - * @param documentStyle True for document style, false otherwise. - */ - public void setDocumentStyle(boolean documentStyle) { - this.documentStyle = documentStyle; - } - - /** - * Returns the document style property. - * - * @return The document style property. - */ - public boolean isDocumentStyle() { - return documentStyle; - } -} diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/SOAPMessage.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/SOAPMessage.java deleted file mode 100644 index b9a41f4a8..000000000 --- a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/SOAPMessage.java +++ /dev/null @@ -1,339 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable - *******************************************************************************/ -package org.eclipse.wst.ws.internal.explorer.transport; - -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Map; - -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * This is a default implementation of the ISOAPMessage interface that extenders of the Web - * Services Explorer transport can use if they do not wish to implement their own message. - * This class is implemented as a collection of loose pieces of the SOAP message, and each - * piece must be set individually (for example, setting the envelope element will not - * automatically populate the header or body elements). - * <br/> - * <br/> - * This class does not know how to serialize itself. It depends on an ISerializer provided by - * the transport extender. - */ -public final class SOAPMessage implements ISOAPMessage { - - private MessageContext context; - private ISerializer serializer; - - private Map properties = new Hashtable(); - - private Element envelope = null; - - private Element header = null; - private Element[] headerContent = null; - - private Element body = null; - private Element[] bodyContent = null; - - private Element fault = null; - - private String xml = null; - - /** - * Constructor. - * - * @param context The MessageContext. - * @param serializer An ISerializer to use to serialize this message. - */ - public SOAPMessage(MessageContext context, ISerializer serializer) { - this.context = context; - this.serializer = serializer; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getMessageContext() - */ - public MessageContext getMessageContext() { - return context; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setProperty(java.lang.String, java.lang.Object) - */ - public void setProperty(String key, Object value) { - properties.put(key, value); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getProperty(java.lang.String) - */ - public Object getProperty(String key) { - return properties.get(key); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setNamespaceTable(java.util.Map) - */ - public synchronized void setNamespaceTable(Map namespaceTable) { - if (namespaceTable == null || envelope == null) - return; - - Iterator iter = namespaceTable.entrySet().iterator(); - - while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); - String name = "xmlns:" + entry.getValue(); - envelope.setAttribute(name, entry.getKey().toString()); - } - - xml = null; - } - - /* - * If the attribute is a namespace declaration, the namespace prefix is returned. - * Otherwise null is returned. - */ - private String getNSPrefix(Attr attribute) { - String name = attribute.getName(); - if (name.startsWith("xmlns:")) - return name.substring(6); - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getNamespaceTable() - */ - public Map getNamespaceTable() { - - Hashtable namespaceTable = new Hashtable(); - - if (envelope != null) { - NamedNodeMap attributes = envelope.getAttributes(); - for (int i = 0; i < attributes.getLength(); i++) { - Attr attribute = (Attr) attributes.item(i); - String prefix = getNSPrefix(attribute); - if (prefix != null) - namespaceTable.put(attribute.getValue(), prefix); - } - } - - return namespaceTable; - } - - /* - * Appends a child node to a parent node, takes care of importing - * the child node if neccessary. - */ - private void appendNode(Node parent, Node child) { - if (parent == null || child == null) - return; - - Document owner = parent.getOwnerDocument(); - - if (!owner.equals(child.getOwnerDocument())) - child = owner.importNode(child, true); - - parent.appendChild(child); - } - - /* - * Adds an array of elements to the parent element as child elements. - */ - private void appendChildren(Element parent, Element[] children) { - if (parent == null || children == null) - return; - - for (int i = 0; i < children.length; i++) { - if (children[i] == null) - continue; - appendNode(parent, children[i]); - } - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setEnvelope(org.w3c.dom.Element) - */ - public synchronized void setEnvelope(Element envelope) { - if (envelope == null) - this.envelope = envelope; - else - this.envelope = (Element) envelope.cloneNode(false); - - xml = null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getEnvelope(boolean) - */ - public Element getEnvelope(boolean deep) { - if (!deep) - return envelope; - - synchronized (this) { - if (envelope == null) - return null; - - Element clonedEnvelope = (Element) envelope.cloneNode(false); - - if (headerContent != null && headerContent.length > 0) - appendNode(clonedEnvelope, getHeader(true)); - - appendNode(clonedEnvelope, getBody(true)); - - return clonedEnvelope; - } - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setHeader(org.w3c.dom.Element) - */ - public synchronized void setHeader(Element header) { - if (header == null) - this.header = null; - else - this.header = (Element) header.cloneNode(false); - - xml = null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getHeader(boolean) - */ - public Element getHeader(boolean deep) { - if (!deep) - return header; - - synchronized (this) { - if (header == null) - return null; - - Element clonedHeader = (Element) header.cloneNode(false); - appendChildren(clonedHeader, headerContent); - return clonedHeader; - } - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setHeaderContent(org.w3c.dom.Element[]) - */ - public synchronized void setHeaderContent(Element[] headerContent) { - this.headerContent = headerContent; - xml = null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getHeaderContent() - */ - public Element[] getHeaderContent() { - return headerContent; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setBody(org.w3c.dom.Element) - */ - public synchronized void setBody(Element body) { - if (body == null) - this.body = null; - else { - this.body = (Element) body.cloneNode(false); - - if (!context.isDocumentStyle() && fault == null) { - NodeList childElements = body.getElementsByTagName("*"); - if (childElements.getLength() > 0) - this.body.appendChild(childElements.item(0).cloneNode(false)); - } - } - xml = null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getBody(boolean) - */ - public Element getBody(boolean deep) { - if (!deep) - return body; - - synchronized (this) { - if (body == null) - return null; - - // copy the rpc wrapper element as well, if any - Element clonedBody = (Element) body.cloneNode(true); - - if (fault != null) - appendNode(clonedBody, fault); - else { - Element target = clonedBody; - - // check for rpc wrapper - if (clonedBody.getFirstChild() != null) - target = (Element) clonedBody.getFirstChild(); - - appendChildren(target, bodyContent); - } - - return clonedBody; - } - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setBodyContent(org.w3c.dom.Element[]) - */ - public synchronized void setBodyContent(Element[] bodyContent) { - this.bodyContent = bodyContent; - if (bodyContent != null) - fault = null; - xml = null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getBodyContent() - */ - public Element[] getBodyContent() { - return bodyContent; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#setFault(org.w3c.dom.Element) - */ - public synchronized void setFault(Element fault) { - this.fault = fault; - if (fault != null) { - if (body != null && body.getFirstChild() != null) - body.removeChild(body.getFirstChild()); - bodyContent = null; - } - xml = null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#getFault() - */ - public Element getFault() { - return fault; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.ws.internal.explorer.transport.ISOAPMessage#toXML() - */ - public synchronized String toXML() throws TransportException { - if (xml == null) - xml = serializer.serialize(ENVELOPE, this); - return xml; - } -} diff --git a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/TransportException.java b/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/TransportException.java deleted file mode 100644 index 2cac2fd17..000000000 --- a/bundles/org.eclipse.wst.ws.explorer/src/org/eclipse/wst/ws/internal/explorer/transport/TransportException.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * yyyymmdd bug Email and other contact information - * -------- -------- ----------------------------------------------------------- - * 20070413 176493 makandre@ca.ibm.com - Andrew Mak, WSE: Make message/transport stack pluggable - *******************************************************************************/ -package org.eclipse.wst.ws.internal.explorer.transport; - -/** - * An general purpose exception to indicate a problem has occurred when - * invoking a web service. - */ -public class TransportException extends RuntimeException { - - private static final long serialVersionUID = -1502247230726021403L; - - /** - * Constructor. - * - * @param message A message about the problem that occurred. - */ - public TransportException(String message) { - super(message); - } - - /** - * Constructor that accepts a message and a cause. - * - * @param message A message about the problem that occurred. - * @param cause The cause for this exception. - */ - public TransportException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Constructor that accepts a cause. - * - * @param cause The cause for this exception. - */ - public TransportException(Throwable cause) { - super(cause); - } -} |