You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-dev@ws.apache.org by wi...@apache.org on 2005/08/24 03:14:07 UTC

svn commit: r239498 - in /webservices/muse/trunk/src/examples/ieeedemo/client/src: ./ org/apache/interop/client/ org/apache/interop/common/ui/ org/apache/interop/smgr/ org/apache/interop/wcmgr/ org/apache/interop/wcmgr/impl/ tests/

Author: wire
Date: Tue Aug 23 18:13:54 2005
New Revision: 239498

URL: http://svn.apache.org/viewcvs?rev=239498&view=rev
Log: (empty)

Added:
    webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/client/NotificationListener.java
      - copied, changed from r232294, webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/NotificationListener.java
    webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/NBEditorBean.properties
    webservices/muse/trunk/src/examples/ieeedemo/client/src/tests/TibcoTest.java
Removed:
    webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/NotificationListener.java
Modified:
    webservices/muse/trunk/src/examples/ieeedemo/client/src/log4j.properties
    webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/client/ResourceStub.java
    webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/MessagesJPanel.java
    webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/StatusJPanel.java
    webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/BlackBerryApp.java
    webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/BlackBerryApp2.java
    webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/HttpHeader.java
    webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/MessageWorker.java
    webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/wcmgr/WcMgrApp.java
    webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/wcmgr/impl/WsImpl.java
    webservices/muse/trunk/src/examples/ieeedemo/client/src/tests/WsCompatabilityTest.java

Modified: webservices/muse/trunk/src/examples/ieeedemo/client/src/log4j.properties
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/log4j.properties?rev=239498&r1=239497&r2=239498&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/ieeedemo/client/src/log4j.properties (original)
+++ webservices/muse/trunk/src/examples/ieeedemo/client/src/log4j.properties Tue Aug 23 18:13:54 2005
@@ -15,7 +15,7 @@
 #  Root logger's log-level (affects all classes within the JVM that use Log4J)  #
 #-------------------------------------------------------------------------------#
 #
-log4j.rootCategory=INFO, STDOUT
+log4j.rootCategory=DEBUG, STDOUT
 log4j.additivity.rootCategory=false
 
 #--------------------------------------------------#

Copied: webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/client/NotificationListener.java (from r232294, webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/NotificationListener.java)
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/client/NotificationListener.java?p2=webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/client/NotificationListener.java&p1=webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/NotificationListener.java&r1=232294&r2=239498&rev=239498&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/NotificationListener.java (original)
+++ webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/client/NotificationListener.java Tue Aug 23 18:13:54 2005
@@ -4,7 +4,7 @@
  * TODO To change the template for this generated file go to
  * Window - Preferences - Java - Code Style - Code Templates
  */
-package org.apache.interop.smgr;
+package org.apache.interop.client;
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
@@ -21,297 +21,338 @@
 import java.util.Locale;
 import java.util.TimeZone;
 
