Author: veithen
Date: Tue May 25 19:25:09 2010
New Revision: 948188
URL: http://svn.apache.org/viewvc?rev=948188&view=rev
Log:
Making some progress with the SOAP/UDP scenario with WS-Addressing based
dispatching.
Modified:
axis/axis2/java/transports/trunk/modules/base/src/main/java/org/apache/axis2/transport/base/ProtocolEndpoint.java
axis/axis2/java/transports/trunk/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/AbstractDatagramTransportListener.java
axis/axis2/java/transports/trunk/modules/udp/src/main/java/org/apache/axis2/transport/udp/Endpoint.java
axis/axis2/java/transports/trunk/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPSender.java
axis/axis2/java/transports/trunk/src/site/apt/udp.apt
Modified:
axis/axis2/java/transports/trunk/modules/base/src/main/java/org/apache/axis2/transport/base/ProtocolEndpoint.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/base/src/main/java/org/apache/axis2/transport/base/ProtocolEndpoint.java?rev=948188&r1=948187&r2=948188&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/base/src/main/java/org/apache/axis2/transport/base/ProtocolEndpoint.java
(original)
+++
axis/axis2/java/transports/trunk/modules/base/src/main/java/org/apache/axis2/transport/base/ProtocolEndpoint.java
Tue May 25 19:25:09 2010
@@ -22,6 +22,7 @@ import javax.xml.namespace.QName;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.AxisService;
@@ -53,8 +54,23 @@ public abstract class ProtocolEndpoint {
return service;
}
+ /**
+ * Get the name of the service to which messages received by this endpoint
are pre-dispatched.
+ *
+ * @return the name of the service, or <code>null</code> if message are
not pre-dispatched
+ */
public final String getServiceName() {
- return service.getName();
+ return service == null ? null : service.getName();
+ }
+
+ /**
+ * Get the Axis2 configuration context. This is a convenience method that
can be used by
+ * subclasses to get the {...@link ConfigurationContext} object from the
listener.
+ *
+ * @return the configuration context
+ */
+ protected final ConfigurationContext getConfigurationContext() {
+ return listener.getConfigurationContext();
}
/**
@@ -93,6 +109,16 @@ public abstract class ProtocolEndpoint {
*/
public abstract EndpointReference[] getEndpointReferences(AxisService
service, String ip) throws AxisFault;
+ /**
+ * Get a short description of this endpoint suitable for inclusion in log
messages.
+ *
+ * @return a short description of the endpoint
+ */
+ // TODO: we should implement this method in all derived transports and
make it abstract here
+ public String getDescription() {
+ return toString();
+ }
+
public MessageContext createMessageContext() throws AxisFault {
MessageContext msgContext = listener.createMessageContext();
Modified:
axis/axis2/java/transports/trunk/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/AbstractDatagramTransportListener.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/AbstractDatagramTransportListener.java?rev=948188&r1=948187&r2=948188&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/AbstractDatagramTransportListener.java
(original)
+++
axis/axis2/java/transports/trunk/modules/base/src/main/java/org/apache/axis2/transport/base/datagram/AbstractDatagramTransportListener.java
Tue May 25 19:25:09 2010
@@ -70,12 +70,10 @@ public abstract class AbstractDatagramTr
dispatcher.addEndpoint(endpoint);
} catch (IOException ex) {
// TODO: passing endpoint.getService() is not correct because it
may be null
- throw new AxisFault("Unable to listen on endpoint "
- + endpoint.getEndpointReferences(endpoint.getService(),
defaultIp)[0], ex);
+ throw new AxisFault("Unable to listen on endpoint " +
endpoint.getDescription(), ex);
}
if (log.isDebugEnabled()) {
- log.debug("Started listening on endpoint " +
- endpoint.getEndpointReferences(endpoint.getService(),
defaultIp)[0] +
+ log.debug("Started listening on endpoint " +
endpoint.getDescription() +
" [contentType=" + endpoint.getContentType() +
"; service=" + endpoint.getServiceName() + "]");
}
Modified:
axis/axis2/java/transports/trunk/modules/udp/src/main/java/org/apache/axis2/transport/udp/Endpoint.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/udp/src/main/java/org/apache/axis2/transport/udp/Endpoint.java?rev=948188&r1=948187&r2=948188&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/udp/src/main/java/org/apache/axis2/transport/udp/Endpoint.java
(original)
+++
axis/axis2/java/transports/trunk/modules/udp/src/main/java/org/apache/axis2/transport/udp/Endpoint.java
Tue May 25 19:25:09 2010
@@ -44,6 +44,11 @@ public class Endpoint extends DatagramEn
}
@Override
+ public String getDescription() {
+ return "*:" + port;
+ }
+
+ @Override
public boolean loadConfiguration(ParameterInclude params) throws AxisFault
{
port = ParamUtils.getOptionalParamInt(params, UDPConstants.PORT_KEY,
-1);
if (port == -1) {
@@ -63,7 +68,20 @@ public class Endpoint extends DatagramEn
throw new AxisFault("Unable to determine the host's IP
address", ex);
}
}
- return new EndpointReference[] { new EndpointReference("udp://" + ip +
":" + getPort()
- + "?contentType=" + getContentType()) };
+ StringBuilder epr = new StringBuilder("udp://");
+ epr.append(ip);
+ epr.append(':');
+ epr.append(getPort());
+ // If messages are predispatched to a service, then WS-Addressing
will be used and we
+ // need to include the service path in the EPR.
+ if (getService() == null) {
+ epr.append('/');
+ epr.append(getConfigurationContext().getServiceContextPath());
+ epr.append('/');
+ epr.append(service.getName());
+ }
+ epr.append("?contentType=");
+ epr.append(getContentType());
+ return new EndpointReference[] { new EndpointReference(epr.toString())
};
}
}
Modified:
axis/axis2/java/transports/trunk/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPSender.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPSender.java?rev=948188&r1=948187&r2=948188&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPSender.java
(original)
+++
axis/axis2/java/transports/trunk/modules/udp/src/main/java/org/apache/axis2/transport/udp/UDPSender.java
Tue May 25 19:25:09 2010
@@ -73,6 +73,9 @@ public class UDPSender extends AbstractT
byte[] payload = messageFormatter.getBytes(msgContext, format);
try {
DatagramSocket socket = new DatagramSocket();
+ if (log.isDebugEnabled()) {
+ log.debug("Sending " + payload.length + " bytes to " +
udpOutInfo.getAddress());
+ }
try {
socket.send(new DatagramPacket(payload, payload.length,
udpOutInfo.getAddress()));
if (!msgContext.getOptions().isUseSeparateListener() &&
Modified: axis/axis2/java/transports/trunk/src/site/apt/udp.apt
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/src/site/apt/udp.apt?rev=948188&r1=948187&r2=948188&view=diff
==============================================================================
--- axis/axis2/java/transports/trunk/src/site/apt/udp.apt (original)
+++ axis/axis2/java/transports/trunk/src/site/apt/udp.apt Tue May 25 19:25:09
2010
@@ -57,9 +57,17 @@ JMS Transport
[<<<transport.udp.maxPacketSize>>> (optional, defaults to 1024)]
The maximum UDP packet size.
-** {Examples}
+* {Transport sender}
-*** {Enabling SOAP over UDP at the transport level}
+ The UDP transport sender can be enabled in <<<axis2.xml>>> using the
following declaration:
+
++----------------------------+
+<transportSender name="udp" class="org.apache.axis2.transport.udp.UDPSender"/>
++----------------------------+
+
+* {Examples}
+
+** {Enabling SOAP over UDP at the transport level}
The following declaration in <<<axis2.xml>>> enables SOAP over UDP on port
3333 and
allows all services (for which UDP is in the list of exposed transports) to
receive
@@ -79,3 +87,33 @@ JMS Transport
+----------------------------+
<module ref="addressing"/>
+----------------------------+
+
+ With the configuration shown above, the UDP transport would generate
bindings with the
+ following EPR:
+
++----------------------------+
+udp://localhost:3333/axis2/services/Version?contentType=text/xml
++----------------------------+
+
+ The following example shows a message that can be sent to the Version
service over UDP:
+
++----------------------------+
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:wsa="http://www.w3.org/2005/08/addressing">
+ <SOAP-ENV:Header>
+ <wsa:MessageID>1234</wsa:MessageID>
+
<wsa:To>udp://localhost:3333/axis2/services/Version?contentType=text/xml</wsa:To>
+ <wsa:Action>urn:getVersion</wsa:Action>
+ </SOAP-ENV:Header>
+ <SOAP-ENV:Body>
+ </SOAP-ENV:Body>
+</SOAP-ENV:Envelope>
++----------------------------+
+
+ On most Linux/Unix systems (including Mac OS X), the <<<nc>>> utility is
available to send
+ UDP messages and can be used to test the transport. To do this, save the
message into
+ <<<test-message.xml>>> and execute the following command:
+
++----------------------------+
+nc -u 127.0.0.1 3333 < test-message.xml
++----------------------------+