Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 63763 invoked from network); 20 Jun 2005 08:02:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Jun 2005 08:02:02 -0000 Received: (qmail 1244 invoked by uid 500); 20 Jun 2005 08:02:01 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 1138 invoked by uid 500); 20 Jun 2005 08:02:01 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 1116 invoked by uid 99); 20 Jun 2005 08:02:00 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 20 Jun 2005 01:01:55 -0700 Received: (qmail 62055 invoked by uid 65534); 20 Jun 2005 08:01:17 -0000 Message-ID: <20050620080117.62054.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r191417 - in /webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http: HTTPTransportReceiver.java SimpleHTTPServer.java Date: Mon, 20 Jun 2005 08:01:16 -0000 To: axis-cvs@ws.apache.org From: hemapani@apache.org X-Mailer: svnmailer-1.0.2 X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: hemapani Date: Mon Jun 20 01:01:16 2005 New Revision: 191417 URL: http://svn.apache.org/viewcvs?rev=191417&view=rev Log: refactor the GET support for the Simple Axis Server Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportReceiver.java webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportReceiver.java URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportReceiver.java?rev=191417&r1=191416&r2=191417&view=diff ============================================================================== --- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportReceiver.java (original) +++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportReceiver.java Mon Jun 20 01:01:16 2005 @@ -16,8 +16,13 @@ package org.apache.axis.transport.http; import java.io.IOException; +import java.io.OutputStream; import java.io.Reader; +import java.util.Collection; +import java.util.Enumeration; import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; import java.util.Map; import javax.xml.stream.XMLInputFactory; @@ -28,6 +33,8 @@ import org.apache.axis.addressing.EndpointReference; import org.apache.axis.context.ConfigurationContext; import org.apache.axis.context.MessageContext; +import org.apache.axis.description.OperationDescription; +import org.apache.axis.description.ServiceDescription; import org.apache.axis.engine.AxisFault; import org.apache.axis.om.impl.llom.builder.StAXBuilder; import org.apache.axis.om.impl.llom.builder.StAXOMBuilder; @@ -106,40 +113,47 @@ msgContext.setProperty( MessageContext.TRANSPORT_SUCCEED, HTTPConstants.RESPONSE_ACK_CODE_VAL); - return soapEnvelope; - } - msgContext.setWSAAction((String) map.get(HTTPConstants.HEADER_SOAP_ACTION)); - Utils.configureMessageContextForHTTP( - (String) map.get(HTTPConstants.HEADER_CONTENT_TYPE), - msgContext.getWSAAction(), - msgContext); - - String requestURI = (String) map.get(HTTPConstants.REQUEST_URI); - msgContext.setTo(new EndpointReference(AddressingConstants.WSA_TO, requestURI)); - //getServiceLookUp(requestURI))); - - // TODO see is it a Service request e.g. WSDL, list .... - // TODO take care of the other HTTPHeaders - try { - //Check for the REST behaviour, if you desire rest beahaviour - //put a at the server.xml/client.xml file - Object doREST = msgContext.getProperty(Constants.Configuration.DO_REST); - XMLStreamReader xmlreader = XMLInputFactory.newInstance().createXMLStreamReader(in); - StAXBuilder builder = null; - SOAPEnvelope envelope = null; - if (doREST != null && "true".equals(doREST)) { - SOAPFactory soapFactory = new SOAP11Factory(); - builder = new StAXOMBuilder(xmlreader); - builder.setOmbuilderFactory(soapFactory); - envelope = soapFactory.getDefaultEnvelope(); - envelope.getBody().addChild(builder.getDocumentElement()); - } else { - builder = new StAXSOAPModelBuilder(xmlreader); - envelope = (SOAPEnvelope) builder.getDocumentElement(); + return null; + }else if(HTTPConstants.HEADER_GET.equals(map.get(HTTPConstants.HTTP_REQ_TYPE))) { + this.handleGETRequest((String)map.get(HTTPConstants.REQUEST_URI), + (OutputStream)map.get(MessageContext.TRANSPORT_OUT), + msgContext.getSystemContext()); + return null; + }else{ + msgContext.setWSAAction((String) map.get(HTTPConstants.HEADER_SOAP_ACTION)); + Utils.configureMessageContextForHTTP( + (String) map.get(HTTPConstants.HEADER_CONTENT_TYPE), + msgContext.getWSAAction(), + msgContext); + + String requestURI = (String) map.get(HTTPConstants.REQUEST_URI); + msgContext.setTo(new EndpointReference(AddressingConstants.WSA_TO, requestURI)); + //getServiceLookUp(requestURI))); + + // TODO see is it a Service request e.g. WSDL, list .... + // TODO take care of the other HTTPHeaders + try { + //Check for the REST behaviour, if you desire rest beahaviour + //put a at the server.xml/client.xml file + Object doREST = msgContext.getProperty(Constants.Configuration.DO_REST); + XMLStreamReader xmlreader = XMLInputFactory.newInstance().createXMLStreamReader(in); + StAXBuilder builder = null; + SOAPEnvelope envelope = null; + if (doREST != null && "true".equals(doREST)) { + SOAPFactory soapFactory = new SOAP11Factory(); + builder = new StAXOMBuilder(xmlreader); + builder.setOmbuilderFactory(soapFactory); + envelope = soapFactory.getDefaultEnvelope(); + envelope.getBody().addChild(builder.getDocumentElement()); + } else { + builder = new StAXSOAPModelBuilder(xmlreader); + envelope = (SOAPEnvelope) builder.getDocumentElement(); + } + return envelope; + } catch (Exception e) { + throw new AxisFault(e.getMessage(), e); } - return envelope; - } catch (Exception e) { - throw new AxisFault(e.getMessage(), e); + } } else { throw new AxisFault("Input reader not found"); @@ -500,18 +514,73 @@ } } - // private String getServiceLookUp(String requestURI) throws AxisFault { - // final String URI_ID_STRING = "/services"; - // String filePart = requestURI; - // - // int index = filePart.lastIndexOf(URI_ID_STRING); - // String serviceStr = null; - // if (index > 0) { - // serviceStr = filePart.substring(index + URI_ID_STRING.length() + 1); - // return serviceStr; - // - // } else { - // throw new AxisFault("Both the URI and SOAP_ACTION are Null"); - // } - // } + private void handleGETRequest(String reqUri, OutputStream out,ConfigurationContext configurationContext) { + + try { + out.write(this.getServicesHTML(configurationContext).getBytes()); + out.flush(); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } +} + + +/** + * Returns the HTML text for the list of services deployed + * This can be delegated to another Class as well + * where it will handle more options of GET messages :-? + * @return + */ +private String getServicesHTML(ConfigurationContext configurationContext) { + String temp = ""; + Map services = configurationContext.getAxisConfiguration().getServices(); + Hashtable erroneousServices = configurationContext.getAxisConfiguration().getFaulytServices(); + boolean status = false; + + if(services!= null && !services.isEmpty()) { + status = true; + Collection serviceCollection = services.values(); + for(Iterator it = serviceCollection.iterator(); it.hasNext();) { + Map operations; + Collection operationsList; + ServiceDescription axisService = (ServiceDescription) it.next(); + operations = axisService.getOperations(); + operationsList = operations.values(); + temp += "