+import org.apache.interop.smgr.HttpHeader;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
 /**
+ * Creates a HTTP listener on a port and delivers posts to a callback interface.
+ * 
  * @author wire
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
+ * 
  */
 public class NotificationListener implements Runnable {
-    private static final String HTTP_SERVER_NAME = "WS-NotificationConsumer/1.0";
-    private static final String HTTP_VERSION = "1.0";
-    private static final String HTTP_STATUS = "202 Accepted";
-    private boolean closeSocketAfterNotification=true;
-    private ServerSocket server ;
-    private String request;
-    int port;
-    int timeout;
-    final Object listenerStarted = new Object();
-    private static final DateFormat HTTP_DATE_FORMAT = new SimpleDateFormat(
-            "EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US );
-    StringBuffer retIncomingMessage;
-    static
-    {
-        HTTP_DATE_FORMAT.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
-    }
-    public void setCloseSocketAfterNotification(boolean value){
-    	closeSocketAfterNotification=value;
-    }
-    /**
-     * the buffer to store the incoming message
-     */
-    private StringBuffer m_incomingMessage;
-    private Thread listener;
+	static Logger LOG = Logger.getLogger(NotificationListener.class.toString());
+
+	private static final String HTTP_SERVER_NAME = "WS-NotificationConsumer/1.0";
+
+	private static final String HTTP_VERSION = "1.0";
+
+	private static final String HTTP_STATUS = "202 Accepted";
+
+	private boolean closeSocketAfterNotification = true;
+
+	private ServerSocket server;
+
+	private String request;
+
+	int port;
+
+	int timeout;
+
+	final Object listenerStarted = new Object();
+
+	private static final DateFormat HTTP_DATE_FORMAT = new SimpleDateFormat(
+			"EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
+
+	/**
+	 * the buffer to store the incoming message
+	 */
+	//private StringBuffer m_incomingMessage;
+
+	private Thread listenerThread;
+
 	private BufferedReader bufIn;
+
 	private BufferedOutputStream bufOut;
+
 	private Socket sock;
-    public Object getMessageSemaphore(){
-    	return listenerStarted;
-    }
-    
+
+	public boolean ready=false; 
+	StringBuffer retIncomingMessage;
+	static {
+		HTTP_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
+	}
+
 	/**
 	 * 
 	 */
-	public NotificationListener(int port,int timeout,StringBuffer retIncomingMessage) {
+	public NotificationListener(int port, int timeout,
+			StringBuffer retIncomingMessage) {
 		super();
-		this.port=port;
-		this.timeout=timeout;
-		this.retIncomingMessage=retIncomingMessage;		
+		this.port = port;
+		this.timeout = timeout;
+		this.retIncomingMessage = retIncomingMessage;
 	}
-	
-	public void stop(){
-		listener.interrupt();
-        if ( server != null )
-        {
-            try
-            {
-            	if(sock!=null)
-            		synchronized(sock){	
-            		sock.notifyAll();
-            	}
-	              if(bufIn!=null)
-	              	bufIn.close();
-	              if(bufOut!=null)
-	              	bufOut.close();
-	              if(server!=null)
-	              	server.close();
-            }
-            catch ( IOException ignored )
-            {
-            }
-        }
+
+
+	public void start() throws IOException {
+		// start listening and then return when the thread has officially gone
+		// live and the socket is ready to be accepted
+		retIncomingMessage.setLength(0);
+		ready=false; 
+		listenerThread = new Thread(this, "Notification Listener = Port "+port);
+
+		synchronized (listenerStarted) {
+			listenerThread.start();
+
+			// TODO This code is on probation
+			 try
+			 {
+				LOG.log(Level.DEBUG,"Waiting for listener to start.");
+
+				 listenerStarted.wait();
+			 }
+			 catch ( InterruptedException ignored )
+			 {
+			 }
+			 // return controll to the caller
+			LOG.log(Level.DEBUG,"Have been notified that listener has started.");
+
+		}
 
 	}
-	
-	public void start() throws IOException{
-	       // start listening and then return when the thread has officially gone live
-        // and the socket is ready to be accepted
-	    listener = new Thread(this,"Notification Listener");
+
+	public void stop() {
+		// Stop the thread waiting for data
+		listenerThread.interrupt();
 		
-        synchronized ( listenerStarted )
-        {
-            listener.start();
-
-//            try
-//            {
-//                listenerStarted.wait();
-//            }
-//            catch ( InterruptedException ignored )
-//            {
-//            }
-            //return controll to the caller
-        }
+		// Close all open streams
+		if (server != null) {
+			try {
+				if (sock != null)
+					synchronized (sock) {
+						sock.notifyAll();
+					}
+				if (bufIn != null)
+					bufIn.close();
+				if (bufOut != null)
+					bufOut.close();
+				if (server != null)
+					server.close();
+			} catch (IOException ignored) {
+				LOG.log(Level.WARN,ignored);
+			}
+		}
 
 	}
-	
-	/* (non-Javadoc)
+
+	/*
+	 * (non-Javadoc)
+	 * 
 	 * @see java.lang.Runnable#run()
 	 */
 	public void run() {
- 
-            server = null;
-            sock = null;
-			bufIn = null;
-			bufOut = null;
-			byte[] responseBytes=null;
-            try {
-				server = new ServerSocket( port );
-	            // U might want to comment this back out   
-				server.setSoTimeout( timeout );
-
-	                // let the outer method know that we have started and just about to block on the accept
-	                synchronized ( listenerStarted )
-	                {
-	                    listenerStarted.notify();
-	                }
-
-			} catch (IOException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-				return;
+
+		server = null;
+		sock = null;
+		bufIn = null;
+		bufOut = null;
+		byte[] responseBytes = null;
+
+		try {
+			server = new ServerSocket(port);
+			server.setSoTimeout(timeout);
+
+			// let the outer method know that we have started and just about to
+			// block on the accept
+			synchronized (listenerStarted) {
+				listenerStarted.notify();
+				LOG.log(Level.DEBUG,"Calling thread notified that listner is running.");
 			}
 
-			while(true){
+		} catch (IOException e) {
+			LOG.log(Level.ERROR,"Error creating listener socket.",e);			
+			return;
+		}
+
+		while (true) {
 			
-				try
-	            {	
-						//System.out.println("Going into accepting state");
-	                	sock = server.accept();
-	                
-	                bufIn = new BufferedReader(
-	                        new InputStreamReader( sock.getInputStream() ) );
-	                bufOut = new BufferedOutputStream( sock.getOutputStream() );
-	                String header=readHeader(bufIn);
-	                
-	                HttpHeader headerObj=new HttpHeader(header);
-	                //headerObj.getHeader()
-				    String content_length = headerObj.getHeader(HttpHeader.CONTENT_LENGTH);
-				    int size = Integer.parseInt(content_length);
-				    //System.out.println("Waiting on "+size+" bytes");
-	                responseBytes = buildResponse().toString().getBytes();
-	                Thread.sleep(1000);
-	                try
-                  {
-
-	                    synchronized ( retIncomingMessage )
-	                    {
-	                        char[] buffer = new char[size];
-	                        bufIn.read( buffer, 0, size) ;
-	                        {
-	                            retIncomingMessage.append( buffer, 0, size );
-	                        }
-	                    }
-                  }
-                  catch ( InterruptedIOException ignored )
-                  {
-                  }
-
-	              bufOut.write( responseBytes, 0, responseBytes.length );
-	              bufOut.flush();
-	              bufIn.close();
-	              bufOut.close();
-	              if(closeSocketAfterNotification){
-	              	sock.close();
-	              	//System.out.println("This notification socket has been closed.");
-	              }
-	              		
-	            }    
-	            catch ( InterruptedIOException ignored )
-	            {
-	            	ignored.printStackTrace();
-	            	//System.out.println("Notification Listener Has Exited.");
-	            	return;
-	            }
-	            catch ( Throwable t )
-	            {
-	                synchronized ( retIncomingMessage )
-	                {
-	                    retIncomingMessage.delete( 0,
-	                            retIncomingMessage.length() );
-	                    retIncomingMessage.append( "ERROR: " );
-	                    retIncomingMessage.append( t );
-	                }
-	            }
-	            finally
-	            {
-	                synchronized ( retIncomingMessage )
-	                {
-	                    // make sure something goes in the message, even if nothing was received
-	                    if ( retIncomingMessage.length() == 0 )
-	                    {
-	                        retIncomingMessage.append( "ERROR: incoming message was empty" );
-	                    }
-	
-	                    retIncomingMessage.notify();
-	                    try {
-							retIncomingMessage.wait();
-						} catch (InterruptedException e1) {
-							// TODO Auto-generated catch block
-							//System.out.println("Notification Worker Exiting");
-							return;
-						//	e1.printStackTrace();
+			try {
+				LOG.log(Level.INFO, "Listener Going into accepting state");
+				sock = server.accept();
+
+				bufIn = new BufferedReader(new InputStreamReader(sock
+						.getInputStream()));
+				bufOut = new BufferedOutputStream(sock.getOutputStream());
+
+				// Blocks until Header is read
+				String header = readHeader(bufIn);
+				HttpHeader headerObj = new HttpHeader(header);
+				
+				// Determine length of HTTP Request
+				String content_length = headerObj
+						.getHeader(HttpHeader.CONTENT_LENGTH);
+								
+				int size = Integer.parseInt(content_length);
+				
+				LOG.log(Level.DEBUG,"Waiting on "+size+" bytes");
+				responseBytes = buildResponse().toString().getBytes();
+				
+				// TODO This has been probationally removed
+				//Thread.sleep(1000);
+				
+				// Build a buffer that matches the content length
+				int bytes_to_read=size;
+				while(retIncomingMessage.length()<size){
+					try {
+						synchronized (retIncomingMessage) {
+							char[] buffer = new char[size];
+							
+							//blocks
+							int bytes_read=bufIn.read(buffer, 0, bytes_to_read);
+							{
+								retIncomingMessage.append(buffer, 0, bytes_read);
+							}
+							LOG.log(Level.DEBUG,"Read "+bytes_read+" bytes.");
+							bytes_to_read-=bytes_read;
 						}
-	                    retIncomingMessage.setLength(0);
-
-	                }
-	                
-	//                if ( server != null )
-	//                {
-	//                    try
-	//                    {
-	//                        server.close();
-	//                    }
-	//                    catch ( IOException ignored )
-	//                    {
-	//                    }
-	//                }
-	
-	                // do this as a fail safe
-	                synchronized ( listenerStarted )
-	                {
-	                    listenerStarted.notify();
-	                }
-					//System.out.println("Notification Listening Thread has Died.");
+					} catch (InterruptedIOException ignored) {
+						LOG.log(Level.DEBUG,"This thread was interrupted.",ignored);
+					}
+				}
+				bufOut.write(responseBytes, 0, responseBytes.length);
+				bufOut.flush();
+				bufIn.close();
+				bufOut.close();
+				LOG.log(Level.DEBUG,"Closed Buffers. Now closing socket...");
+				if (closeSocketAfterNotification) {
+					sock.close();
+				}
+				LOG.log(Level.INFO,
+				"This notification socket has been closed.");
 
-	                
+			} catch (InterruptedIOException ignored) {
+				LOG.log(Level.DEBUG,"Timeout occured or listener inerrupted.",ignored);
+				return;
+			} catch (Throwable t) {
+				synchronized (retIncomingMessage) {
+					retIncomingMessage.delete(0, retIncomingMessage.length());
+					retIncomingMessage.append("ERROR: ");
+					retIncomingMessage.append(t);
+				}
+			} finally {
+				synchronized (retIncomingMessage) {
+					// make sure something goes in the message, even if nothing
+					// was received
+					if (retIncomingMessage.length() == 0) {
+						retIncomingMessage
+								.append("ERROR: incoming message was empty");
+						LOG.log(Level.ERROR,
+								"ERROR: incoming message was empty");
+					}
+					LOG.log(Level.DEBUG, "Notfication Received.\n"
+							+ retIncomingMessage);
+					LOG.log(Level.DEBUG, "Notifying Listening Application.\n");
+					retIncomingMessage.notify();
+					
+					LOG.log(Level.DEBUG, "Waiting for it to empty buffer and notify.....\n");
+					try { //This wait hangs
+						ready=true;
+						retIncomingMessage.wait();
+						LOG.log(Level.DEBUG, "Notifying Listening Application Complete.\n");
+					} catch (InterruptedException e1) {
+						LOG.log(Level.DEBUG, "Notification Worker Exiting");
+						return;
+					}
+					retIncomingMessage.setLength(0);
+					ready=false;
+
+				}
+
+				// if ( server != null )
+				// {
+				// try
+				// {
+				// server.close();
+				// }
+				// catch ( IOException ignored )
+				// {
+				// }
+				// }
+
+				// do this as a fail safe
+				synchronized (listenerStarted) {
+					listenerStarted.notify();
+				}
+				LOG.log(Level.INFO, "Notification Listening restarting.");
 
-	            }
 			}
+		}
 
-        }
+	}
 
-        /**
+	/**
 	 * @param bufIn2
 	 */
 	private String readHeader(BufferedReader streamIn) throws IOException {
-		// TODO Auto-generated method stub
-        char LF=10;
-        char NL=13;
-      	int lastread = -1;
-      	int input = -1;
-      	StringBuffer header = new StringBuffer();
-    	
-      	request= streamIn.readLine();
-      	String str = request; 
-         while (!str.equals("")){
-           str = streamIn.readLine();
-           header.append(str);
-           header.append("\n");
-           //header.append(LF);
-         }
-      	
-    	return header.toString();
 		
+		StringBuffer header = new StringBuffer();
+		// blocks
+		request = streamIn.readLine();
+		LOG.log(Level.DEBUG,"Notification URI is "+request);
+		String str = request;
+		while (!str.equals("")) {
+			str = streamIn.readLine();
+			header.append(str);
+			header.append("\n");			
+		}
+		LOG.log(Level.DEBUG,"Received HTTP Header:\n"+header.toString());
+		
+		return header.toString();
+	}
+
+	/**
+	 * Build a one-way HTTP response message that complies to the WS-I Basic
+	 * Profile 1.0, section 5.6.10 - see
+	 * http://www.ws-i.org/Profiles/BasicProfile-1.0-2004-04-16.html#refinement16651160
+	 * 
+	 * @return a WS-I-compliant Notify response message
+	 */
+	private String buildResponse() {
+		Date timeNow = new Date();
+		Date sameTimeTomorrow = new Date(timeNow.getTime()
+				+ (24 * 60 * 60 * 1000));
+		StringBuffer responseBuf = new StringBuffer("HTTP/");
+		responseBuf.append(HTTP_VERSION);
+		responseBuf.append(" ");
+		responseBuf.append(HTTP_STATUS);
+		responseBuf.append("\r\n");
+
+		responseBuf.append("Date: ");
+		responseBuf.append(HTTP_DATE_FORMAT.format(timeNow));
+		responseBuf.append("\r\n");
+
+		responseBuf.append("Server: ");
+		responseBuf.append(HTTP_SERVER_NAME);
+		responseBuf.append("\r\n");
+
+		responseBuf.append("Cache-Control: ");
+		responseBuf.append("max-age=86400");
+		responseBuf.append("\r\n");
+
+		responseBuf.append("Expires: ");
+		responseBuf.append(HTTP_DATE_FORMAT.format(sameTimeTomorrow));
+		responseBuf.append("\r\n");
+
+		return responseBuf.toString();
+	}
+
+	public String getRequestUri() {
+		if (request == null)
+			return "";
+		return request.split(" ")[1];
+	}
+	public void setCloseSocketAfterNotification(boolean value) {
+		closeSocketAfterNotification = value;
+	}
+
+	public Object getMessageSemaphore() {
+		return listenerStarted;
+	}
+	
+	public boolean isReady(){
+		return ready;
 	}
 
-		/**
-         * Build a one-way HTTP response message that complies to the WS-I Basic Profile 1.0, section 5.6.10
-         * - see http://www.ws-i.org/Profiles/BasicProfile-1.0-2004-04-16.html#refinement16651160
-         *
-         * @return a WS-I-compliant Notify response message
-         */
-        private String buildResponse()
-        {
-            Date timeNow = new Date();
-            Date sameTimeTomorrow = new Date( timeNow.getTime() + ( 24 * 60 * 60 * 1000 ) );
-            StringBuffer responseBuf = new StringBuffer( "HTTP/" );
-            responseBuf.append( HTTP_VERSION );
-            responseBuf.append( " " );
-            responseBuf.append( HTTP_STATUS );
-            responseBuf.append( "\r\n" );
-
-            responseBuf.append( "Date: " );
-            responseBuf.append( HTTP_DATE_FORMAT.format( timeNow ) );
-            responseBuf.append( "\r\n" );
-
-            responseBuf.append( "Server: " );
-            responseBuf.append( HTTP_SERVER_NAME );
-            responseBuf.append( "\r\n" );
-
-            responseBuf.append( "Cache-Control: " );
-            responseBuf.append( "max-age=86400" );
-            responseBuf.append( "\r\n" );
-
-            responseBuf.append( "Expires: " );
-            responseBuf.append( HTTP_DATE_FORMAT.format( sameTimeTomorrow ) );
-            responseBuf.append( "\r\n" );
-
-            return responseBuf.toString();
-        }
-        public String getRequestUri(){
-        	if(request==null)
-        		return "";
-        	return request.split(" ")[1];        	
-        }
-         
 }

Modified: webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/client/ResourceStub.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/client/ResourceStub.java?rev=239498&r1=239497&r2=239498&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/client/ResourceStub.java (original)
+++ webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/client/ResourceStub.java Tue Aug 23 18:13:54 2005
@@ -57,12 +57,25 @@
 	static final boolean DEBUG = false;//Boolean.getBoolean( "debug" );
 
     private EndpointReference m_epr;
+    private EndpointReference m_epr2003;
+    private EndpointReference m_epr2004;
 
     public static boolean USE_WRAPPED_NOTIFICATIONS = Boolean.valueOf(System.getProperty("wrapped_notifications", "true")).booleanValue();
 
     public ResourceStub( EndpointReference epr )
     {
+       XmlBeansEndpointReference xBeansEpr=(XmlBeansEndpointReference)epr;
        m_epr = epr;
+       XmlObject eprXBean = ((XmlObjectWrapper)m_epr).getXmlObject();
+       if ( eprXBean.schemaType().getName().getNamespaceURI().equals( Constants.NS_URI_ADDRESSING_2003_03 ) )
+       {
+    	   m_epr2003=m_epr;
+    	   m_epr2004=new XmlBeansEndpointReference((org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType)xBeansEpr.getXmlObject(org.apache.ws.addressing.v2004_08_10.AddressingConstants.NSURI_ADDRESSING_SCHEMA));
+    	   
+       } else {
+    	   m_epr2004=m_epr;
+    	   m_epr2003=new XmlBeansEndpointReference((org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType)xBeansEpr.getXmlObject(org.apache.ws.addressing.v2003_03.AddressingConstants.NSURI_ADDRESSING_SCHEMA));    	   
+       }
     }
 
     public XmlObject[] getResourceProperty( QName propName ) throws FaultException
@@ -162,7 +175,8 @@
             setChanged();
             XmlOptions xmlOpts = new XmlOptions().setSaveOuter();
             xmlOpts.setSavePrettyPrint();
-    		notifyObservers(new WcmMessage(requestDoc.xmlText(xmlOpts), response,type));            
+            
+    		notifyObservers(new WcmMessage("<?xml version=\"1.0\" encoding=\"UTF8\" ?>"+requestEnvelopeDoc.xmlText(xmlOpts), response,type));            
             EnvelopeDocument responseEnvelopeDoc = (EnvelopeDocument) XmlObject.Factory.parse( response );
             LOG.log(Level.DEBUG, "Received response: \n" + responseEnvelopeDoc ); 
             Envelope responseEnvelope = responseEnvelopeDoc.getEnvelope();
@@ -178,11 +192,58 @@
         }
         catch ( Exception e )
         {
+            LOG.log(Level.ERROR,e);
             throw new RuntimeException( e );
         }
     }
 
+    /**
+     * All resource proerpties request must you 2003 addressing
+     * @param header
+     * @param action
+     */
     private void addAddressingHeaders( Header header, String action )
+    {
+        XmlObject eprXBean = ((XmlObjectWrapper)m_epr).getXmlObject();
+        XmlObject toElem;
+        XmlObject actionElem;
+        if ( eprXBean.schemaType().getName().getNamespaceURI().equals( Constants.NS_URI_ADDRESSING_2003_03 ) )
+        {
+            org.xmlsoap.schemas.ws.x2003.x03.addressing.ToDocument toDoc = org.xmlsoap.schemas.ws.x2003.x03.addressing.ToDocument.Factory.newInstance();
+            org.xmlsoap.schemas.ws.x2003.x03.addressing.AttributedURI attributedURI = toDoc.addNewTo();
+            attributedURI.setStringValue(m_epr.getAddress());
+            toElem = toDoc;
+            org.xmlsoap.schemas.ws.x2003.x03.addressing.ActionDocument actionDoc = org.xmlsoap.schemas.ws.x2003.x03.addressing.ActionDocument.Factory.newInstance();
+            org.xmlsoap.schemas.ws.x2003.x03.addressing.AttributedURI actionType = actionDoc.addNewAction();
+            actionType.setStringValue( action );
+            actionElem = actionDoc;
+        }
+        else
+        {
+            org.xmlsoap.schemas.ws.x2004.x08.addressing.ToDocument toDoc = org.xmlsoap.schemas.ws.x2004.x08.addressing.ToDocument.Factory.newInstance();
+            org.xmlsoap.schemas.ws.x2004.x08.addressing.AttributedURI attributedURI = toDoc.addNewTo();
+            attributedURI.setStringValue(m_epr.getAddress());
+            toElem = toDoc;
+            org.xmlsoap.schemas.ws.x2004.x08.addressing.ActionDocument actionDoc = org.xmlsoap.schemas.ws.x2004.x08.addressing.ActionDocument.Factory.newInstance();
+            org.xmlsoap.schemas.ws.x2004.x08.addressing.AttributedURI actionType = actionDoc.addNewAction();
+            actionType.setStringValue( action );
+            actionElem = actionDoc;
+        }
+        
+        
+        XmlBeanUtils.addChildElement( header, toElem );
+        XmlBeanUtils.addChildElement( header, actionElem );
+        if (m_epr.getReferenceProperties() != null)
+        {
+            XmlObject[] refPropElems = (XmlObject[]) m_epr.getReferenceProperties();
+            for (int i = 0; i < refPropElems.length; i++)
+            {
+                XmlBeanUtils.addChildElement(header, refPropElems[i]);
+            }
+        }
+    }
+
+    private void addAddressingHeadersOld( Header header, String action )
     {
         XmlObject eprXBean = ((XmlObjectWrapper)m_epr).getXmlObject();
         XmlObject toElem;

Modified: webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/MessagesJPanel.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/MessagesJPanel.java?rev=239498&r1=239497&r2=239498&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/MessagesJPanel.java (original)
+++ webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/MessagesJPanel.java Tue Aug 23 18:13:54 2005
@@ -4,13 +4,22 @@
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.Insets;
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Observable;
 import java.util.Observer;
+import java.util.ResourceBundle;
+import java.util.StringTokenizer;
 
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.DefaultListModel;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
 import javax.swing.JCheckBox;
 import javax.swing.JEditorPane;
+import javax.swing.JFileChooser;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JList;
@@ -23,10 +32,16 @@
 import javax.swing.border.LineBorder;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
+import javax.swing.filechooser.FileFilter;
 
 import org.apache.interop.client.WcmMessage;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
+import org.netbeans.editor.BaseSettingsInitializer;
+import org.netbeans.editor.LocaleSupport;
+import org.netbeans.editor.Settings;
+import org.netbeans.editor.LocaleSupport.Localizer;
+import org.netbeans.editor.ext.ExtSettingsInitializer;
 /**
 * This code was generated using CloudGarden's Jigloo
 * SWT/Swing GUI Builder, which is free for non-commercial
@@ -49,20 +64,22 @@
 	private JList jListTime;
 	private JScrollPane jScrollPaneTime;
 	private JScrollPane jScrollPaneRequest;
+	private JEditorPane response;
+	private JEditorPane request;
 	private JCheckBox jCheckBoxUpdate;
 	private JLabel jLabelTime;
 	private JLabel jLabelRequest;
-	private JPanel jPanelRequest;
 	private JLabel jLabelResponse;
-	private JPanel jPanelResponse;
-	private JEditorPane response;
-	private JEditorPane request;
 	private JScrollPane jScrollPaneResponse;
 	private JSplitPane jSplitPaneReqRes;
 	private JPanel jPanelTimePanel;
 	private JPanel jPanelMessageBody;
 	private DefaultListModel listModel;
 	private static final int m_CountMessages2Retain=100;
+    // Net Beans Internationalization
+    private static final String SETTINGS = "org/apache/interop/common/ui/NBEditorBean";
+    private ResourceBundle settings = ResourceBundle.getBundle( SETTINGS );
+
 	/**
 	* Auto-generated main method to display this 
 	* JPanel inside a new JFrame.
@@ -91,6 +108,8 @@
 	
 	public MessagesJPanel() {
 		super();
+		nbInitSettings();
+		nbReadSettings();
 		initGUI();
 		listModel=new DefaultListModel();
 		jListTime.setModel(listModel);
@@ -207,30 +226,13 @@
 							jPanelLeft.add(
 								jScrollPaneRequest,
 								BorderLayout.CENTER);
-							jScrollPaneRequest
-								.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
 							jScrollPaneRequest.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
 							{
-								jPanelRequest = new JPanel();
-								BorderLayout jPanelRequestLayout = new BorderLayout();
-								jPanelRequest.setEnabled(false);
-								jPanelRequest.setLayout(jPanelRequestLayout);
-								jScrollPaneRequest
-									.setViewportView(jPanelRequest);
-								{
-									request = new JEditorPane();
-									jPanelRequest.add(
-										getRequest(),
-										BorderLayout.CENTER);
-									request
-										.setPreferredSize(new java.awt.Dimension(
-											200,
-											257));
-									request
-										.setMinimumSize(new java.awt.Dimension(
-											50,
-											22));
-								}
+								request = new JEditorPane("text/html","");
+								jScrollPaneRequest.setViewportView(request);
+								request.setFont(new java.awt.Font("Dialog",0,9));
+								request.setEditable(false);
+								request.setEnabled(false);
 							}
 						}
 					}
@@ -247,28 +249,15 @@
 						{
 							jScrollPaneResponse = new JScrollPane();
 							jPanelRight.add(jScrollPaneResponse, BorderLayout.CENTER);
-							jScrollPaneResponse
-								.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
 							jScrollPaneResponse.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
 							{
-								jPanelResponse = new JPanel();
-								jScrollPaneResponse.setViewportView(jPanelResponse);
-								BorderLayout jPanelResponseLayout = new BorderLayout();
-								jPanelResponse.setLayout(jPanelResponseLayout);
-								{
-									response = new JEditorPane();
-									jPanelResponse.add(
-										getResponse(),
-										BorderLayout.CENTER);
-									response
-										.setPreferredSize(new java.awt.Dimension(
-											200,
-											257));
-									response
-										.setMinimumSize(new java.awt.Dimension(
-											5,
-											22));
-								}
+								response = new JEditorPane("text/html","");
+								jScrollPaneResponse.setViewportView(response);
+								response.setPreferredSize(new java.awt.Dimension(200,257));
+								response.setMinimumSize(new java.awt.Dimension(5,22));
+								response.setFont(new java.awt.Font("Dialog",0,9));
+								response.setEditable(false);
+								response.setEnabled(false);
 							}
 						}
 					}
@@ -293,12 +282,12 @@
 
 		WcmMessage value=(WcmMessage) jListTime.getSelectedValue();
 		response.setText(value.getResponse());
-		response.getCaret().setDot(response.getText().length() );
+		response.getCaret().setDot(0);//response.getText().length() 
 		jScrollPaneResponse.scrollRectToVisible(jScrollPaneResponse.getVisibleRect() );
 		jScrollPaneResponse.invalidate();
 		
 		request.setText(value.getRequest());
-		request.getCaret().setDot(request.getText().length() );
+		request.getCaret().setDot(0 );
 		jScrollPaneRequest.scrollRectToVisible(jScrollPaneRequest.getVisibleRect() );
 		jScrollPaneRequest.invalidate();
 		
@@ -356,5 +345,198 @@
 		request.setText("");
 
 	}
+    private void nbInitSettings()
+    {
+        //LocaleSupport.addLocalizer( new Localizer(  "org.netbeans.editor.Bundle" ) );
+        
+        // Feed our kits with their default Settings
+        Settings.addInitializer(new BaseSettingsInitializer(), Settings.CORE_LEVEL);
+        Settings.addInitializer(new ExtSettingsInitializer(), Settings.CORE_LEVEL);
+        Settings.reset();
+    }
+    
+    private void nbReadSettings() 
+    {
+        File currentPath = new File( System.getProperty(  "user.dir" ) ).getAbsoluteFile();
+        JFileChooser fileChooser = new JFileChooser( currentPath );
+        
+        String kits = settings.getString( "InstalledEditors" );
+        String defaultKit = settings.getString( "DefaultEditor" );
+        
+        StringTokenizer st = new StringTokenizer( kits,  "," );
+        while( st.hasMoreTokens() )
+        {
+            String kitName = st.nextToken();
+            // At the first, we have to read ALL info about kit
+            String contentType = settings.getString( kitName +  "_ContentType" );
+            String extList = settings.getString( kitName +  "_ExtensionList" );
+            String menuTitle = settings.getString( kitName +  "_NewMenuTitle" );
+            char menuMnemonic = settings.getString( kitName +  "_NewMenuMnemonic" ).charAt( 0 );
+            String templateURL = settings.getString( kitName +  "_Template" );
+            String iconName = settings.getString( kitName +  "_Icon" );
+            String filterTitle = settings.getString( kitName +  "_FileFilterTitle" );
+            String kit = settings.getString( kitName +  "_KitClass" );
+            
+            // At the second, we surely need an instance of kitClass
+            Class kitClass=null;
+            try
+            {
+                kitClass = Class.forName( kit );
+            }
+            catch( ClassNotFoundException exc )
+            { // we really need it
+                LOG.log(Level.ERROR,"Editor Kit configuration missing.",exc);
+            }
+            
+            // At the third, it is nice to have icon although we could live without one
+            
+            Icon icon = null;
+            
+            ClassLoader loader = kitClass.getClassLoader();
+            if( loader == null ) loader = ClassLoader.getSystemClassLoader();
+            
+            URL resource = loader.getResource( iconName );
+            if( resource == null ) resource = ClassLoader.getSystemResource( iconName );
+            if( resource != null ) icon = new ImageIcon( resource );
+            
+            
+            // At the fourth, try to get URL for template
+            URL template = loader.getResource( templateURL );
+            if( resource == null ) template = ClassLoader.getSystemResource( templateURL );
+            
+            // Finally, convert the list of extensions to, ehm, List :-)
+            List l = new ArrayList( 5 );
+            StringTokenizer extST = new StringTokenizer( extList,  "," );
+            while( extST.hasMoreTokens() ) l.add( extST.nextToken() );
+            
+            // Actually create the KitInfo from provided informations
+            KitInfo ki = new KitInfo( contentType, l, template, icon, filterTitle, kitClass, loader, defaultKit.equals( kitName ) );
+            
+            // Make the MenuItem for it
+            /*
+            JMenuItem item = new JMenuItem( menuTitle, icon );
+            item.setMnemonic( menuMnemonic );
+            item.addActionListener( new NewFileActionListener( ki ) );
+            newMenu.add( item );
+             */
+            // Register a FileFilter for given type of file
+            fileChooser.addChoosableFileFilter( ki );
+            
+        }
+        
+        // Finally, add fileFilter that would recognize files of all kits
+        fileChooser.addChoosableFileFilter( new FileFilter()
+        {
+            public String getDescription()
+            {
+                return  "All recognized files";
+            }
+            
+            public boolean accept( File f )
+            {
+                return f.isDirectory() || KitInfo.getKitInfoForFile( f ) != null;
+            }
+        });
+        
+        //if( KitInfo.getDefault() == null ) throw new MissingResourceException(  "Missing default kit definition", defaultKit,  "DefaultEditor" );
+    }
+    private static final class KitInfo extends FileFilter
+    {
+        
+        private static List kits = new ArrayList();
+        private static KitInfo defaultKitInfo;
+        
+        public static List getKitList()
+        {
+            return new ArrayList( kits );
+        }
+        
+        public static KitInfo getDefault()
+        {
+            return defaultKitInfo;
+        }
+        
+        public static KitInfo getKitInfoOrDefault( File f )
+        {
+            KitInfo ki = getKitInfoForFile( f );
+            return ki == null ? defaultKitInfo : ki;
+        }
+        
+        public static KitInfo getKitInfoForFile( File f )
+        {
+            for( int i = 0; i < kits.size(); i++ )
+            {
+                if( ((KitInfo)kits.get(i)).accept( f ) )
+                    return (KitInfo)kits.get(i);
+            }
+            return null;
+        }
+        
+        private String type;
+        private String[] extensions;
+        private URL template;
+        private Icon icon;
+        private Class kitClass;
+        private String description;
+        
+        public KitInfo( String type, List exts, URL template, Icon icon, String description, Class kitClass, ClassLoader loader, boolean isDefault )
+        {
+            // Fill in the structure
+            this.type = type;
+            this.extensions = (String[])exts.toArray( new String[0] );
+            this.template = template;
+            this.icon = icon;
+            this.description = description;
+            this.kitClass = kitClass;
+            
+            // Register us
+            JEditorPane.registerEditorKitForContentType( type, kitClass.getName(), loader );
+            kits.add( this );
+            if( isDefault ) defaultKitInfo = this;
+        }
+        
+        
+        
+        public String getType()
+        {
+            return type;
+        }
+        
+        public String getDefaultExtension()
+        {
+            return extensions[0];
+        }
+        
+        public URL getTemplate()
+        {
+            return template;
+        }
+        
+        public Icon getIcon()
+        {
+            return icon;
+        }
+        
+        public Class getKitClass()
+        {
+            return kitClass;
+        }
+        
+        public String getDescription()
+        {
+            return description;
+        }
+        
+        public boolean accept( File f )
+        {
+            if( f.isDirectory() ) return true;
+            String fileName = f.getName();
+            for( int i=0; i<extensions.length; i++ )
+            {
+                if( fileName.endsWith( extensions[i] ) ) return true;
+            }
+            return false;
+        }
+    }
 
 }

Added: webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/NBEditorBean.properties
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/NBEditorBean.properties?rev=239498&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/NBEditorBean.properties (added)
+++ webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/NBEditorBean.properties Tue Aug 23 18:13:54 2005
@@ -0,0 +1,109 @@
+# File with settings of kits the editor is providing, their recognized file
+# types, icons, menu labels and so on.
+#
+# Format of this file:
+#     There should be a key 'InstalledEditors', whose value is a coma separated
+# list of symbolic names of instaled kits. These names, further trimmed
+# and appended with underscore are then used as prefixes for each kit
+# information key.
+#     There also should be the a key 'DefaultEditor', which holds a reference
+# to another editor symbolic name. The DefualtEditor would be used when opening
+# a file of unknown content.
+#     For every declared kit, there have to be a definition consisting of a set
+# of a key-value pairs for the following keys:
+#     * ContentType - the content type this editor is intended for
+#     * ExtensionList - the coma separated list of file extensions associated
+#       with given content type. The Editor uses the extensions as they are
+#       and uses them to match filenames with String.endsWith( extension )
+#       without adding dot. If the file of the content type ends with
+#       '.ext', use '.ext' in the list, if it is 'README', use 'README'.
+#       The first noted extension is treated as default extension and
+#       is appended to name of newly created file.
+#     * NewMenuTitle - the text to appear in New... submenu item
+#     * NewMenuMnemonic - the accelerator char for the New... submenu item
+#     * Template - the URL of the resource representing empty document.
+#       If it could'n be loaded, it is simply ignored.
+#     * Icon - the URL of the icon resource used to identified files
+#       of the content type. The icon is used in NewMenuItem, in FileChooser,
+#       and in the tab of the edited file. If it couln't be loaded, editor
+#       would simply use no icon, so if you don't have one, use e.g. 'NONE'
+#     * FileFilterTitle - the title to use in the FileChooser's pluggable
+#       file filter for the files of the content type.
+#     * KitClass - the name of class implementing the EditorKit for this kit.
+
+InstalledEditors=Plain,Java,Html,
+#,Xml,Dtd,Css,Jsp
+DefaultEditor=Plain
+
+Plain_ContentType=text/plain2
+Plain_ExtensionList=.txt,.ME,README,.log
+Plain_NewMenuTitle=Plain Text File
+Plain_NewMenuMnemonic=P
+Plain_Template=NONE
+Plain_Icon=org/apache/interop/common/ui/xmleditorkit/res/txtObject.gif
+Plain_FileFilterTitle=Text Files
+Plain_KitClass=org.apache.interop.common.ui.xmleditorkit.PlainKit
+
+Html_ContentType=text/html
+Html_ExtensionList=.htm,.html,.php3,.xml,.jsp,.asp
+Html_NewMenuTitle=HTML Document
+Html_NewMenuMnemonic=H
+Html_Template=com/hp/mwlabs/tools/pacman/docbeans/nbeditor/res/template.html_
+Html_Icon=com/hp/mwlabs/tools/pacman/docbeans/nbeditor/res/htmlObject.gif
+Html_FileFilterTitle=HTML Files
+Html_KitClass=org.apache.interop.common.ui.xmleditorkit.HTMLKit
+
+Java_ContentType=text/x-java
+Java_ExtensionList=.java
+Java_NewMenuTitle=Java Source
+Java_NewMenuMnemonic=J
+Java_Template=com/hp/mwlabs/tools/pacman/docbeans/nbeditor/res/template.java_
+Java_Icon=com/hp/mwlabs/tools/pacman/docbeans/nbeditor/res/javaObject.gif
+Java_FileFilterTitle=Java Sources
+Java_KitClass=org.apache.interop.common.ui.xmleditorkit.JavaKit
+Java_Completion=D:\\forte4j-ie\\system\\ParserDB\\jdk13
+
+Properties_ContentType=text/properties
+Properties_ExtensionList=.properties
+Properties_NewMenuTitle=Resource Bundle
+Properties_NewMenuMnemonic=R
+Properties_Template=NONE
+Properties_Icon=com/hp/mwlabs/tools/pacman/docbeans/nbeditor/res/propertiesObject.gif
+Properties_FileFilterTitle=Resource Bundles
+Properties_KitClass=org.apache.interop.common.ui.xmleditorkit.PropertiesKit
+
+Xml_ContentType=text/xml
+Xml_ExtensionList=.xml
+Xml_NewMenuTitle=XML Document
+Xml_NewMenuMnemonic=X
+Xml_Template=NONE
+Xml_Icon=com/hp/mwlabs/tools/pacman/docbeans/nbeditor/res/xmlObject.gif
+Xml_FileFilterTitle=XML Files
+Xml_KitClass=org.apache.interop.common.ui.xmleditorkit.XMLKit
+
+Dtd_ContentType=text/dtd
+Dtd_ExtensionList=.dtd
+Dtd_NewMenuTitle=Document Type Definition
+Dtd_NewMenuMnemonic=D
+Dtd_Template=NONE
+Dtd_Icon=com/hp/mwlabs/tools/pacman/docbeans/nbeditor/res/dtdObject.gif
+Dtd_FileFilterTitle=DTD Files
+Dtd_KitClass=org.apache.interop.common.ui.xmleditorkit.DTDKit
+
+Css_ContentType=text/css
+Css_ExtensionList=.css
+Css_NewMenuTitle=Cascading Style Sheet
+Css_NewMenuMnemonic=C
+Css_Template=NONE
+Css_Icon=com/hp/mwlabs/tools/pacman/docbeans/nbeditor/res/css.gif
+Css_FileFilterTitle=CSS Files
+Css_KitClass=org.apache.interop.common.ui.xmleditorkit.CSSEditorKit
+
+Jsp_ContentType=text/x-jsp
+Jsp_ExtensionList=.jsp
+Jsp_NewMenuTitle=JSP Page
+Jsp_NewMenuMnemonic=S
+Jsp_Template=NONE
+Jsp_Icon=com/hp/mwlabs/tools/pacman/docbeans/nbeditor/res/jspObject.gif
+Jsp_FileFilterTitle=JSP Files
+Jsp_KitClass=org.apache.interop.common.ui.xmleditorkit.JSPKit

Modified: webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/StatusJPanel.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/StatusJPanel.java?rev=239498&r1=239497&r2=239498&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/StatusJPanel.java (original)
+++ webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/common/ui/StatusJPanel.java Tue Aug 23 18:13:54 2005
@@ -105,7 +105,10 @@
 
 	protected void kick() {
 		WsGraphCell cell=(WsGraphCell)jGraphMain.getSelectionCell();
-		commandLister.kick(cell.toString());		
+		if(commandLister!=null)
+			commandLister.kick(cell.toString());
+		else
+			LOG.log(Level.ERROR,"You cannot kick because the commandLister is NULL");
 	}
 
 	public void setPopupListener(CommandListener listener){

Modified: webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/BlackBerryApp.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/BlackBerryApp.java?rev=239498&r1=239497&r2=239498&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/BlackBerryApp.java (original)
+++ webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/BlackBerryApp.java Tue Aug 23 18:13:54 2005
@@ -34,6 +34,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.interop.client.FaultException;
+import org.apache.interop.client.NotificationListener;
 import org.apache.interop.client.ResourceStub;
 import org.apache.interop.client.ServiceStub;
 import org.apache.interop.common.LocationJPanel;

Modified: webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/BlackBerryApp2.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/BlackBerryApp2.java?rev=239498&r1=239497&r2=239498&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/BlackBerryApp2.java (original)
+++ webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/BlackBerryApp2.java Tue Aug 23 18:13:54 2005
@@ -5,6 +5,7 @@
 
 
 import org.apache.interop.client.FaultException;
+import org.apache.interop.client.NotificationListener;
 import org.apache.interop.client.ResourceStub;
 import org.apache.interop.client.ServiceStub;
 import org.apache.interop.smgr.SubsciberInfoJPanel;

Modified: webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/HttpHeader.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/HttpHeader.java?rev=239498&r1=239497&r2=239498&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/HttpHeader.java (original)
+++ webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/HttpHeader.java Tue Aug 23 18:13:54 2005
@@ -74,7 +74,7 @@
         {
             String header = strings[i];
             String[] values = header.split(": ");
-            m_headers.put(values[0].trim(), values[1].trim());
+            m_headers.put(values[0].trim().toLowerCase(), values[1].trim());
         }
 
         //System.out.println("Parsed Headers: " +toString());//debug only
@@ -88,9 +88,9 @@
      */
     public String getHeader(String headerName)
     {
-        if (m_headers.containsKey(headerName))
+        if (m_headers.containsKey(headerName.toLowerCase()))
         {
-            return (String) m_headers.get(headerName);
+            return (String) m_headers.get(headerName.toLowerCase());
         }
         else
         {

Modified: webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/MessageWorker.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/MessageWorker.java?rev=239498&r1=239497&r2=239498&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/MessageWorker.java (original)
+++ webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/smgr/MessageWorker.java Tue Aug 23 18:13:54 2005
@@ -8,6 +8,7 @@
 
 import java.io.IOException;
 
+import org.apache.interop.client.NotificationListener;
 import org.apache.interop.common.ui.StatusJPanel;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;

Modified: webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/wcmgr/WcMgrApp.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/wcmgr/WcMgrApp.java?rev=239498&r1=239497&r2=239498&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/wcmgr/WcMgrApp.java (original)
+++ webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/wcmgr/WcMgrApp.java Tue Aug 23 18:13:54 2005
@@ -1,6 +1,7 @@
 package org.apache.interop.wcmgr;
 
 import org.apache.interop.client.FaultException;
+import org.apache.interop.client.NotificationListener;
 import org.apache.interop.client.ResourceStub;
 import org.apache.interop.client.WcmMessage;
 import org.apache.interop.common.LocationJPanel;
@@ -10,21 +11,24 @@
 import org.apache.interop.smgr.ConnectionListener;
 import org.apache.interop.smgr.MessageListener;
 import org.apache.interop.smgr.MessageWorker;
-import org.apache.interop.smgr.NotificationListener;
 import org.apache.interop.wcmgr.impl.WcImpl;
 import org.apache.interop.wcmgr.impl.WsImpl;
 import org.apache.interop.wcmgr.model.IWc;
 import org.apache.interop.wcmgr.model.IWs;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
+import org.apache.ws.Soap1_1Constants;
 import org.apache.ws.addressing.EndpointReference;
 import org.apache.ws.addressing.XmlBeansEndpointReference;
 import org.apache.ws.addressing.v2004_08_10.AddressingConstants;
+import org.apache.ws.resource.handler.ResourceHandler;
 import org.apache.ws.util.XmlBeanUtils;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
 import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
+import org.apache.xmlbeans.impl.values.XmlStringImpl;
 import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.impl.ManagementEventTypeImpl;
 import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.impl.RelationshipTypeImpl;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotificationMessageHolderType;
@@ -35,6 +39,7 @@
 import org.xmlsoap.schemas.soap.envelope.Body;
 import org.xmlsoap.schemas.soap.envelope.EnvelopeDocument;
 import org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType;
+import org.xmlsoap.schemas.ws.x2004.x08.addressing.impl.EndpointReferenceTypeImpl;
 
 import javax.swing.*;
 import javax.xml.namespace.QName;
@@ -44,7 +49,10 @@
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
 import java.io.IOException;
+import java.text.ParseException;
+import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Vector;
 
 /**
@@ -62,6 +70,9 @@
 * *************************************
 */
 public class WcMgrApp extends javax.swing.JFrame  implements ConnectionListener,MessageListener,CommandListener {
+	public static final long instanceID=Math.round(Math.random()*100000);
+	private static final QName weatherStationReferenceQname= new QName("http://wsdmdemo.org/service/weather-client-config","WeatherStationReference");
+	private static final QName weatherStationNameQname= new QName("http://wsdmdemo.org/service/weather-station", "Name", "tns");
 	static Logger LOG = Logger.getLogger(WcMgrApp.class.toString());
 	private LocationJPanel locationJPanel;
 	private MessagesJPanel messagesJPanel1;
@@ -205,9 +216,10 @@
 		}
 
 		// Call WC and set it for the cheapest and the best
-		if(wsChoice!=null)
+		if(wsChoice!=null){
+			LOG.log(Level.INFO,"Station "+wsChoice+" has been chosen as the active weather station.");
 			switchStations(wsChoice);
-		else
+		} else
 			LOG.log(Level.WARN,"No Valid Ws choice found.");		
 	}
 	
@@ -247,6 +259,9 @@
 			
 			// Request Inital Status of 
 			updateOperationalStatus();
+			
+			// Determine the active WS
+			statusJPanel.setCurrentWs(getCurrentWs());//asdfasdf
 						
 		} catch (XmlException e1) {
 			LOG.log(Level.ERROR,"Failed to parse relationship information for weather station higherarchy.",e1);
@@ -269,6 +284,19 @@
 	}
 
 
+	private String getCurrentWs() throws XmlException, IOException, FaultException {
+		EndpointReference epr = locationJPanel.getEpr("weather-client-config-epr.xml");
+		ResourceStub resourceStub = new ResourceStub(epr);
+		XmlObject[] refreshDocArry = resourceStub.getResourceProperty(weatherStationReferenceQname);
+		EndpointReferenceTypeImpl refreshDoc = (EndpointReferenceTypeImpl)refreshDocArry[0];
+		ResourceStub resourceWs = new ResourceStub(new XmlBeansEndpointReference(refreshDoc));
+		XmlObject[] nameArry = resourceWs.getResourceProperty(weatherStationNameQname);
+		XmlStringImpl nameDocument=(XmlStringImpl)nameArry[0];
+		String name = nameDocument.getStringValue();
+
+		return name;
+	}
+
 	/**
 	 * 
 	 */
@@ -317,7 +345,7 @@
 			
 			for (int id = 0; id < relationArry.length; id++) {
 				RelationshipTypeImpl relationship = (RelationshipTypeImpl) relationArry[id];
-				IWs ws1=new WsImpl(relationship,notificationListenerUrl,messagesJPanel1,""+id);
+				IWs ws1=new WsImpl(relationship,notificationListenerUrl,messagesJPanel1,""+(WcMgrApp.instanceID+id));
 				model.add(ws1);
 			}
 			
@@ -346,6 +374,9 @@
 			m_listener.stop();
 		
 		timer.stop();
+		
+		// Blank out display
+		//aasd
 
 	}
 
@@ -374,10 +405,21 @@
 			}
 			String id= parts[parts.length-1];
 			
-			LOG.log(Level.INFO,""+epr.getAddress()+" at id="+id+" Reports "+optStatus);
-			updateStatusOfWs(epr,optStatus,id);
+			//LOG.log(Level.INFO,""+epr.getAddress()+" at id="+id+" Reports "+optStatus);
+			try {
+				updateStatusOfWs(epr,optStatus,id);
+			} catch (IOException e) {
+				// TODO Auto-generated catch block
+				LOG.log(Level.ERROR,"An problem has occured parsing a received notification.",e);
+			} catch (FaultException e) {
+				// TODO Auto-generated catch block
+				LOG.log(Level.ERROR,"An problem has occured parsing a received notification.",e);
+			}
 		} catch (XmlException e) {
 			LOG.log(Level.ERROR,"An problem has occured parsing a received notification.",e);
+		} catch (ParseException e) {
+			// TODO Auto-generated catch block
+			LOG.log(Level.ERROR,"Invalid notification received. Discarding.",e);
 		}
 				
 	}
