You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2006/06/12 18:04:44 UTC

svn commit: r413691 [2/2] - in /webservices/muse/trunk/modules/muse-wsa-soap: ./ specs/ src/org/apache/muse/ws/addressing/ src/org/apache/muse/ws/addressing/soap/

Added: webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapConstants.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapConstants.java?rev=413691&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapConstants.java (added)
+++ webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapConstants.java Mon Jun 12 09:04:42 2006
@@ -0,0 +1,87 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.ws.addressing.soap;
+
+import javax.xml.namespace.QName;
+
+/**
+ *
+ * SoapConstants is a collection of values related to SOAP 1.2.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SoapConstants
+{
+    /**
+     * 
+     * The SOAP 1.2 namespace URI.
+     * 
+     */
+    public static final String NAMESPACE_URI = "http://www.w3.org/2003/05/soap-envelope";
+    
+    public static final String PREFIX = "soap";
+    
+    public static final String ACTOR = "actor";
+    
+    public static final String MUST_UNDERSTAND = "mustUnderstand";
+    
+    public static final String CONTENT_TYPE_HEADER = "application/soap+xml";
+    
+    public static final QName ENVELOPE_QNAME = 
+        new QName(NAMESPACE_URI, "Envelope", PREFIX);
+    
+    public static final QName HEADER_QNAME = 
+        new QName(NAMESPACE_URI, "Header", PREFIX);
+    
+    public static final QName BODY_QNAME = 
+        new QName(NAMESPACE_URI, "Body", PREFIX);
+
+    public static final QName FAULT_QNAME = 
+        new QName(NAMESPACE_URI, "Fault", PREFIX);
+
+    public static final QName CODE_QNAME = 
+        new QName(NAMESPACE_URI, "Code", PREFIX);
+
+    public static final QName SUBCODE_QNAME = 
+        new QName(NAMESPACE_URI, "Subcode", PREFIX);
+
+    public static final QName VALUE_QNAME = 
+        new QName(NAMESPACE_URI, "Value", PREFIX);
+
+    public static final QName REASON_QNAME = 
+        new QName(NAMESPACE_URI, "Reason", PREFIX);
+
+    public static final QName TEXT_QNAME = 
+        new QName(NAMESPACE_URI, "Text", PREFIX);
+
+    public static final QName NODE_QNAME = 
+        new QName(NAMESPACE_URI, "Node", PREFIX);
+
+    public static final QName ROLE_QNAME = 
+        new QName(NAMESPACE_URI, "Role", PREFIX);
+
+    public static final QName DETAIL_QNAME = 
+        new QName(NAMESPACE_URI, "Detail", PREFIX);
+
+    public static final QName SENDER_QNAME = 
+        new QName(NAMESPACE_URI, "Sender", PREFIX);
+
+    public static final QName RECEIVER_QNAME = 
+        new QName(NAMESPACE_URI, "Receiver", PREFIX);
+}