" + "Deployed services" + "

"; + temp += "

" + axisService.getName().getLocalPart() + "

"; + if(operationsList.size() > 0) { + temp += "Available operations
    "; + for (Iterator iterator1 = operationsList.iterator(); iterator1.hasNext();) { + OperationDescription axisOperation = (OperationDescription) iterator1.next(); + temp += "
  • " + axisOperation.getName().getLocalPart() + "
  • "; + } + temp += "
"; + } else { + temp += "No operations speficied for this service"; + } + } + } + + if(erroneousServices != null && !erroneousServices.isEmpty()) { + + temp += "

Faulty Services

"; + status = true; + Enumeration faultyservices = erroneousServices.keys(); + while (faultyservices.hasMoreElements()) { + String faultyserviceName = (String) faultyservices.nextElement(); + temp += "

" + faultyserviceName + "

"; + } + } + + if(!status) { + temp = "

There are no services deployed

"; + } + + temp = "Axis2: Services" + + "" + temp + ""; + + return temp; +} + } Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java?rev=191417&r1=191416&r2=191417&view=diff ============================================================================== --- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java (original) +++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/SimpleHTTPServer.java Mon Jun 20 01:01:16 2005 @@ -22,11 +22,6 @@ import java.io.Reader; import java.net.ServerSocket; import java.net.Socket; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Map; import javax.xml.namespace.QName; @@ -37,13 +32,12 @@ import org.apache.axis.context.ConfigurationContext; import org.apache.axis.context.ConfigurationContextFactory; import org.apache.axis.context.MessageContext; -import org.apache.axis.description.OperationDescription; import org.apache.axis.description.Parameter; -import org.apache.axis.description.ServiceDescription; import org.apache.axis.description.TransportInDescription; import org.apache.axis.description.TransportOutDescription; import org.apache.axis.engine.AxisEngine; import org.apache.axis.engine.AxisFault; +import org.apache.axis.soap.SOAPEnvelope; import org.apache.axis.transport.TransportListener; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -164,34 +158,33 @@ msgContext.setProperty(MessageContext.TRANSPORT_OUT, out); msgContext.setProperty(MessageContext.TRANSPORT_READER, in); HTTPTransportReceiver reciver = new HTTPTransportReceiver(); - + /* * If the request is a GET request then * process the request and send out HTML * if not get the soap message and process it - */ - Map map = reciver.parseTheHeaders(in,msgContext.isServerSide()); - if(map.get(HTTPConstants.HTTP_REQ_TYPE).equals(HTTPConstants.HEADER_POST)) { - //Handle POST Request - msgContext.setEnvelope( - reciver.checkForMessage(msgContext, configurationContext, map)); - - AxisEngine engine = new AxisEngine(configurationContext); - engine.receive(msgContext); - - Object contextWritten = - msgContext.getProperty(Constants.RESPONSE_WRITTEN); - if (contextWritten == null - || !Constants.VALUE_TRUE.equals(contextWritten)) { - out.write(new String(HTTPConstants.NOCONTENT).getBytes()); - out.close(); - } - - log.info("status written"); - } else if(map.get(HTTPConstants.HTTP_REQ_TYPE).equals(HTTPConstants.HEADER_GET)) { - this.handleGETRequest((String)map.get(HTTPConstants.REQUEST_URI), out); + */ + + //Handle POST Request + SOAPEnvelope envelope = + reciver.checkForMessage(msgContext, configurationContext); + + if (envelope != null) { + msgContext.setEnvelope(envelope); + + AxisEngine engine = new AxisEngine(configurationContext); + engine.receive(msgContext); + + Object contextWritten = + msgContext.getProperty(Constants.RESPONSE_WRITTEN); + if (contextWritten == null + || !Constants.VALUE_TRUE.equals(contextWritten)) { + out.write(new String(HTTPConstants.NOCONTENT).getBytes()); + out.close(); + } + } - + } } catch (Throwable e) { log.error(e); @@ -301,7 +294,11 @@ ServerSocket serverSoc = null; serverSoc = new ServerSocket(Integer.parseInt(args[1])); SimpleHTTPServer reciver = new SimpleHTTPServer(args[0], serverSoc); - System.out.println("starting SimpleHTTPServer in port "+args[1]+ " using the repository "+ new File(args[0]).getAbsolutePath()); + System.out.println( + "starting SimpleHTTPServer in port " + + args[1] + + " using the repository " + + new File(args[0]).getAbsolutePath()); reciver.setServerSocket(serverSoc); Thread thread = new Thread(reciver); thread.setDaemon(true); @@ -331,73 +328,4 @@ } } - private void handleGETRequest(String reqUri, OutputStream out) { - - try { - out.write(this.getServicesHTML().getBytes()); - out.flush(); - out.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - - /** - * Returns the HTML text for the list of services deployed - * This can be delegated to another Class as well - * where it will handle more options of GET messages :-? - * @return - */ - private String getServicesHTML() { - String temp = ""; - Map services = this.configurationContext.getAxisConfiguration().getServices(); - Hashtable erroneousServices = this.configurationContext.getAxisConfiguration().getFaulytServices(); - boolean status = false; - - if(services!= null && !services.isEmpty()) { - status = true; - Collection serviceCollection = services.values(); - for(Iterator it = serviceCollection.iterator(); it.hasNext();) { - Map operations; - Collection operationsList; - ServiceDescription axisService = (ServiceDescription) it.next(); - operations = axisService.getOperations(); - operationsList = operations.values(); - temp += "

" + "Deployed services" + "

"; - temp += "

" + axisService.getName().getLocalPart() + "

"; - if(operationsList.size() > 0) { - temp += "Available operations
    "; - for (Iterator iterator1 = operationsList.iterator(); iterator1.hasNext();) { - OperationDescription axisOperation = (OperationDescription) iterator1.next(); - temp += "
  • " + axisOperation.getName().getLocalPart() + "
  • "; - } - temp += "
"; - } else { - temp += "No operations speficied for this service"; - } - } - } - - if(erroneousServices != null && !erroneousServices.isEmpty()) { - - temp += "

Faulty Services

"; - status = true; - Enumeration faultyservices = erroneousServices.keys(); - while (faultyservices.hasMoreElements()) { - String faultyserviceName = (String) faultyservices.nextElement(); - temp += "

" + faultyserviceName + "

"; - } - } - - if(!status) { - temp = "

There are no services deployed

"; - } - - temp = "Axis2: Services" + - "" + temp + ""; - - return temp; - } - }