@@ -397,60 +439,48 @@
 	/**
 	 * @param epr
 	 * @param optStatus
+	 * @throws FaultException 
+	 * @throws IOException 
+	 * @throws XmlException 
 	 */
-	private void updateStatusOfWs(EndpointReferenceType epr, String optStatus,String id) {
-		String epr1=epr.getAddress().getStringValue();
+	private void updateStatusOfWs(EndpointReferenceType epr, String optStatus,String id) throws XmlException, IOException, FaultException {
+		boolean processedNotification=false;
 		for (Iterator iter = model.iterator(); iter.hasNext();) {
 			WsImpl ws = (WsImpl) iter.next();
 			if(!(ws instanceof IWc)){
-				EndpointReference eprTest = ws.getEpr();
 				
-//				// Is this an IBM Endpoint?
-//				if(epr.getAddress().getStringValue().endsWith("anonymous")){
-//					if(eprTest.getAddress().endsWith("WeatherStationSOAP")){
-//						Color color=colorFromStatus(optStatus);
-//						statusJPanel.setColor(ws.getName(),color); 
-//					}					
-//				}
-//				else {
-				if(ws.getId().equals(id)){ //eprTest.getAddress().equals(epr.getAddress().getStringValue())){
-					Object[] refProps = eprTest.getReferenceProperties();
-					XmlObject xmlRefProp = (XmlObject)epr.getReferenceProperties();
-					
-//					if(refProps!=null&&refProps.length>0){
-//						XmlObject xmlOb = (XmlObject)refProps[0];
-//						String resourceId=xmlOb.newCursor().getTextValue();
-//						String resIdOfEpr=xmlRefProp.newCursor().getTextValue();
-//						if(resourceId.equals(resIdOfEpr)){
-							Color color=colorFromStatus(optStatus);
-							statusJPanel.setColor(ws.getName(),color);								
-//						}
-//					} else {						
-//						Color color=colorFromStatus(optStatus);
-//						statusJPanel.setColor(ws.getName(),color);
-//					}
+				if(ws.getId().equals(id)){ 
+					Color color=colorFromStatus(optStatus);
+					statusJPanel.setColor(ws.getName(),color);
+					repairIfNeeded(ws.getName(),optStatus);
+					processedNotification=true;
+					break;
 				}
-//				}
-				repairIfNeeded(ws.getName(),optStatus);
 			}
+			if(!processedNotification)
+				LOG.log(Level.WARN,"Rejected message for Id="+id+" because there is no matching weather station. This may be a notification from a previous client instance.");
 		}
 	}
 
 	/**
 	 * @param name
 	 * @param optStatus
+	 * @throws FaultException 
+	 * @throws IOException 
+	 * @throws XmlException 
 	 */
-	private void repairIfNeeded(String name, String optStatus) {
+	private void repairIfNeeded(String name, String optStatus) throws XmlException, IOException, FaultException {
 //		if(optStatus.equals("Available"))
 //			return; // Don't respond to avaiable notices
 		
-		String activeWsName=getActiveWsName();
-		if(name.equals(activeWsName)){
-			LOG.log(Level.INFO,"Have decided to repair based on ACTIVE ws being "+activeWsName+" and event name being "+name +"being "+optStatus);
-			resolveWsProblem();
-		} else {
-			LOG.log(Level.INFO,"Not going to repair based on ACTIVE ws being "+activeWsName+" and event name being "+name +"being "+optStatus);
-		}
+//		String activeWsName=getCurrentWs();//getActiveWsName();
+//		if(name.equals(activeWsName)){
+//			LOG.log(Level.INFO,"Have decided to repair based on ACTIVE ws being "+activeWsName+" and event name being "+name +"being "+optStatus);
+		LOG.log(Level.INFO,"Attempting to choose the best new weather station");	
+		resolveWsProblem();
+//		} else {
+//			LOG.log(Level.INFO,"Not going to repair based on ACTIVE ws being "+activeWsName+" and event name being "+name +"being "+optStatus);
+//		}
 		
 	}
 
@@ -509,7 +539,12 @@
     public static ManagementEventTypeImpl parseManagementEvent(NotificationMessageHolderType noteMess)
             throws XmlException
     {
-     
+    	try {
+			validateXmlBean(noteMess);
+		} catch (ParseException e) {
+			// TODO Auto-generated catch block
+			LOG.log(Level.ERROR,"Failed to parse notification.",e);//e.printStackTrace();
+		}
         XmlAnyTypeImpl mess = (XmlAnyTypeImpl) noteMess.getMessage();
         ManagementEventTypeImpl manEvt =
                 (ManagementEventTypeImpl) XmlBeanUtils.getChildElements(mess)[0];
@@ -521,8 +556,10 @@
 	 * @return
 	 * @throws XmlException
 	 */
-	public static NotificationMessageHolderType getNotificationMessageHolder(String messageText) throws XmlException {
-		EnvelopeDocument ed = (EnvelopeDocument) XmlObject.Factory.parse(messageText);
+	public static NotificationMessageHolderType getNotificationMessageHolder(String messageText) throws ParseException,XmlException {
+		EnvelopeDocument ed = null;
+			ed=(EnvelopeDocument) XmlObject.Factory.parse(messageText);
+		//validateXmlBean(ed);
         org.xmlsoap.schemas.soap.envelope.Envelope env = ed.getEnvelope();
         Body body = env.getBody();
         XmlObject[] arryStuff = XmlBeanUtils.getChildElements(body);
@@ -624,4 +661,31 @@
 			}};
 			new Thread(runnable).start();				
 	}
+public static void validateXmlBean(XmlObject requestXBean) throws ParseException{
+    XmlOptions validateOptions = new XmlOptions(  );
+    List       errorList = new ArrayList(  );
+    validateOptions.setErrorListener( errorList );
+    boolean isValid = requestXBean.validate( validateOptions );
+    if ( !isValid )
+    {
+       QName        bodyElemName = XmlBeanUtils.getName( requestXBean );
+       StringBuffer strBuf = new StringBuffer( "Request body element " );
+       strBuf.append( bodyElemName);
+       strBuf.append( " is not valid as per its schema: \n\n" );
+       for ( int i = 0; i < errorList.size(  ); i++ )
+       {
+          strBuf.append( "\t\t" );
+          strBuf.append( i + 1 );
+          strBuf.append( ") " );
+          strBuf.append( errorList.get( i ) );
+          strBuf.append( "\n" );
+       }
+
+       strBuf.append( "\n" );
+       throw new ParseException(
+                                 strBuf.toString(  ),0 );
+    }
+
+	
+}
 }

Modified: webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/wcmgr/impl/WsImpl.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/wcmgr/impl/WsImpl.java?rev=239498&r1=239497&r2=239498&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/wcmgr/impl/WsImpl.java (original)
+++ webservices/muse/trunk/src/examples/ieeedemo/client/src/org/apache/interop/wcmgr/impl/WsImpl.java Tue Aug 23 18:13:54 2005
@@ -85,7 +85,7 @@
 	private void requestNotificationFromEpr() throws FaultException {
 		ResourceStub resource = new ResourceStub( wsEpr );
 		resource.addObserver(observer);
-		String listenerFullURL=listenerURL+"/"+getId();
+		String listenerFullURL=listenerURL+"/wsmgr?a=/"+getId();
 		resource.subscribe(listenerFullURL,STATUS_TOPIC_QNAME);
 		resource.deleteObserver(observer);
 	}

Added: webservices/muse/trunk/src/examples/ieeedemo/client/src/tests/TibcoTest.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/tests/TibcoTest.java?rev=239498&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/ieeedemo/client/src/tests/TibcoTest.java (added)
+++ webservices/muse/trunk/src/examples/ieeedemo/client/src/tests/TibcoTest.java Tue Aug 23 18:13:54 2005
@@ -0,0 +1,79 @@
+package tests;
+
+import java.io.IOException;
+import java.net.URL;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.interop.wcmgr.WcMgrApp;
+import org.apache.ws.util.XmlBeanUtils;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.impl.ManagementEventTypeImpl;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotificationMessageHolderType;
+import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotifyDocument;
+import org.xmlsoap.schemas.soap.envelope.Body;
+import org.xmlsoap.schemas.soap.envelope.EnvelopeDocument;
+import org.xmlsoap.schemas.ws.x2004.x08.addressing.AttributedURI;
+import org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType;
+
+public class TibcoTest extends TestCase {
+	public void testTibcoNotification() throws XmlException, IOException, ParseException{
+		URL url=new URL("file:///c:/test.xml");
+		XmlObject xmlObj = XmlObject.Factory.parse(url);
+		assertTrue(xmlObj instanceof EnvelopeDocument);
+		EnvelopeDocument ed = (EnvelopeDocument)xmlObj;
+		//ed=(EnvelopeDocument) XmlObject.Factory.parse(messageText);
+//		validateXmlBean(ed);
+	    org.xmlsoap.schemas.soap.envelope.Envelope env = ed.getEnvelope();
+	    Body body = env.getBody();
+	    XmlObject[] arryStuff = XmlBeanUtils.getChildElements(body);
+	    NotifyDocument.Notify ele = (NotifyDocument.Notify) arryStuff[0];
+	    NotificationMessageHolderType noteMess = ele.getNotificationMessageArray(0);
+		
+		ManagementEventTypeImpl manEvt = WcMgrApp.parseManagementEvent(noteMess);				
+		assertNotNull(manEvt);
+		String optStatus = WcMgrApp.parseCurrentOperationalStatus(manEvt);
+		assertNotNull(optStatus);
+		EndpointReferenceType epr = WcMgrApp.parseSourceEpr(noteMess);
+		assertNotNull(epr);
+
+		AttributedURI address = epr.getAddress();
+		assertNotNull(address);
+		
+		
+	}
+	public static void validateXmlBean(XmlObject requestXBean) throws ParseException{
+	    XmlOptions validateOptions = new XmlOptions(  );
+	    List       errorList = new ArrayList(  );
+	    validateOptions.setErrorListener( errorList );
+	    boolean isValid = requestXBean.validate( validateOptions );
+	    if ( !isValid )
+	    {
+	       QName        bodyElemName = XmlBeanUtils.getName( requestXBean );
+	       StringBuffer strBuf = new StringBuffer( "Request body element " );
+	       strBuf.append( bodyElemName);
+	       strBuf.append( " is not valid as per its schema: \n\n" );
+	       for ( int i = 0; i < errorList.size(  ); i++ )
+	       {
+	          strBuf.append( "\t\t" );
+	          strBuf.append( i + 1 );
+	          strBuf.append( ") " );
+	          strBuf.append( errorList.get( i ) );
+	          strBuf.append( "\n" );
+	       }
+
+	       strBuf.append( "\n" );
+	       throw new ParseException(
+	                                 strBuf.toString(  ),0 );
+	    }
+
+		
+	}
+}

Modified: webservices/muse/trunk/src/examples/ieeedemo/client/src/tests/WsCompatabilityTest.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/ieeedemo/client/src/tests/WsCompatabilityTest.java?rev=239498&r1=239497&r2=239498&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/ieeedemo/client/src/tests/WsCompatabilityTest.java (original)
+++ webservices/muse/trunk/src/examples/ieeedemo/client/src/tests/WsCompatabilityTest.java Tue Aug 23 18:13:54 2005
@@ -1,10 +1,10 @@
 package tests;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.OutputStream;
 import java.io.PrintStream;
-import java.io.StringBufferInputStream;
-import java.util.Calendar;
+import java.net.InetAddress;
+import java.net.URL;
+import java.text.ParseException;
 import java.util.Set;
 import java.util.TreeSet;
 
@@ -14,9 +14,9 @@
 import junit.framework.TestCase;
 
 import org.apache.interop.client.FaultException;
+import org.apache.interop.client.NotificationListener;
 import org.apache.interop.client.ResourceStub;
-import org.apache.interop.smgr.MessageListener;
-import org.apache.interop.smgr.NotificationListener;
+import org.apache.interop.wcmgr.WcMgrApp;
 import org.apache.ws.addressing.EndpointReference;
 import org.apache.ws.addressing.XmlBeansEndpointReference;
 import org.apache.ws.addressing.v2004_08_10.AddressingConstants;
@@ -27,18 +27,16 @@
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.impl.values.XmlDoubleImpl;
 import org.apache.xmlbeans.impl.values.XmlStringImpl;
-import org.mortbay.util.StringBufferWriter;
 import org.oasisOpen.docs.wsdm.x2004.x12.mows.wsdmMows.impl.DurationMetricImpl;
 import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.impl.ManagementEventTypeImpl;
 import org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart2.impl.OperationalStatusDocumentImpl;
 import org.oasisOpen.docs.wsn.x2004.x06.wsnWSBaseNotification12Draft01.NotificationMessageHolderType;
 import org.wsdmdemo.service.weatherStation.KickmeDocument;
 import org.wsdmdemo.service.weatherStation.RecalibrateDocument;
-import org.wsdmdemo.service.weatherStation.impl.PriceDocumentImpl;
+import org.wsdmdemo.service.weatherStation.impl.KickmeResponseDocumentImpl;
 import org.wsdmdemo.service.weatherStation.impl.TemperatureMetricTypeImpl;
 import org.xmlsoap.schemas.ws.x2004.x08.addressing.AttributedURI;
 import org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceType;
-import org.apache.interop.wcmgr.WcMgrApp;
 /**
  * Objective: 
  * 
@@ -84,13 +82,24 @@
 	 */
 	private StringBuffer m_buffer=new StringBuffer();
 
+	private String weatherStationEprUrl;
+
 	
 	protected void setUp() throws Exception {
 		super.setUp();
 		weatherStationURL=System.getProperty("WeatherStationServiceURL");
 		weatherStationRid=System.getProperty("WeatherStationServiceResourceID");  
 		weatherStationListenerHostname=System.getProperty("WeatherStationListenerHostname");
-		m_wsEpr=getEpr(weatherStationURL,weatherStationRid,weatherStationNameQname);
+		if(weatherStationListenerHostname==null){
+		       InetAddress addr = InetAddress.getLocalHost();
+		        weatherStationListenerHostname = addr.getHostName();
+		}
+		weatherStationEprUrl=System.getProperty("WeatherStationEprUrl");
+		if(weatherStationEprUrl==null)//-DweatherStationEprUrl=http://localhost:8080/muse/epr/weather-station-1-epr.xml
+			m_wsEpr=makeEpr(weatherStationURL,weatherStationRid,weatherStationNameQname);
+		else
+			m_wsEpr=getEpr(new URL(weatherStationEprUrl));
+		
 		m_wsResourceStub=new ResourceStub( m_wsEpr );
 	}
 
@@ -192,7 +201,7 @@
 		assertNotNull(temperatureMetric);
 				
 		double temperature = temperatureMetric.doubleValue();
-		assertTrue("Temperature should be 75 Degrees or higher during normal operation.",temperature>=75.0);
+		assertTrue("Temperature should be 75 Degrees or higher during normal operation. You returned "+temperature,temperature>=75.0);
 		assertTrue("Temperature should be 78 Degrees or less during normal operation. Your station reported "+temperature+" degrees.",temperature<=78.0);
 		return temperature;
 	}
@@ -218,12 +227,14 @@
 		String durationString=gduration.toString();
 		assertTrue(durationString.startsWith("P"));
 		assertTrue(durationString.endsWith("S"));
-		Calendar timeUpdated = durationMetric.getLastUpdated();
-		assertNotNull(timeUpdated);
-		Calendar timeReset = durationMetric.getResetAt();
-		assertNotNull(timeReset);
-		assertTrue(durationMetric.isSetLastUpdated());
-		assertTrue(durationMetric.isSetResetAt());
+		
+		// These values are not required by any client and have been dropped.
+		//Calendar timeUpdated = durationMetric.getLastUpdated();
+		//assertNotNull("Updated time required in duration.",timeUpdated);
+		//Calendar timeReset = durationMetric.getResetAt();
+		//assertNotNull("ResetAt time required in duration.",timeReset);
+		//assertTrue(durationMetric.isSetLastUpdated());
+		//assertTrue(durationMetric.isSetResetAt());
 				
 	}
 	
