You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pubscribe-dev@ws.apache.org by sc...@apache.org on 2005/02/03 19:26:10 UTC
svn commit: r151198 - in incubator/hermes/trunk/src:
java/org/apache/ws/addressing/ java/org/apache/ws/notification/base/v1_2/
java/org/apache/ws/notification/topics/impl/ test/org/
Author: scamp
Date: Thu Feb 3 10:26:08 2005
New Revision: 151198
URL: http://svn.apache.org/viewcvs?view=rev&rev=151198
Log: (empty)
Added:
incubator/hermes/trunk/src/java/org/apache/ws/addressing/Addressing_03_2003_Constants.java
incubator/hermes/trunk/src/test/org/
Modified:
incubator/hermes/trunk/src/java/org/apache/ws/addressing/XmlBeansEndpointReference.java
incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v1_2/BaseNotification1_2Constants.java
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleSubscriptionTopicListener.java
Added: incubator/hermes/trunk/src/java/org/apache/ws/addressing/Addressing_03_2003_Constants.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/addressing/Addressing_03_2003_Constants.java?view=auto&rev=151198
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/addressing/Addressing_03_2003_Constants.java (added)
+++ incubator/hermes/trunk/src/java/org/apache/ws/addressing/Addressing_03_2003_Constants.java Thu Feb 3 10:26:08 2005
@@ -0,0 +1,35 @@
+/*=============================================================================*
+ * Copyright 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.ws.addressing;
+
+
+/**
+ * @author Sal Campana
+ */
+public interface Addressing_03_2003_Constants
+{
+ /** DOCUMENT_ME */
+ String NSURI_WSRL_SCHEMA = "http://schemas.xmlsoap.org/ws/2003/03/addressing";
+
+ /**
+ * DOCUMENT_ME
+ */
+ String NSPREFIX_WSRL_SCHEMA = "wsa";
+
+ String TO = "To";
+
+ String ACTION = "Action";
+}
\ No newline at end of file
Modified: incubator/hermes/trunk/src/java/org/apache/ws/addressing/XmlBeansEndpointReference.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/addressing/XmlBeansEndpointReference.java?view=diff&r1=151197&r2=151198
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/addressing/XmlBeansEndpointReference.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/addressing/XmlBeansEndpointReference.java Thu Feb 3 10:26:08 2005
@@ -49,11 +49,16 @@
public XmlBeansEndpointReference( org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType epr )
{
m_xmlObjectEPR = epr;
- m_address = epr.getAddress( ).getStringValue( );
- m_portTypeQName = epr.getPortType( ).getQNameValue( );
- m_servicePortName = epr.getServiceName( ).getPortName( );
- m_serviceQName = epr.getServiceName( ).getQNameValue( );
- m_referenceProps = XmlBeanUtils.getChildElements(epr.getReferenceProperties());
+ if(epr.getAddress()!=null)
+ m_address = epr.getAddress( ).getStringValue( );
+ if(epr.getPortType()!=null)
+ m_portTypeQName = epr.getPortType( ).getQNameValue( );
+ if(epr.getServiceName()!=null)
+ m_servicePortName = epr.getServiceName( ).getPortName( );
+ if(epr.getServiceName()!=null)
+ m_serviceQName = epr.getServiceName( ).getQNameValue( );
+ if(epr.getReferenceProperties()!=null)
+ m_referenceProps = XmlBeanUtils.getChildElements(epr.getReferenceProperties());
}
/**
Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v1_2/BaseNotification1_2Constants.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v1_2/BaseNotification1_2Constants.java?view=diff&r1=151197&r2=151198
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v1_2/BaseNotification1_2Constants.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/base/v1_2/BaseNotification1_2Constants.java Thu Feb 3 10:26:08 2005
@@ -41,4 +41,6 @@
*/
String NSPREFIX_WSNT_WSDL = "wsntw";
+ String NOTIFY_ACTION_URL = BaseNotification1_2Constants.NSURI_WSNT_WSDL + "/Notify";
+
}
Modified: incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleSubscriptionTopicListener.java
URL: http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleSubscriptionTopicListener.java?view=diff&r1=151197&r2=151198
==============================================================================
--- incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleSubscriptionTopicListener.java (original)
+++ incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/SimpleSubscriptionTopicListener.java Thu Feb 3 10:26:08 2005
@@ -20,8 +20,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.XmlObjectWrapper;
+import org.apache.ws.addressing.Addressing_03_2003_Constants;
import org.apache.ws.addressing.EndpointReference;
import org.apache.ws.notification.base.Subscription;
+import org.apache.ws.notification.base.v1_2.BaseNotification1_2Constants;
import org.apache.ws.notification.topics.Topic;
import org.apache.ws.notification.topics.TopicExpression;
import org.apache.ws.notification.topics.TopicExpressionEngine;
@@ -30,17 +32,24 @@
import org.apache.ws.notification.topics.topicexpression.impl.TopicExpressionException;
import org.apache.ws.pubsub.NotificationConsumer;
import org.apache.ws.pubsub.emitter.EmitterTask;
+import org.apache.ws.util.XmlBeanUtils;
import org.apache.ws.util.thread.NamedThread;
+import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotificationMessageHolderType;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotifyDocument;
import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.TopicExpressionType;
import org.w3c.dom.Document;
import org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.ReferencePropertiesType;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
import javax.xml.soap.SOAPMessage;
import java.io.Serializable;
import java.net.URL;
@@ -143,7 +152,7 @@
System.out.println("Notification received for subscription with Id " + subscription.getID() + "; value: " + msg);
EndpointReference epr = subscription.getNotificationConsumer().getEPR();
-
+
if(subscription.getUseNotify())
{
NotifyDocument notifyDoc = NotifyDocument.Factory.newInstance();
@@ -153,23 +162,22 @@
//assumes xmlobject for msg...this needs to change
notificationMessageHolderType.setMessage((XmlObject) msg);
-
- //todo once epr is resolved
+ //set the producer ref
notificationMessageHolderType.setProducerReference((EndpointReferenceType) ((XmlObjectWrapper)subscription.getNotificationProducer().getEPR()).getXmlObject());
TopicExpressionEngine engine =
TopicExpressionEngineImpl.getInstance();
TopicExpression topicExpressionIntf = subscription.getTopicExpression();
- TopicExpressionType tp = TopicExpressionType.Factory.newInstance();
- //todo ???
-
+ TopicExpressionType tp = (TopicExpressionType) ((XmlObjectWrapper)topicExpressionIntf).getXmlObject();
String dialect = topicExpressionIntf.getDialect().toString();
+
TopicExpressionEvaluator evaluator =
engine.getEvaluator(dialect);
- TopicExpression topicExpression =
- null;
+
+ //TopicExpression
+ TopicExpression topicExpression = null;
try
{
topicExpression = (TopicExpression) evaluator.toTopicExpression(
@@ -177,24 +185,16 @@
}
catch (TopicExpressionException e)
{
-
-
+ //todo do something
}
- notificationMessageHolderType.setTopic((TopicExpressionType) ((XmlObjectWrapper)topicExpression).getXmlObject());
- //notify is done
+ notificationMessageHolderType.setTopic((TopicExpressionType) ((XmlObjectWrapper)topicExpression).getXmlObject());
+ //notify is now populated
//build soap mesage
- SOAPMessage soapMsg = MessageFactory.newInstance().createMessage();
-
- SOAPHeader soapHeader = soapMsg.getSOAPHeader();
- //set the wsa headers
-
- SOAPBody soapBody = soapMsg.getSOAPBody();
- //doubt this will work...but lets give it a try using a Document type "notifyDoc"
- soapBody.addDocument((Document) notifyDoc.newDomNode());
+ SOAPMessage soapMessage = buildSOAPMessage(notifyDoc, (EndpointReferenceType)((XmlObjectWrapper)epr).getXmlObject());
- EMITTER_POOL.execute(EmitterTask.createEmitterTask(soapMsg, new URL(epr.getAddress().toString())));
+ EMITTER_POOL.execute(EmitterTask.createEmitterTask(soapMessage, new URL(epr.getAddress().toString())));
}
else
@@ -203,6 +203,60 @@
}
}
}
+ }
+ private SOAPMessage buildSOAPMessage( XmlObject fullMsgBodyElem,
+ EndpointReferenceType consumerEPR )
+ throws Exception
+ {
+ SOAPMessage msg = MessageFactory.newInstance( ).createMessage( );
+ SOAPEnvelope envelope = msg.getSOAPPart( ).getEnvelope( );
+ SOAPBody body = envelope.getBody( );
+ body.addDocument( (Document)fullMsgBodyElem.newDomNode() );
+ SOAPHeader header = msg.getSOAPHeader( );
+ addWSAHeaders( header, consumerEPR );
+
+ return msg;
+ }
+
+ /*
+ * Add WS-Addressing headers to a notification.
+ *
+ * @param header - The header to which to add the WS-Addressing headers.
+ * @param consumerEPR - An endpointReferece to the consumer of this notification.
+ * @throws Exception
+ */
+ private void addWSAHeaders( SOAPHeader header,
+ EndpointReferenceType consumerEPR )
+ throws Exception
+ {
+ SOAPFactory factory = SOAPFactory.newInstance( );
+
+ SOAPHeaderElement h = header.addHeaderElement( factory.createName( Addressing_03_2003_Constants.TO,
+ Addressing_03_2003_Constants.NSPREFIX_WSRL_SCHEMA,
+ Addressing_03_2003_Constants.NSURI_WSRL_SCHEMA ) );
+
+ h.addTextNode( consumerEPR.getAddress( ).getStringValue( ) );
+
+ h = header.addHeaderElement( factory.createName( Addressing_03_2003_Constants.ACTION ,
+ Addressing_03_2003_Constants.NSPREFIX_WSRL_SCHEMA
+ , Addressing_03_2003_Constants.NSURI_WSRL_SCHEMA ) );
+ h.addTextNode( BaseNotification1_2Constants.NOTIFY_ACTION_URL );
+
+ ReferencePropertiesType props = consumerEPR.getReferenceProperties( );
+ XmlCursor cursor = props.newCursor( );
+
+ boolean haveChild = cursor.toFirstChild( );
+
+ while ( haveChild )
+ {
+ SOAPElement e = XmlBeanUtils.toSOAPElement( cursor.getObject( ) );
+ h = header.addHeaderElement( e.getElementName( ) );
+ h.addTextNode( e.getValue( ) );
+
+ haveChild = cursor.toNextSibling( );
+ }
+
+ cursor.dispose( );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: hermes-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: hermes-dev-help@ws.apache.org