You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by di...@apache.org on 2004/02/10 20:18:35 UTC
cvs commit: ws-fx/addressing/src/org/apache/axis/message/addressing/util TextExtractor.java
dims 2004/02/10 11:18:35
Modified: addressing/src/org/apache/axis/message/addressing
Action.java Address.java
AddressingFormatException.java
AddressingHeaders.java AddressList.java
AttributedQName.java AttributedURI.java
EndpointReference.java EndpointReferenceType.java
FaultTo.java From.java MessageID.java PortType.java
Recipient.java ReferenceProperties.java
RelatesTo.java ReplyTo.java ServiceName.java
To.java
Added: addressing/src/org/apache/axis/message/addressing
Constants.java
addressing/test/addressing TestSerDeser.java
addressing/src/org/apache/axis/message/addressing/util
TextExtractor.java
Log:
Initial implementation of WS-Addressing.
Note:
Test case extracts WS-Addressing headers from a soap envelope and save it back into the soap envelope
Revision Changes Path
1.2 +24 -2 ws-fx/addressing/src/org/apache/axis/message/addressing/Action.java
Index: Action.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/Action.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Action.java 6 Feb 2004 19:51:28 -0000 1.1
+++ Action.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,5 +1,24 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
+import org.apache.axis.types.URI;
+
/**
* Class Action
*
@@ -10,8 +29,11 @@
/**
* Constructor Action
*
- * @param URI
+ * @param uri
*/
- public Action(String URI) {
+ public Action(URI uri) {
+ super(uri);
}
}
+
+
1.2 +45 -2 ws-fx/addressing/src/org/apache/axis/message/addressing/Address.java
Index: Address.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/Address.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Address.java 6 Feb 2004 19:51:28 -0000 1.1
+++ Address.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,6 +1,24 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
import org.apache.axis.types.URI;
+import org.w3c.dom.Element;
/**
* Class Address
@@ -12,8 +30,33 @@
/**
* Constructor Address
*
- * @param URI
+ * @param uri
+ */
+ public Address(URI uri) {
+ super(uri);
+ }
+
+ /**
+ * Constructor Address
+ *
+ * @param uri
+ * @throws MalformedURIException
*/
- public Address(URI URI) {
+ public Address(String uri) throws MalformedURIException {
+ this(new URI(uri));
+ }
+
+ /**
+ * append DOM node to parent
+ *
+ * @param parent
+ */
+ public void append(Element parent) {
+ Element child = parent.getOwnerDocument().createElementNS(Constants.NS_URI_ADDRESSING,
+ Constants.ADDRESS);
+ child.appendChild(parent.getOwnerDocument().createTextNode(toString()));
+ parent.appendChild(child);
}
}
+
+
1.2 +19 -0 ws-fx/addressing/src/org/apache/axis/message/addressing/AddressingFormatException.java
Index: AddressingFormatException.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/AddressingFormatException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddressingFormatException.java 6 Feb 2004 19:51:28 -0000 1.1
+++ AddressingFormatException.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,3 +1,20 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
import org.apache.axis.AxisFault;
@@ -17,3 +34,5 @@
public AddressingFormatException(String message) {
}
}
+
+
1.2 +281 -83 ws-fx/addressing/src/org/apache/axis/message/addressing/AddressingHeaders.java
Index: AddressingHeaders.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/AddressingHeaders.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddressingHeaders.java 6 Feb 2004 19:51:28 -0000 1.1
+++ AddressingHeaders.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,6 +1,36 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
import org.apache.axis.message.SOAPEnvelope;
+import org.apache.axis.message.SOAPHeaderElement;
+import org.apache.axis.message.addressing.util.TextExtractor;
+import org.apache.axis.types.URI;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.soap.SOAPException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
/**
* Class AddressingHeaders
@@ -8,202 +38,370 @@
* @author Davanum Srinivas (dims@yahoo.com)
*/
public class AddressingHeaders {
-
/**
- * Constructor AddressingHeaders
- *
- * @param env
+ * Field action
*/
- public AddressingHeaders(SOAPEnvelope env) {
- }
+ private Action action = null;
/**
- * Constructor AddressingHeaders
+ * Field replyTo
*/
- public AddressingHeaders() {
- }
+ private ReplyTo replyTo = null;
/**
- * Field _action
+ * Field to
*/
- private Action _action;
+ private To to = null;
/**
- * Field _replyTo
+ * Field faultTo
*/
- private ReplyTo _replyTo;
+ private FaultTo faultTo = null;
/**
- * Field _to
+ * Field from
*/
- private To _to;
+ private From from = null;
/**
- * Field _faultTo
+ * Field recipient
*/
- private FaultTo _faultTo;
+ private Recipient recipient = null;
/**
- * Field _from
+ * Field messageID
*/
- private From _from;
+ private MessageID messageID = null;
/**
- * Field _messageID
+ * Field relatesTo
*/
- private MessageID _messageID;
+ private ArrayList relatesTo = new ArrayList();
/**
- * Field _recipient
+ * Constructor AddressingHeaders
*/
- private Recipient _recipient;
+ public AddressingHeaders() {
+ }
/**
- * Field _relatesTo
+ * Constructor AddressingHeaders
+ *
+ * @param env
+ * @throws Exception
*/
- private RelatesTo _relatesTo;
+ public AddressingHeaders(SOAPEnvelope env) throws Exception {
+ this(env, true, true);
+ }
/**
- * Method get_action
+ * Constructor AddressingHeaders
+ *
+ * @param env
+ * @param process
+ * @param remove
+ * @throws Exception
+ */
+ public AddressingHeaders(SOAPEnvelope env, boolean process, boolean remove)
+ throws Exception {
+
+ URI uri = extract(env, Constants.MESSAGE_ID, process, remove);
+ if (uri != null) {
+ messageID = new MessageID(uri);
+ }
+ uri = extract(env, Constants.TO, process, remove);
+ if (uri != null) {
+ to = new To(uri);
+ }
+ uri = extract(env, Constants.ACTION, process, remove);
+ if (uri != null) {
+ action = new Action(uri);
+ }
+ uri = extract(env, Constants.FROM, process, remove);
+ if (uri != null) {
+ from = new From(uri);
+ }
+ uri = extract(env, Constants.REPLY_TO, process, remove);
+ if (uri != null) {
+ replyTo = new ReplyTo(uri);
+ }
+ uri = extract(env, Constants.FAULT_TO, process, remove);
+ if (uri != null) {
+ faultTo = new FaultTo(uri);
+ }
+ uri = extract(env, Constants.RECIPIENT, process, remove);
+ if (uri != null) {
+ recipient = new Recipient(uri);
+ }
+
+ Enumeration enum = env.getHeadersByName(Constants.NS_URI_ADDRESSING,
+ Constants.RELATES_TO);
+ if (enum.hasMoreElements()) {
+ while (enum.hasMoreElements()) {
+ SOAPHeaderElement header = (SOAPHeaderElement) enum.nextElement();
+
+ String type = header.getAttributeValue(Constants.RELATIONSHIP_TYPE);
+ String uri2 = header.getValue();
+
+ relatesTo.add(new RelatesTo(uri2, type));
+
+ if (process) {
+ header.setProcessed(true);
+ }
+
+ if (remove) {
+ env.removeHeader(header);
+ }
+ }
+ }
+ }
+
+ public URI extract(SOAPEnvelope env, String name, boolean process, boolean remove) throws Exception {
+ URI uri = null;
+ SOAPHeaderElement header = env.getHeaderByName(Constants.NS_URI_ADDRESSING, name);
+
+ if (header != null) {
+ uri = new URI(TextExtractor.getText(header.getAsDOM()));
+ if (process) {
+ header.setProcessed(true);
+ }
+ if (remove) {
+ env.removeHeader(header);
+ }
+ }
+ return uri;
+ }
+
+ /**
+ * Method getAction
*
* @return
*/
- public Action get_action() {
- return _action;
+ public Action getAction() {
+ return action;
}
/**
- * Method set_action
+ * Method setAction
*
- * @param _action
+ * @param action
*/
- public void set_action(Action _action) {
- this._action = _action;
+ public void setAction(Action action) {
+ this.action = action;
}
/**
- * Method get_replyTo
+ * Method getTo
*
* @return
*/
- public ReplyTo get_replyTo() {
- return _replyTo;
+ public To getTo() {
+ return to;
}
/**
- * Method set_replyTo
+ * Method setTo
*
- * @param _replyTo
+ * @param to
*/
- public void set_replyTo(ReplyTo _replyTo) {
- this._replyTo = _replyTo;
+ public void setTo(To to) {
+ this.to = to;
}
/**
- * Method get_to
+ * Method setMessageID
*
- * @return
+ * @param messageID
*/
- public To get_to() {
- return _to;
+ public void setMessageID(MessageID messageID) {
+ this.messageID = messageID;
}
/**
- * Method set_to
+ * Method toEnvelope
*
- * @param _to
+ * @param env
+ * @throws SOAPException
+ * @throws ParserConfigurationException
*/
- public void set_to(To _to) {
- this._to = _to;
+ public void toEnvelope(SOAPEnvelope env)
+ throws SOAPException, ParserConfigurationException {
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ dbf.setValidating(false);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.newDocument();
+
+ if (env.getNamespaceURI(Constants.NS_PREFIX_ADDRESSING) == null) {
+ env.addNamespaceDeclaration(Constants.NS_PREFIX_ADDRESSING, Constants.NS_URI_ADDRESSING);
+ }
+
+ if (messageID != null) {
+ SOAPHeaderElement header = new SOAPHeaderElement(Constants.NS_URI_ADDRESSING,
+ Constants.MESSAGE_ID);
+ header.addTextNode(messageID.toString());
+ header.setMustUnderstand(true);
+ env.addHeader(header);
+ }
+
+ if (to != null) {
+ SOAPHeaderElement header = new SOAPHeaderElement(Constants.NS_URI_ADDRESSING, Constants.TO);
+ header.addTextNode(to.getAddress().toString());
+ header.setMustUnderstand(true);
+ env.addHeader(header);
+
+ ReferenceProperties properties = to.getProperties();
+ if (properties != null && properties.size() > 0) {
+ for (int i = 0; i < properties.size(); i++) {
+ Element elem = (Element) properties.get(i);
+ env.addHeader(new SOAPHeaderElement(elem));
+ }
+ }
+ }
+
+ if (action != null) {
+ SOAPHeaderElement header = new SOAPHeaderElement(Constants.NS_URI_ADDRESSING,
+ Constants.ACTION);
+ header.addTextNode(action.toString());
+ header.setMustUnderstand(true);
+ env.addHeader(header);
+ }
+
+ if (from != null) {
+ from.toEnvelope(env, doc);
+ }
+
+ if (replyTo != null) {
+ replyTo.toEnvelope(env, doc);
+ }
+
+ if (faultTo != null) {
+ faultTo.toEnvelope(env, doc);
+ }
+
+ if (recipient != null) {
+ recipient.toEnvelope(env, doc);
+ }
+
+ if (relatesTo != null) {
+ for (int i = 0; i < relatesTo.size(); i++) {
+ RelatesTo rtp = (RelatesTo) relatesTo.get(i);
+ SOAPHeaderElement header = new SOAPHeaderElement(Constants.NS_URI_ADDRESSING,
+ Constants.RELATES_TO);
+ header.setAttribute(Constants.NS_URI_ADDRESSING,
+ Constants.RELATIONSHIP_TYPE,
+ rtp.getType().toString());
+ header.addTextNode(rtp.getURI().toString());
+ header.setMustUnderstand(true);
+ env.addHeader(header);
+ }
+ }
}
/**
- * Method get_faultTo
+ * Method getMessageID
*
* @return
*/
- public FaultTo get_faultTo() {
- return _faultTo;
+ public MessageID getMessageID() {
+ return messageID;
}
/**
- * Method set_faultTo
+ * Method getRelatesTo
*
- * @param _faultTo
+ * @return
*/
- public void set_faultTo(FaultTo _faultTo) {
- this._faultTo = _faultTo;
+ public List getRelatesTo() {
+ return relatesTo;
}
/**
- * Method get_from
+ * Set the collection of RelatesToProperties. Not additive,
+ * this replaces the current collection.
*
- * @return
+ * @param v Vector of RelatesToProperties
+ */
+ public void setRelatesTo(List v) {
+ relatesTo.clear();
+ relatesTo.addAll(v);
+ }
+
+ /**
+ * Method addRelatesTo
+ *
+ * @param uri
+ * @param type
+ * @throws URI.MalformedURIException
*/
- public From get_from() {
- return _from;
+ public void addRelatesTo(String uri, String type)
+ throws URI.MalformedURIException {
+ relatesTo.add(new RelatesTo(uri, type));
}
/**
- * Method set_from
+ * Method setTo
*
- * @param _from
+ * @param ref
*/
- public void set_from(From _from) {
- this._from = _from;
+ public void setTo(EndpointReference ref) {
+ to = new To(ref);
}
/**
- * Method get_messageID
+ * Method getFrom
*
* @return
*/
- public MessageID get_messageID() {
- return _messageID;
+ public EndpointReference getFrom() {
+ return from;
}
/**
- * Method set_messageID
+ * Method setFrom
*
- * @param _messageID
+ * @param ref
*/
- public void set_messageID(MessageID _messageID) {
- this._messageID = _messageID;
+ public void setFrom(EndpointReference ref) {
+ from = new From(ref);
}
/**
- * Method get_recipient
+ * Method getReplyTo
*
* @return
*/
- public Recipient get_recipient() {
- return _recipient;
+ public EndpointReference getReplyTo() {
+ return replyTo;
}
/**
- * Method set_recipient
+ * Method setReplyTo
*
- * @param _recipient
+ * @param ref
*/
- public void set_recipient(Recipient _recipient) {
- this._recipient = _recipient;
+ public void setReplyTo(EndpointReference ref) {
+ replyTo = new ReplyTo(ref);
}
/**
- * Method get_relatesTo
+ * Method getFaultTo
*
* @return
*/
- public RelatesTo get_relatesTo() {
- return _relatesTo;
+ public EndpointReference getFaultTo() {
+ return faultTo;
}
/**
- * Method set_relatesTo
+ * Method setFaultTo
*
- * @param _relatesTo
+ * @param epr
*/
- public void set_relatesTo(RelatesTo _relatesTo) {
- this._relatesTo = _relatesTo;
+ public void setFaultTo(EndpointReference epr) {
+ this.faultTo = new FaultTo(epr);
}
}
+
+
1.2 +19 -0 ws-fx/addressing/src/org/apache/axis/message/addressing/AddressList.java
Index: AddressList.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/AddressList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddressList.java 6 Feb 2004 19:51:28 -0000 1.1
+++ AddressList.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,3 +1,20 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
import java.util.ArrayList;
@@ -15,3 +32,5 @@
public AddressList() {
}
}
+
+
1.2 +19 -0 ws-fx/addressing/src/org/apache/axis/message/addressing/AttributedQName.java
Index: AttributedQName.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/AttributedQName.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AttributedQName.java 6 Feb 2004 19:51:28 -0000 1.1
+++ AttributedQName.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,3 +1,20 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
import javax.xml.namespace.QName;
@@ -18,3 +35,5 @@
super(qname.getNamespaceURI(), qname.getLocalPart(), qname.getPrefix());
}
}
+
+
1.2 +22 -11 ws-fx/addressing/src/org/apache/axis/message/addressing/AttributedURI.java
Index: AttributedURI.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/AttributedURI.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AttributedURI.java 6 Feb 2004 19:51:28 -0000 1.1
+++ AttributedURI.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,3 +1,20 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
import org.apache.axis.types.URI;
@@ -6,24 +23,16 @@
* Class AttributedURI
*
* @author Davanum Srinivas (dims@yahoo.com)
- * @version %I%, %G%
*/
public abstract class AttributedURI extends URI {
/**
* Constructor AttributedURI
*
- * @param URI
- */
- public AttributedURI(URI URI) {
- }
-
- /**
- * Constructor AttributedURI
- *
- * @param aURI
+ * @param uri
*/
- public AttributedURI(AttributedURI aURI) {
+ public AttributedURI(URI uri) {
+ super(uri);
}
/**
@@ -32,3 +41,5 @@
public AttributedURI() {
}
}
+
+
1.2 +153 -3 ws-fx/addressing/src/org/apache/axis/message/addressing/EndpointReference.java
Index: EndpointReference.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/EndpointReference.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EndpointReference.java 6 Feb 2004 19:51:28 -0000 1.1
+++ EndpointReference.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,13 +1,37 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
+import org.apache.axis.message.SOAPEnvelope;
+import org.apache.axis.message.SOAPHeaderElement;
+import org.apache.axis.message.addressing.util.TextExtractor;
import org.apache.axis.types.URI;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* Class EndpointReference
*
* @author Davanum Srinivas (dims@yahoo.com)
*/
-public class EndpointReference {
+public class EndpointReference extends EndpointReferenceType {
/**
* Constructor EndpointReference
@@ -15,13 +39,139 @@
* @param address
*/
public EndpointReference(Address address) {
+ setAddress(address);
+ }
+
+ /**
+ * Constructor EndpointReference
+ *
+ * @param uri
+ */
+ public EndpointReference(URI uri) {
+ setAddress(new Address(uri));
}
/**
* Constructor EndpointReference
*
- * @param URI
+ * @param endpoint
+ */
+ public EndpointReference(EndpointReferenceType endpoint) {
+ super(endpoint);
+ }
+
+ /**
+ * Constructor EndpointReference
+ *
+ * @param endpoint
+ * @throws URI.MalformedURIException
+ */
+ public EndpointReference(final String endpoint)
+ throws URI.MalformedURIException {
+ setAddress(new Address(new URI(endpoint)));
+ }
+
+ /**
+ * Constructor EndpointReference
+ *
+ * @param el
+ * @throws URI.MalformedURIException
+ */
+ public EndpointReference(final Element el)
+ throws URI.MalformedURIException {
+
+ NodeList list = el.getElementsByTagNameNS(Constants.NS_URI_ADDRESSING,
+ Constants.ADDRESS);
+
+ if (list.getLength() > 0) {
+ setAddress(new Address(TextExtractor.getText((Element) list.item(0))));
+ }
+
+ list = el.getElementsByTagNameNS(Constants.NS_URI_ADDRESSING, Constants.PORT_TYPE);
+
+ if (list.getLength() > 0) {
+ setPortType(new PortType(TextExtractor.getText((Element) list.item(0))));
+ }
+
+ list = el.getElementsByTagNameNS(Constants.NS_URI_ADDRESSING,
+ Constants.SERVICE_NAME);
+
+ if (list.getLength() > 0) {
+ Element child = (Element) list.item(0);
+ String portName =
+ child.getAttributeNS(Constants.NS_URI_ADDRESSING, Constants.PORT_NAME);
+ ServiceName serviceName = new ServiceName(TextExtractor.getText(child),
+ portName);
+ setServiceName(serviceName);
+ }
+
+ list = el.getElementsByTagNameNS(Constants.NS_URI_ADDRESSING,
+ Constants.REFERENCE_PROPERTIES);
+
+ if (list.getLength() > 0) {
+ NodeList children = list.item(0).getChildNodes();
+ if (children != null) {
+ for (int i = 0; i < children.getLength(); i++) {
+ Node n = children.item(i);
+ if (n.getNodeType() == Node.ELEMENT_NODE) {
+ getProperties().add((Element) n);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Method toDOM.
+ *
+ * @param doc
*/
- public EndpointReference(URI URI) {
+ public Element toDOM(Document doc) {
+ return toDOM(doc, Constants.ENDPOINT_REFERENCE);
+ }
+
+ /**
+ * Method toDOM.
+ *
+ * @param doc
+ * @param name
+ */
+ public Element toDOM(Document doc, String name) {
+ Element parent = doc.createElementNS(Constants.NS_URI_ADDRESSING, name);
+ if (doc.getDocumentElement() == null) {
+ doc.appendChild(parent);
+ } else {
+ doc.getDocumentElement().appendChild(parent);
+ }
+
+ if (getAddress() != null) {
+ getAddress().append(parent);
+ }
+ if (getPortType() != null) {
+ getPortType().append(parent);
+ }
+ if (getServiceName() != null) {
+ getServiceName().append(parent);
+ }
+ ReferenceProperties referenceProperties = getProperties();
+ if ((null != referenceProperties) && !referenceProperties.isEmpty()) {
+ referenceProperties.append(parent);
+ }
+ return parent;
+ }
+
+ /**
+ * Method toEnvelope
+ *
+ * @param env
+ * @param doc
+ */
+ public void toEnvelope(SOAPEnvelope env, Document doc) {
+ SOAPHeaderElement header =
+ new SOAPHeaderElement(toDOM(doc));
+ header.setMustUnderstand(true);
+ env.addHeader(header);
}
}
+
+
1.2 +88 -49 ws-fx/addressing/src/org/apache/axis/message/addressing/EndpointReferenceType.java
Index: EndpointReferenceType.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/EndpointReferenceType.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EndpointReferenceType.java 6 Feb 2004 19:51:28 -0000 1.1
+++ EndpointReferenceType.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,6 +1,24 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
import org.apache.axis.types.URI;
+import org.w3c.dom.Element;
/**
* Class EndpointReferenceType
@@ -8,118 +26,139 @@
* @author Davanum Srinivas (dims@yahoo.com)
*/
public abstract class EndpointReferenceType {
+ /**
+ * Field address
+ */
+ private Address address;
/**
- * Constructor EndpointReferenceType
- *
- * @param address
+ * Field portType
*/
- public EndpointReferenceType(URI address) {
- }
+ private PortType portType;
/**
- * Constructor EndpointReferenceType
- *
- * @param address
+ * Field serviceName
*/
- public EndpointReferenceType(Address address) {
- }
+ private ServiceName serviceName;
/**
- * Constructor EndpointReferenceType
+ * Field properties
*/
- public EndpointReferenceType() {
- }
+ private ReferenceProperties properties = new ReferenceProperties();
/**
- * Field _address
+ * Constructor EndpointReferenceType
*/
- private Address _address;
+ public EndpointReferenceType() {
+ }
/**
- * Field _portType
+ * Constructor EndpointReferenceType
+ *
+ * @param address
*/
- private PortType _portType;
+ public EndpointReferenceType(URI address) {
+ this.address = new Address(address);
+ }
/**
- * Field _properties
+ * Constructor EndpointReferenceType
+ *
+ * @param address
*/
- private ReferenceProperties _properties;
+ public EndpointReferenceType(Address address) {
+ this.address = address;
+ }
/**
- * Field _serviceName
+ * Constructor EndpointReferenceType
+ *
+ * @param endpoint
*/
- private ServiceName _serviceName;
+ public EndpointReferenceType(EndpointReferenceType endpoint) {
+ setAddress(endpoint.getAddress());
+ setPortType(endpoint.getPortType());
+ setServiceName(endpoint.getServiceName());
+ ReferenceProperties properties = endpoint.getProperties();
+ if (properties != null) {
+ for (int i = 0; i < properties.size(); i++) {
+ Element elem = (Element) properties.get(i);
+ this.getProperties().add(elem);
+ }
+ }
+ }
/**
- * Method get_address
+ * Method getAddress
*
* @return
*/
- public Address get_address() {
- return _address;
+ public Address getAddress() {
+ return address;
}
/**
- * Method set_address
+ * Method setAddress
*
- * @param _address
+ * @param address
*/
- public void set_address(Address _address) {
- this._address = _address;
+ public void setAddress(Address address) {
+ this.address = address;
}
/**
- * Method get_portType
+ * Method getPortType
*
* @return
*/
- public PortType get_portType() {
- return _portType;
+ public PortType getPortType() {
+ return portType;
}
/**
- * Method set_portType
+ * Method setPortType
*
- * @param _portType
+ * @param portType
*/
- public void set_portType(PortType _portType) {
- this._portType = _portType;
+ public void setPortType(PortType portType) {
+ this.portType = portType;
}
/**
- * Method get_properties
+ * Method getProperties
*
* @return
*/
- public ReferenceProperties get_properties() {
- return _properties;
+ public ReferenceProperties getProperties() {
+ return properties;
}
/**
- * Method set_properties
+ * Method setProperties
*
- * @param _properties
+ * @param properties
*/
- public void set_properties(ReferenceProperties _properties) {
- this._properties = _properties;
+ public void setProperties(ReferenceProperties properties) {
+ this.properties = properties;
}
/**
- * Method get_serviceName
+ * Method getServiceName
*
* @return
*/
- public ServiceName get_serviceName() {
- return _serviceName;
+ public ServiceName getServiceName() {
+ return serviceName;
}
/**
- * Method set_serviceName
+ * Method setServiceName
*
- * @param _serviceName
+ * @param serviceName
*/
- public void set_serviceName(ServiceName _serviceName) {
- this._serviceName = _serviceName;
+ public void setServiceName(ServiceName serviceName) {
+ this.serviceName = serviceName;
}
}
+
+
1.2 +44 -4 ws-fx/addressing/src/org/apache/axis/message/addressing/FaultTo.java
Index: FaultTo.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/FaultTo.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FaultTo.java 6 Feb 2004 19:51:28 -0000 1.1
+++ FaultTo.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,27 +1,67 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
import org.apache.axis.types.URI;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* Class FaultTo
*
* @author Davanum Srinivas (dims@yahoo.com)
*/
-public class FaultTo extends EndpointReferenceType {
-
+public class FaultTo extends EndpointReference {
/**
* Constructor FaultTo
*
* @param address
*/
public FaultTo(Address address) {
+ super(address);
+ }
+
+ /**
+ * Constructor FaultTo
+ *
+ * @param uri
+ */
+ public FaultTo(URI uri) {
+ super(uri);
}
/**
* Constructor FaultTo
*
- * @param URI
+ * @param endpoint
+ */
+ public FaultTo(EndpointReferenceType endpoint) {
+ super(endpoint);
+ }
+
+ /**
+ * Method toDOM.
+ *
+ * @param doc
*/
- public FaultTo(URI URI) {
+ public Element toDOM(Document doc) {
+ return toDOM(doc, Constants.FAULT_TO);
}
}
+
+
1.2 +44 -4 ws-fx/addressing/src/org/apache/axis/message/addressing/From.java
Index: From.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/From.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- From.java 6 Feb 2004 19:51:28 -0000 1.1
+++ From.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,27 +1,67 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
import org.apache.axis.types.URI;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* Class From
*
* @author Davanum Srinivas (dims@yahoo.com)
*/
-public class From extends EndpointReferenceType {
-
+public class From extends EndpointReference {
/**
* Constructor From
*
* @param address
*/
public From(Address address) {
+ super(address);
+ }
+
+ /**
+ * Constructor From
+ *
+ * @param uri
+ */
+ public From(URI uri) {
+ super(uri);
}
/**
* Constructor From
*
- * @param URI
+ * @param endpoint
+ */
+ public From(EndpointReferenceType endpoint) {
+ super(endpoint);
+ }
+
+ /**
+ * Method toDOM.
+ *
+ * @param doc
*/
- public From(URI URI) {
+ public Element toDOM(Document doc) {
+ return toDOM(doc, Constants.FROM);
}
}
+
+
1.2 +22 -3 ws-fx/addressing/src/org/apache/axis/message/addressing/MessageID.java
Index: MessageID.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/MessageID.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MessageID.java 6 Feb 2004 19:51:28 -0000 1.1
+++ MessageID.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,3 +1,20 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
import org.apache.axis.types.URI;
@@ -8,13 +25,13 @@
* @author Davanum Srinivas (dims@yahoo.com)
*/
public class MessageID extends AttributedURI {
-
/**
* Constructor MessageID
*
- * @param URI
+ * @param uri
*/
- public MessageID(URI URI) {
+ public MessageID(URI uri) {
+ super(uri);
}
/**
@@ -23,3 +40,5 @@
public MessageID() {
}
}
+
+
1.2 +42 -1 ws-fx/addressing/src/org/apache/axis/message/addressing/PortType.java
Index: PortType.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/PortType.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PortType.java 6 Feb 2004 19:51:28 -0000 1.1
+++ PortType.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,5 +1,24 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
+import org.w3c.dom.Element;
+
import javax.xml.namespace.QName;
/**
@@ -8,7 +27,6 @@
* @author Davanum Srinivas (dims@yahoo.com)
*/
public class PortType extends AttributedQName {
-
/**
* Constructor PortType
*
@@ -17,4 +35,27 @@
public PortType(QName qname) {
super(qname);
}
+
+ /**
+ * Constructor PortType
+ *
+ * @param qname
+ */
+ public PortType(String qname) {
+ this(new QName(qname));
+ }
+
+ /**
+ * append DOM node to parent
+ *
+ * @param parent
+ */
+ public void append(Element parent) {
+ Element pt = parent.getOwnerDocument().createElementNS(Constants.NS_URI_ADDRESSING,
+ Constants.PORT_TYPE);
+ pt.appendChild(parent.getOwnerDocument().createTextNode(toString()));
+ parent.appendChild(pt);
+ }
}
+
+
1.2 +32 -2 ws-fx/addressing/src/org/apache/axis/message/addressing/Recipient.java
Index: Recipient.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/Recipient.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Recipient.java 6 Feb 2004 19:51:28 -0000 1.1
+++ Recipient.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,20 +1,39 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
import org.apache.axis.types.URI;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* Class Recipient
*
* @author Davanum Srinivas (dims@yahoo.com)
*/
-public class Recipient extends EndpointReferenceType {
-
+public class Recipient extends EndpointReference {
/**
* Constructor Recipient
*
* @param address
*/
public Recipient(Address address) {
+ super(address);
}
/**
@@ -25,4 +44,15 @@
public Recipient(URI uri) {
super(uri);
}
+
+ /**
+ * Method toDOM.
+ *
+ * @param doc
+ */
+ public Element toDOM(Document doc) {
+ return toDOM(doc, Constants.RECIPIENT);
+ }
}
+
+
1.2 +56 -1 ws-fx/addressing/src/org/apache/axis/message/addressing/ReferenceProperties.java
Index: ReferenceProperties.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/ReferenceProperties.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ReferenceProperties.java 6 Feb 2004 19:51:28 -0000 1.1
+++ ReferenceProperties.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,9 +1,64 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+
/**
* Class ReferenceProperties
*
* @author Davanum Srinivas (dims@yahoo.com)
*/
-public class ReferenceProperties {
+public class ReferenceProperties extends LinkedList {
+ /**
+ * Constructor ReferenceProperties
+ */
+ public ReferenceProperties() {
+ }
+
+ /**
+ * Constructor ReferenceProperties
+ *
+ * @param p
+ */
+ public ReferenceProperties(ReferenceProperties p) {
+ super(p);
+ }
+
+ /**
+ * append DOM node to parent
+ *
+ * @param parent
+ */
+ public void append(Element parent) {
+ Element refProp =
+ parent.getOwnerDocument().createElementNS(Constants.NS_URI_ADDRESSING,
+ Constants.REFERENCE_PROPERTIES);
+ for (Iterator i = this.iterator(); i.hasNext();) {
+ Node refNode = (Node) i.next();
+ refProp.appendChild(parent.getOwnerDocument().importNode(refNode, true));
+ }
+ parent.appendChild(refProp);
+ }
}
+
+
1.2 +73 -12 ws-fx/addressing/src/org/apache/axis/message/addressing/RelatesTo.java
Index: RelatesTo.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/RelatesTo.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RelatesTo.java 6 Feb 2004 19:51:28 -0000 1.1
+++ RelatesTo.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,3 +1,20 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
import org.apache.axis.types.URI;
@@ -9,37 +26,81 @@
*
* @author Davanum Srinivas (dims@yahoo.com)
*/
-public class RelatesTo extends AttributedURI {
+public class RelatesTo {
+ /**
+ * Field type
+ */
+ private URI uri;
+
+ /**
+ * Field type
+ */
+ private QName type;
/**
* Constructor RelatesTo
*
- * @param uri
+ * @param uri
+ * @param type
+ * @throws URI.MalformedURIException
*/
- public RelatesTo(URI uri) {
- super(uri);
+ public RelatesTo(String uri, String type) throws URI.MalformedURIException {
+
+ this.uri = new URI(uri);
+ this.type = (type == null)
+ ? Constants.QNAME_RESPONSE
+ : new QName(type);
}
/**
- * Field _type
+ * Constructor RelatesTo
+ *
+ * @param uri
+ * @param type
*/
- private QName _type;
+ public RelatesTo(URI uri, QName type) {
+
+ this.uri = uri;
+ this.type = (type == null)
+ ? Constants.QNAME_RESPONSE
+ : type;
+ }
/**
- * Method get_type
+ * Method getType
*
* @return
*/
- public QName get_type() {
- return _type;
+ public QName getType() {
+ return type;
}
/**
* Method set_type
*
- * @param _type
+ * @param type
*/
- public void set_type(QName _type) {
- this._type = _type;
+ public void setType(QName type) {
+ this.type = type;
+ }
+
+ /**
+ * Method getURI
+ *
+ * @return
+ */
+ public URI getURI() {
+ return uri;
+ }
+
+ /**
+ * Method setURI
+ *
+ * @param uri
+ */
+ public void setURI(URI uri) {
+ this.uri = uri;
}
}
+
+
1.2 +42 -2 ws-fx/addressing/src/org/apache/axis/message/addressing/ReplyTo.java
Index: ReplyTo.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/ReplyTo.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ReplyTo.java 6 Feb 2004 19:51:28 -0000 1.1
+++ ReplyTo.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,20 +1,39 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
import org.apache.axis.types.URI;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* Class ReplyTo
*
* @author Davanum Srinivas (dims@yahoo.com)
*/
-public class ReplyTo extends EndpointReferenceType {
-
+public class ReplyTo extends EndpointReference {
/**
* Constructor ReplyTo
*
* @param address
*/
public ReplyTo(Address address) {
+ super(address);
}
/**
@@ -23,5 +42,26 @@
* @param address
*/
public ReplyTo(URI address) {
+ super(address);
+ }
+
+ /**
+ * Constructor FaultTo
+ *
+ * @param endpoint
+ */
+ public ReplyTo(EndpointReferenceType endpoint) {
+ super(endpoint);
+ }
+
+ /**
+ * Method toDOM.
+ *
+ * @param doc
+ */
+ public Element toDOM(Document doc) {
+ return toDOM(doc, Constants.REPLY_TO);
}
}
+
+
1.2 +62 -10 ws-fx/addressing/src/org/apache/axis/message/addressing/ServiceName.java
Index: ServiceName.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/ServiceName.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServiceName.java 6 Feb 2004 19:51:28 -0000 1.1
+++ ServiceName.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,5 +1,25 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+
import javax.xml.namespace.QName;
/**
@@ -8,36 +28,68 @@
* @author Davanum Srinivas (dims@yahoo.com)
*/
public class ServiceName extends AttributedQName {
+ /**
+ * Field port
+ */
+ private String port;
/**
* Constructor ServiceName
*
* @param qname
+ * @param port
*/
- public ServiceName(QName qname) {
+ public ServiceName(QName qname, String port) {
super(qname);
+ this.port = port;
}
/**
- * Field _port
+ * Constructor ServiceName
+ *
+ * @param qname
+ * @param port
*/
- private String _port;
+ public ServiceName(String qname, String port) {
+ this(new QName(qname), port);
+ }
/**
- * Method get_port
+ * Method getPort
*
* @return
*/
- public String get_port() {
- return _port;
+ public String getPort() {
+ return port;
+ }
+
+ /**
+ * Method setPort
+ *
+ * @param port
+ */
+ public void setPort(String port) {
+ this.port = port;
}
/**
- * Method set_port
+ * append DOM node to parent
*
- * @param _port
+ * @param parent
*/
- public void set_port(String _port) {
- this._port = _port;
+ public void append(Element parent) {
+ Element sn = parent.getOwnerDocument().createElementNS(Constants.NS_URI_ADDRESSING,
+ Constants.SERVICE_NAME);
+ sn.appendChild(parent.getOwnerDocument().createTextNode(toString()));
+ if (getPort() != null) {
+ Attr attr =
+ parent.getOwnerDocument().createAttributeNS(Constants.NS_URI_ADDRESSING,
+ Constants.PORT_NAME);
+ attr.setValue(getPort());
+ sn.appendChild(attr);
+ }
+ parent.appendChild(sn);
}
}
+
+
1.2 +53 -5 ws-fx/addressing/src/org/apache/axis/message/addressing/To.java
Index: To.java
===================================================================
RCS file: /home/cvs/ws-fx/addressing/src/org/apache/axis/message/addressing/To.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- To.java 6 Feb 2004 19:51:28 -0000 1.1
+++ To.java 10 Feb 2004 19:18:35 -0000 1.2
@@ -1,27 +1,75 @@
+/*
+ * Copyright 1999-2004 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.axis.message.addressing;
import org.apache.axis.types.URI;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* Class To
*
* @author Davanum Srinivas (dims@yahoo.com)
*/
-public class To extends AttributedURI {
+public class To extends EndpointReference {
+ /**
+ * Constructor To
+ *
+ * @param uri
+ */
+ public To(AttributedURI uri) {
+ super(uri);
+ }
/**
* Constructor To
*
- * @param URI
+ * @param uri
*/
- public To(AttributedURI URI) {
+ public To(URI uri) {
+ super(uri);
}
/**
* Constructor To
*
- * @param URI
+ * @param uri
*/
- public To(URI URI) {
+ public To(String uri) throws URI.MalformedURIException {
+ super(new URI(uri));
+ }
+
+ /**
+ * Constructor To
+ *
+ * @param endpoint
+ */
+ public To(EndpointReferenceType endpoint) {
+ super(endpoint);
+ }
+
+ /**
+ * Method toDOM.
+ *
+ * @param doc
+ */
+ public Element toDOM(Document doc) {
+ return toDOM(doc, Constants.TO);
}
}
+
+
1.1 ws-fx/addressing/src/org/apache/axis/message/addressing/Constants.java
Index: Constants.java
===================================================================
/*
* Copyright 1999-2004 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.axis.message.addressing;
import javax.xml.namespace.QName;
/**
* Interface Constants
*
* @author Davanum Srinivas (dims@yahoo.com)
*/
public interface Constants {
/**
* Field NS_PREFIX_ADDRESSING
*/
public static final String NS_PREFIX_ADDRESSING = "wsa";
/**
* Field NS_URI_ADDRESSING
*/
public static final String NS_URI_ADDRESSING =
"http://schemas.xmlsoap.org/ws/2003/03/addressing";
/**
* Field NS_URI_ANONYMOUS
*/
public static final String NS_URI_ANONYMOUS = NS_URI_ADDRESSING
+ "/role/anonymous";
/**
* Field ENDPOINT_REFERENCE
*/
public static final String ENDPOINT_REFERENCE = "EndpointReference";
/**
* Field MESSAGE_ID
*/
public static final String MESSAGE_ID = "MessageID";
/**
* Field RELATES_TO
*/
public static final String RELATES_TO = "RelatesTo";
/**
* Field RELATIONSHIP_TYPE
*/
public static final String RELATIONSHIP_TYPE = "RelationshipType";
/**
* Field ACTION
*/
public static final String ACTION = "Action";
/**
* Field ADDRESS
*/
public static final String ADDRESS = "Address";
/**
* Field REFERENCE_PROPERTIES
*/
public static final String REFERENCE_PROPERTIES = "ReferenceProperties";
/**
* Field SERVICE_NAME
*/
public static final String SERVICE_NAME = "ServiceName";
/**
* Field PORT_NAME
*/
public static final String PORT_NAME = "PortName";
/**
* Field PORT_TYPE
*/
public static final String PORT_TYPE = "PortType";
/**
* Field RESPONSE
*/
public static final String RESPONSE = "Response";
/**
* Field TO
*/
public static final String TO = "To";
/**
* Field REPLY_TO
*/
public static final String REPLY_TO = "ReplyTo";
/**
* Field FAULT_TO
*/
public static final String FAULT_TO = "FaultTo";
/**
* Field FROM
*/
public static final String FROM = "From";
/**
* Field RECIPIENT
*/
public static final String RECIPIENT = "Recipient";
/**
* Field QNAME_ENDPOINT_REFERENCE
*/
public static final QName QNAME_ENDPOINT_REFERENCE =
new QName(NS_URI_ADDRESSING, ENDPOINT_REFERENCE);
/**
* Field QNAME_ADDRESS
*/
public static final QName QNAME_ADDRESS = new QName(NS_URI_ADDRESSING,
ADDRESS);
/**
* Field QNAME_REFERENCE_PROPERTIES
*/
public static final QName QNAME_REFERENCE_PROPERTIES =
new QName(NS_URI_ADDRESSING, REFERENCE_PROPERTIES);
/**
* Field QNAME_RESPONSE
*/
public static final QName QNAME_RESPONSE = new QName(NS_URI_ADDRESSING,
RESPONSE);
/**
* Field ENV_ADDRESSING_REQUEST_HEADERS
*/
public static final String ENV_ADDRESSING_REQUEST_HEADERS =
"org.apache.axis.message.addressing..REQUEST.HEADERS";
/**
* Field ENV_ADDRESSING_RESPONSE_HEADERS
*/
public static final String ENV_ADDRESSING_RESPONSE_HEADERS =
"org.apache.axis.message.addressing.RESPONSE.HEADERS";
}
1.1 ws-fx/addressing/test/addressing/TestSerDeser.java
Index: TestSerDeser.java
===================================================================
/*
* Copyright 1999-2004 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 addressing;
import junit.framework.TestCase;
import org.apache.axis.Message;
import org.apache.axis.message.addressing.AddressingHeaders;
import org.apache.axis.message.addressing.RelatesTo;
import java.io.ByteArrayInputStream;
/**
* Class ReplyTo
*
* @author Davanum Srinivas (dims@yahoo.com)
*/
public class TestSerDeser extends TestCase {
String xml = "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
" xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2003/03/addressing\"\n" +
" xmlns:f123=\"http://www.fabrikam123.com/svc53\" \n" +
">\n" +
" <S:Header>\n" +
" <wsa:MessageID>uuid:aaaabbbb-cccc-dddd-eeee-ffffffffffff\n" +
" </wsa:MessageID>\n" +
" <wsa:RelatesTo>uuid:11112222-3333-4444-5555-666666666666\n" +
" </wsa:RelatesTo>\n" +
" <wsa:ReplyTo>\n" +
" <wsa:Address>http://business456.com/client1</wsa:Address>\n" +
" </wsa:ReplyTo>\n" +
" <wsa:FaultTo>\n" +
" <wsa:Address>http://business456.com/deadletters</wsa:Address>\n" +
" </wsa:FaultTo>\n" +
" <wsa:To S:mustUnderstand=\"1\">mailto:joe@fabrikam123.com</wsa:To>\n" +
" <wsa:Action>http://fabrikam123.com/mail#Delete</wsa:Action>\n" +
" </S:Header>\n" +
" <S:Body>\n" +
" <f123:Delete>\n" +
" <maxCount>42</maxCount>\n" +
" </f123:Delete>\n" +
" </S:Body>\n" +
"</S:Envelope>";
public void testSOAPEnvelope() throws Exception {
Message msg = new Message(new ByteArrayInputStream(xml.getBytes()));
AddressingHeaders headers = new AddressingHeaders(msg.getSOAPEnvelope());
System.out.println("Header/MessageID : " + headers.getMessageID());
System.out.println("Header/Action : " + headers.getAction());
System.out.println("Header/To : " + headers.getTo().getAddress());
System.out.println("Header/RelatesTo : " + ((RelatesTo) headers.getRelatesTo().get(0)).getURI());
System.out.println("Header/FaultTo/Address : " + headers.getFaultTo().getAddress());
System.out.println("=================================");
System.out.println(msg.getSOAPPartAsString());
System.out.println("=================================");
headers.toEnvelope(msg.getSOAPEnvelope());
System.out.println("=================================");
System.out.println(msg.getSOAPPartAsString());
System.out.println("=================================");
}
}
1.1 ws-fx/addressing/src/org/apache/axis/message/addressing/util/TextExtractor.java
Index: TextExtractor.java
===================================================================
/*
* Copyright 1999-2004 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.axis.message.addressing.util;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.traversal.DocumentTraversal;
import org.w3c.dom.traversal.NodeFilter;
import org.w3c.dom.traversal.NodeIterator;
/**
* Class Action
*
* @author Davanum Srinivas (dims@yahoo.com)
*/
public class TextExtractor {
public static String getText(Node node) {
if (node == null) return "";
// Set up the iterator
Document doc = node.getOwnerDocument();
DocumentTraversal traversable = (DocumentTraversal) doc;
int whatToShow
= NodeFilter.SHOW_TEXT | NodeFilter.SHOW_CDATA_SECTION;
NodeIterator iterator = traversable.createNodeIterator(node,
whatToShow, null, true);
// Extract the text
StringBuffer result = new StringBuffer();
Node current;
while ((current = iterator.nextNode()) != null) {
result.append(current.getNodeValue());
}
return result.toString();
}
}