@@ -241,71 +252,88 @@
 	 * @throws InterruptedException 
 	 * @throws XmlException 
 	 * @throws FaultException 
+	 * @throws ParseException 
 	 *
 	 */
-	public void testRecalibrate() throws IOException, InterruptedException, XmlException, FaultException{
+	public void recalibrate() throws IOException, InterruptedException, XmlException, FaultException, ParseException{
 		//System.out.println("Starting Recal Test");
-		// Start Listener, Notifications will be passed to 
+		// Start Listener, Notifications will be passed to
+		String testID=getTestIdentifier();
 		m_listener=new NotificationListener(LISTENER_PORT,NOTIFICATION_TIMEOUT,m_buffer);
 		m_listener.start();
 		
 		// Subscribe
 		assertNotNull("Please define the WeatherStationListenerHostname System property.",weatherStationListenerHostname);
-		String notificationURL = "http://"+weatherStationListenerHostname+":"+LISTENER_PORT+"/"+weatherStationRid;
+		String notificationURL = "http://"+weatherStationListenerHostname+":"+LISTENER_PORT+"/unittest/stuff?a=/"+testID;
 		EndpointReference subscriptionEpr = m_wsResourceStub.subscribe(notificationURL,weatherStationStatusTopic,30000);
 		assertNotNull(subscriptionEpr);
 		
-		// Unit test thread will now block until a notification or a timeout occurs
-		synchronized(m_buffer){
-	        RecalibrateDocument recalibrateDocument = RecalibrateDocument.Factory.newInstance();
-	        recalibrateDocument.addNewRecalibrate();
-	        XmlObject recalResponse = m_wsResourceStub.sendRequest(recalibrateDocument,"http://recalibrate","M");
-			assertNotNull(recalResponse);
-			m_buffer.wait();
-		}
-		
-		synchronized(m_buffer){
-			String messageText=m_buffer.toString();
-			//System.out.println(messageText);			
-			m_buffer.notify();// Release the buffer
-			String status = extractStatus(messageText);
-			assertEquals("Your weather station did not report unavailable in response to recalibrate. Notfification was "+messageText+".","Unavailable",status);
-			//System.out.println("Received Unavailable in response to Recalibrate.");
-		}
-		// There should be an available notification too but endure a few 
-		// more unavailables if they are sent first
-		//System.out.println("Waiting for system to become available...");
-		synchronized(m_buffer){
-			m_buffer.wait();
-		}
-
-
-//		boolean pass=false;
-		//for(int retry=0;retry <10;retry++){			
-			synchronized(m_buffer){
-				String messageText=m_buffer.toString();		
-				//System.out.println(messageText);			
-				m_buffer.notify();// Release the buffer
-				String status = extractStatus(messageText);
-				//System.out.println("Received "+status);
-				assertEquals("Your weather station did not report available after unavailable in response to recalibrate. This message also occurs if there is a previous subscription which has not expired causing double notification.","Available",status);
-//				if(status.equals("Available")){
-//					pass=true;
-//					break;
-//				}
-			}
-		//}
+		// Recalibrate
+        RecalibrateDocument recalibrateDocument = RecalibrateDocument.Factory.newInstance();
+        recalibrateDocument.addNewRecalibrate();
+        XmlObject recalResponse = m_wsResourceStub.sendRequest(recalibrateDocument,"http://recalibrate","M");
+		assertNotNull(recalResponse);
+		
 		
+		System.out.println("Now Waiting for Unavaiulable");
+		// Wait for Unavailable
+		String status=getNextStatus(testID);		
+		assertEquals("Your weather station did not report Unavailable in response to recalibrate. It reported "+status,"Unavailable",status);
+		System.out.println("Now Waiting for Available");
+				
+		// Waiting on Available
+		String status1=getNextStatus(testID);		
+		assertEquals("Your weather station did not report Available in response to recalibrate within 60 seconds. It reported "+status1,"Available",status1);
 
 		// Destroy this subscription
 		//System.out.println("Destroying Subscription");
+		try {
 		ResourceStub subManager=new ResourceStub(subscriptionEpr);
-		subManager.destroySubscription();//EndpointReference subscriptionEpr1 = 
+		subManager.destroySubscription();//EndpointReference subscriptionEpr1 =
+		} catch (Exception e){
+			System.out.println("WARN: Your service failed to repond to a subscription destory request. This is not a failure.");
+		}
 		//System.out.println("Ending Recal Test");
 		
 	}
 
-	private String extractStatus(String messageText) throws XmlException {
+	private String getNextStatus(String testID) throws InterruptedException, XmlException, ParseException {
+		// Expecting Unavailable
+		boolean searching=true;
+		String messageText=null;
+		String messageUri=null;
+		while(searching){
+			synchronized(m_buffer){
+				// Unit test thread will now block until a notification or a timeout occurs
+				if(!m_listener.isReady()){
+					System.out.println("WAITING FOR BUFFER TO NOTIFY.....");
+					m_buffer.wait();
+				} else 
+					System.out.println("BUFFER is FULL. Proceeding");
+
+				System.out.println("GOT NOTIFY");
+				messageText=m_buffer.toString();
+				messageUri=m_listener.getRequestUri();
+			}
+			
+			synchronized(m_buffer){
+				m_buffer.notify();// Release the buffer
+			}
+			searching=!isNotificationForMe(testID,messageUri);
+			if(searching)
+				System.out.println("Received notification not for this test. Ignoring.");
+		}
+		
+		String status = extractStatus(messageText);
+		assertNotNull("Status NULL when expecting unavailable for message\n"+messageText,status);
+		return status;
+	}
+
+	private boolean isNotificationForMe(String testID, String messageUri) {
+		return messageUri.endsWith("/"+testID);
+	}
+
+	private String extractStatus(String messageText) throws XmlException, ParseException {
 
 		// Break down the message
 		assertNotNull("The content received as a notifications was null.",messageText);
@@ -314,6 +342,7 @@
 		ManagementEventTypeImpl manEvt = WcMgrApp.parseManagementEvent(noteMess);				
 		assertNotNull(manEvt);
 		String optStatus = WcMgrApp.parseCurrentOperationalStatus(manEvt);
+		System.out.println("Read Resonse to "+manEvt+" is "+optStatus);
 		assertNotNull(optStatus);
 		EndpointReferenceType epr = WcMgrApp.parseSourceEpr(noteMess);
 		assertNotNull(epr);
@@ -321,9 +350,9 @@
 		AttributedURI address = epr.getAddress();
 		assertNotNull(address);
 		
-		// Make sure that the POST Uri is the same as the URI provided by the subscription request.
+		//OBSOLETE: Make sure that the POST Uri is the same as the URI provided by the subscription request.
 		// This is how notifications will be sorted by clients 
-		assertEquals("The Notification URI should match the URI provided by the subscriber. This is required because the client may need to identify your notifications from other weather stations.","/"+weatherStationRid,m_listener.getRequestUri());
+		//assertTrue("The Notification URI should match the URI provided by the subscriber. This is required because the client may need to identify your notifications from other weather stations. You used "+m_listener.getRequestUri()+" but it should have ended with /1",testID,m_listener.getRequestUri().endsWith("/1"));
 		return optStatus;
 	}
 	
@@ -334,13 +363,15 @@
 	 * @throws XmlException 
 	 * @throws InterruptedException 
 	 * @throws IOException 
+	 * @throws ParseException 
 	 *
 	 */
-	public void testForKickResponse() throws FaultException, IOException, InterruptedException, XmlException{
+	public void testForKickResponse() throws FaultException, IOException, InterruptedException, XmlException, ParseException{
         KickmeDocument kickmeDocument = KickmeDocument.Factory.newInstance();
         kickmeDocument.addNewKickme();
         XmlObject kickResponse = m_wsResourceStub.sendRequest(kickmeDocument,"http://kickme","M");
 		assertNotNull(kickResponse);
+		assertTrue("Expected KickmeResponseDocumentImpl but got "+kickResponse.getClass(),kickResponse.getClass().getName().startsWith("org.wsdmdemo.service.weatherStation.impl.KickmeResponseDocumentImpl"));
 
 		// Temperature should drop below 75
 		XmlObject[] responseArry=m_wsResourceStub.getResourceProperty(weatherStationTemperatureQname);
@@ -358,7 +389,7 @@
 
 		// Issue a recalibrate. This should reset the temperature to range after going 
 		// unavaiable and then available.
-		testRecalibrate();
+		recalibrate();
 		
 		// Get temp and check is it is in range.
 		getCurrentTemperature();
@@ -374,50 +405,88 @@
 	 * @return
 	 * @throws XmlException
 	 */
-	private EndpointReference getEpr(String URL, String Rid, QName weatherStationNameQname) throws XmlException{
+	private EndpointReference makeEpr(String URL, String Rid, QName weatherStationNameQname) throws XmlException{
 		XmlBeansEndpointReference x=new XmlBeansEndpointReference(URL,AddressingConstants.NSURI_ADDRESSING_SCHEMA);
 		if(Rid!=null)
 			x.setReferenceProperties(new XmlObject[]{(XmlObject)XmlObject.Factory.parse("<svr:ResourceIdentifier xmlns:svr=\""+weatherStationNameQname.getNamespaceURI()+"\">"+Rid+"</svr:ResourceIdentifier>")});		
 		return x;		
 	}
 
+    private static XmlBeansEndpointReference getEpr(URL url) throws XmlException, IOException 
+    {
+    	XmlObject xmlObj = XmlObject.Factory.parse(url);
+    	if(xmlObj instanceof org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceDocument){
+    		org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceDocument epr0408=
+    			(org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceDocument)xmlObj;
+    		return new XmlBeansEndpointReference(epr0408.getEndpointReference());
+    	} else {
+        	if(xmlObj instanceof org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceDocument){
+        		org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceDocument epr0303=
+        			(org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceDocument)xmlObj;
+        		return new XmlBeansEndpointReference(epr0303.getEndpointReference());
+        	}	
+    	}
+    	//return new XmlBeansEndpointReference(XmlObject.Factory.parse(url).);
+    	//.getEndpointReference()
+    	return null;
+    	//return (org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceDocument) ;
+    }
+
+	
 	public static void main(String[] args) {
 		if(args.length==0){
-			System.out.println("Usage: wstest <ServiceURL> <ServiceResourceID> <ListenerHostname>");
+			System.out.println("Usage: wstest <ServiceURL> <ServiceResourceID> <ListenerHostname>\nor");
+			System.out.println("Usage: wstest <EprURL>");
 			return;
 		}
+		
+		if(args.length==1){
+			System.setProperty("WeatherStationEprUrl",args[0]);
+		}
+		else {
 		if(args.length>=1)
 			System.setProperty("WeatherStationServiceURL",args[0]);
 		if(args.length>=2)
 			System.setProperty("WeatherStationServiceResourceID",args[1]);
 		if(args.length>=3)
 			System.setProperty("WeatherStationListenerHostname",args[2]);
-		
+		}
 		junit.textui.TestRunner.run(WsCompatabilityTest.class);
 		
 	}
 	public static void runTests(String[] args, JspWriter jspw) {//PrintStream
 		if(args.length==0){
-			System.out.println("Usage: wstest <ServiceURL> <ServiceResourceID> <ListenerHostname>");
+			System.out.println("Usage: wstest <ServiceURL> <ServiceResourceID> <ListenerHostname>\n   or");
+			System.out.println("Usage: wstest <EprURL>");
 			return ;
 		}
-		if(args.length>=1)
-			System.setProperty("WeatherStationServiceURL",args[0]);
-		if(args.length>=2)
-			System.setProperty("WeatherStationServiceResourceID",args[1]);
-		if(args.length>=3)
-			System.setProperty("WeatherStationListenerHostname",args[2]);
-		
+		if(args.length==1){
+			System.setProperty("WeatherStationEprUrl",args[0]);
+		}
+		else {
+			if(args.length>=1)
+				System.setProperty("WeatherStationServiceURL",args[0]);
+			if(args.length>=2)
+				System.setProperty("WeatherStationServiceResourceID",args[1]);
+			if(args.length>=3)
+				System.setProperty("WeatherStationListenerHostname",args[2]);
+		}		
 		PrintStream saveOut = System.out;
 		ByteArrayOutputStream os=new ByteArrayOutputStream();
 		PrintStream sbip = new PrintStream(os);
 		System.setOut(sbip);
 		junit.textui.TestRunner.run(WsCompatabilityTest.class);
+		//junit.textui.TestRunner.run()
 		System.setOut(saveOut);
 		try {
 			jspw.println(os.toString());
 		} catch (IOException e) {		
 			e.printStackTrace();
 		}
+	}
+	
+	public static String getTestIdentifier(){
+		long id=Math.round(Math.random()*100000);	
+		return ""+id;
 	}
 }



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