Added: webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapFault.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapFault.java?rev=413691&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapFault.java (added)
+++ webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapFault.java Mon Jun 12 09:04:42 2006
@@ -0,0 +1,197 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.ws.addressing.soap;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.xml.XmlSerializable;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.addressing.soap.SoapConstants;
+
+/**
+ * 
+ * This class represents a the SOAP fault type defined in SOAP 1.2.
+ * 
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class SoapFault extends Exception implements XmlSerializable
+{
+    private static final long serialVersionUID = -8612773172898054578L;
+    
+    private QName _code = SoapConstants.RECEIVER_QNAME;
+    
+    private QName _subCode = null;
+    private String _reason = null;
+    private String _nodeURI = null;
+    private String _roleURI = null;
+    
+    private Element _detail = null;
+    
+    public SoapFault(Element xml)
+    {
+        Element codeXML = XmlUtils.getElement(xml, SoapConstants.CODE_QNAME);
+        _code = XmlUtils.getQNameFromChild(codeXML, SoapConstants.VALUE_QNAME);
+        
+        Element subCodeXML = XmlUtils.getElement(codeXML, SoapConstants.SUBCODE_QNAME);
+            
+        if (subCodeXML != null)
+            _subCode = XmlUtils.getQNameFromChild(subCodeXML, SoapConstants.VALUE_QNAME);
+        
+        Element reasonXML = XmlUtils.getElement(xml, SoapConstants.REASON_QNAME);
+        _reason = XmlUtils.getElementText(reasonXML, SoapConstants.TEXT_QNAME);
+        
+        _nodeURI = XmlUtils.getElementText(xml, SoapConstants.NODE_QNAME);
+        _roleURI = XmlUtils.getElementText(xml, SoapConstants.ROLE_QNAME);
+        
+        Element detailXML = XmlUtils.getElement(xml, SoapConstants.DETAIL_QNAME);
+        
+        if (detailXML != null)
+            _detail = XmlUtils.getFirstElement(detailXML);
+    }
+    
+    public SoapFault(String message)
+    {
+        _reason = message;
+    }
+    
+    public SoapFault(String message, Throwable cause)
+    {
+        _reason = message;
+        initCause(cause);        
+    }
+    
+    public SoapFault(Throwable cause)
+    {
+        _reason = cause.getMessage();
+        initCause(cause);
+    }
+    
+    public final QName getCode()
+    {
+        return _code;
+    }
+
+    public final void setCode(QName code)
+    {
+        _code = code;
+    }
+
+    public final Element getDetail()
+    {
+        return _detail;
+    }
+
+    public final void setDetail(Element detail)
+    {
+        _detail = detail;
+    }
+
+    public final String getNodeURI()
+    {
+        return _nodeURI;
+    }
+
+    public final void setNodeURI(String nodeURI)
+    {
+        _nodeURI = nodeURI;
+    }
+
+    public final String getReason()
+    {
+        return _reason;
+    }
+
+    public final void setReason(String reason)
+    {
+        _reason = reason;
+    }
+
+    public final String getRoleURI()
+    {
+        return _roleURI;
+    }
+    
+    public final void setRoleURI(String roleURI)
+    {
+        _roleURI = roleURI;
+    }
+    
+    public final QName getSubCode()
+    {
+        return _subCode;
+    }
+    
+    public final void setSubCode(QName subCode)
+    {
+        _subCode = subCode;
+    }
+
+    public String getMessage()
+    {
+        return getReason();
+    }
+
+    public Element toXML()
+    {
+        return toXML(XmlUtils.EMPTY_DOC);
+    }
+
+    public Element toXML(Document doc)
+    {
+        Element faultXML = XmlUtils.createElement(doc, SoapConstants.FAULT_QNAME);
+        
+        Element codeXML = XmlUtils.createElement(doc, SoapConstants.CODE_QNAME);
+        faultXML.appendChild(codeXML);
+        
+        XmlUtils.setElement(codeXML, SoapConstants.VALUE_QNAME, getCode());
+        
+        QName subCode = getSubCode();
+        
+        if (subCode != null)
+        {
+            Element subCodeXML = XmlUtils.createElement(doc, SoapConstants.SUBCODE_QNAME);
+            codeXML.appendChild(subCodeXML);
+            XmlUtils.setElement(subCodeXML, SoapConstants.VALUE_QNAME, subCode);
+        }
+        
+        Element reasonXML = XmlUtils.createElement(doc, SoapConstants.REASON_QNAME);
+        faultXML.appendChild(reasonXML);
+        XmlUtils.setElement(reasonXML, SoapConstants.TEXT_QNAME, getReason());
+        
+        String nodeURI = getNodeURI();
+        
+        if (nodeURI != null)
+            XmlUtils.setElement(faultXML, SoapConstants.NODE_QNAME, nodeURI); 
+        
+        String roleURI = getRoleURI();
+        
+        if (roleURI != null)
+            XmlUtils.setElement(faultXML, SoapConstants.ROLE_QNAME, roleURI); 
+        
+        Element detail = getDetail();
+        
+        if (detail != null)
+            XmlUtils.setElement(faultXML, SoapConstants.DETAIL_QNAME, detail, false);
+        
+        return faultXML;
+    }
+}

Added: webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapMonitor.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapMonitor.java?rev=413691&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapMonitor.java (added)
+++ webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapMonitor.java Mon Jun 12 09:04:42 2006
@@ -0,0 +1,71 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.ws.addressing.soap;
+
+/**
+ *
+ * SoapMonitor is a supplemental interface for SOAP clients that wish 
+ * to support TCP/SOAP monitoring without modifying server-side code. 
+ * Services that use WS-Addressing for routing may find it hard to do 
+ * SOAP monitoring because WS-A data is used for routing and resource 
+ * identification (so changing a port number equates to changing an 
+ * identifier).
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public interface SoapMonitor
+{
+    /**
+     * 
+     * @return The port to which messages are being sent when TCP/SOAP 
+     *         monitoring is being used. When no monitoring is used (normal 
+     *         mode), this returns -1.
+     *
+     */
+    int getSoapMonitorPort();
+
+    /**
+     * 
+     * @return True if messages are being redirected to a SOAP monitor port.
+     *
+     */
+    boolean isUsingSoapMonitor();
+
+    /**
+     * 
+     * Causes the SoapClient to send messages to the given port. This does 
+     * <b>not</b> change the port number in the WS-A EPR found in the SOAP 
+     * headers. The receiver will have no idea it is taking part in SOAP 
+     * monitoring. Only the original HTTP GET will have a different port.
+     *
+     * @param monitorPort
+     *        A positive integer - 0 to 65535.
+     *
+     */
+    void startSoapMonitor(int monitorPort);
+
+    /**
+     * 
+     * If SOAP monitoring was in use, the client will revert back to 
+     * sending the messages to the port in the EPR's wsa:Address. If 
+     * SOAP monitoring was not in use, the call is a no-op.
+     *
+     */
+    void stopSoapMonitor();
+}

Added: webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapUtils.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapUtils.java?rev=413691&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapUtils.java (added)
+++ webservices/muse/trunk/modules/muse-wsa-soap/src/org/apache/muse/ws/addressing/soap/SoapUtils.java Mon Jun 12 09:04:42 2006
@@ -0,0 +1,40 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.ws.addressing.soap;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.xml.XmlUtils;
+
+public class SoapUtils
+{
+    public static SoapFault convertToFault(Throwable error)
+    {
+        if (error instanceof SoapFault)
+            return (SoapFault)error;
+        
+        return new SoapFault(error);
+    }
+    
+    public static boolean isFault(Element xml)
+    {
+        QName qname = XmlUtils.getElementQName(xml);
+        return qname.equals(SoapConstants.FAULT_QNAME);
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org