You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by da...@apache.org on 2003/09/26 16:24:28 UTC

cvs commit: ws-axis/c/src/client/transport/axis AxisTransport.cpp AxisTransport.h Channel.cpp Channel.hpp HttpTransport.cpp HttpTransport.hpp Makefile.am Platform.hpp Receiver.cpp Receiver.hpp Sender.cpp Sender.hpp Transport.cpp Transport.hpp TransportFactory.cpp TransportFactory.hpp Url.cpp Url.hpp

damitha     2003/09/26 07:24:28

  Added:       c/src/client Makefile.am autogen.sh configure.ac runconfig
               c/src/client/transport Makefile.am
               c/src/client/transport/axis AxisTransport.cpp
                        AxisTransport.h Channel.cpp Channel.hpp
                        HttpTransport.cpp HttpTransport.hpp Makefile.am
                        Platform.hpp Receiver.cpp Receiver.hpp Sender.cpp
                        Sender.hpp Transport.cpp Transport.hpp
                        TransportFactory.cpp TransportFactory.hpp Url.cpp
                        Url.hpp
  Log:
  log: Added transport layer code for client side
  
  Revision  Changes    Path
  1.1                  xml-axis/c/src/client/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  lib_LTLIBRARIES = libaxiscpp_client.la
  SUBDIRS = transport
  AM_CPPFLAGS = -Wshadow -Wall -pedantic -ansi
  libaxiscpp_client_la_SOURCES =	Call.cpp
  libaxiscpp_client_la_LIBADD   = ./transport/axis/libtransport.la -ldl -lstdc++
  
  INCLUDES = -I$(AXISCPP_HOME)/include
  
  
  
  1.1                  xml-axis/c/src/client/autogen.sh
  
  Index: autogen.sh
  ===================================================================
  #! /bin/sh
  
  # $Id: autogen.sh,v 1.1 2003/09/26 14:24:28 damitha Exp $
  #
  # Copyright (c) 2002  Daniel Elstner  <da...@gmx.net>
  #
  # This program is free software; you can redistribute it and/or modify
  # it under the terms of the GNU General Public License VERSION 2 as
  # published by the Free Software Foundation.  You are not allowed to
  # use any other version of the license; unless you got the explicit
  # permission from the author to do so.
  #
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
  #
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  
  
  dir=`echo "$0" | sed 's,[^/]*$,,'`
  test "x${dir}" = "x" && dir='.'
  
  if test "x`cd "${dir}" 2>/dev/null && pwd`" != "x`pwd`"
  then
      echo "This script must be executed directly from the source directory."
      exit 1
  fi
  
  rm -f config.cache acconfig.h
  
  echo "- libtoolize."		&& \
  libtoolize --force		&& \
  echo "- aclocal."		&& \
  aclocal				&& \
  echo "- autoconf."		&& \
  autoconf			&& \
  echo "- autoheader."		&& \
  autoheader			&& \
  echo "- automake."		&& \
  automake --add-missing --gnu	&&
  #echo				&& \
  #./configure "$@"		&& exit 0
  
  exit 1
  
  
  
  
  1.1                  xml-axis/c/src/client/configure.ac
  
  Index: configure.ac
  ===================================================================
  AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
  AM_INIT_AUTOMAKE(0.3)
  AM_CONFIG_HEADER(config.h)
  CFLAGS="-Wall -Wshadow"
  LDFLAGS="-s"
  AC_PROG_CC
  AC_PROG_CXX
  AC_PROG_INSTALL
  AC_PROG_LIBTOOL
  AC_OUTPUT(Makefile transport/Makefile transport/axis/Makefile)
  
  
  
  1.1                  xml-axis/c/src/client/runconfig
  
  Index: runconfig
  ===================================================================
  #!/bin/bash
  configure --libdir=$AXISCPP_HOME/src/client/lib
  
  
  
  1.1                  xml-axis/c/src/client/transport/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  SUBDIRS = axis
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/AxisTransport.cpp
  
  Index: AxisTransport.cpp
  ===================================================================
  #include <stdio.h>
  #include <string.h>
  #include <iostream.h>
  #include "../../../common/Packet.h"
  AxisTransport::AxisTransport(Ax_soapstream* pSoap)
  {
      m_pSoap = pSoap;
      m_pSender = NULL;
      m_pReceiver = NULL;
      m_pHttpTransport = NULL;       
  }
  
  AxisTransport::~AxisTransport()
  {
      if(m_pSender)
          delete m_pSender;
      if(m_pReceiver)
          delete m_pReceiver;
      if(m_pHttpTransport)
          delete m_pHttpTransport;
  }
  
  int AxisTransport::OpenConnection()
  {
      //Step 1 - Open Transport layer connection taking into account protocol and endpoint URI in m_Soap
      Url objUrl(m_pSoap->so.http.uri_path);
      TransportFactory objTransportFactory;
      m_pHttpTransport = objTransportFactory.getTransport(objUrl);
      if(m_pHttpTransport->Init())
      {
         m_pSender = new Sender(m_pHttpTransport);
         m_pReceiver = new Receiver(m_pHttpTransport);
         //Step 2 - Set Created streams to m_Soap.str.ip_stream and m_Soap.str.op_stream
         m_pSoap.str.op_stream = m_pSender;
         m_pSoap.str.ip_stream = m_pReceiver;
         
         //Step 3 - Add function pointers to the m_Soap structure
         m_pSoap.transport.pGetFunct = Get_bytes;
         m_pSoap.transport.pSendFunct = Send_bytes;
         m_pSoap.transport.pGetTrtFunct = Receive_transport_information;
         m_pSoap.transport.pSendTrtFunct = Send_transport_information; 
      }
      else
          return FAIL;
  }        
  
  void AxisTransport::CloseConnection()
  {
  //Step 1 - Close 2 streams
  	//Step 2 - Possibly delete the streams
  	//Step 3 - Set function pointers in the m_Soap structure to NULL;
  	m_Soap.transport.pGetFunct = NULL;
  	m_Soap.transport.pSendFunct = NULL;
  	m_Soap.transport.pGetTrtFunct = NULL;
  	m_Soap.transport.pSendTrtFunct = NULL;
  }
  
  int AxisTransport::Send_bytes(const char* pSendBuffer, const void* pStream)
  {
      Sender* pSender = (Sender*) pStream;
      if(pSender->Send(pSendBuffer))
          return SUCCESS;
      return FAIL;
      
  }
  
  int AxisTransport::Get_bytes(char* pRecvBuffer, int nBuffSize, int* pRecvSize, const void* pStream)
  {
      Receiver* pReceiver = (Receiver*) pStream;
      const string& strReceive =  pReceiver->Recv();
      
      strcpy(pRecvBuffer, strReceive.c_str());
  }
  
  int AxisTransport::Send_transport_information(void* pSoapStream)
  {
      Ax_soapstream* pSoapStream = (Ax_soapstream*) pSoapStream;    
      
  }
  
  int AxisTransport::Receive_transport_information(void* pSoapStream)
  {
  }
  
  
  1.1                  ws-axis/c/src/client/transport/axis/AxisTransport.h
  
  Index: AxisTransport.h
  ===================================================================
  #if !defined(_AXIS_AXIS_TRANSPORT_HPP)
  #define _AXIS_AXIS_TRANSPORT_HPP
  
  class AxisTransport
  {
      public:
          AxisTransport(Ax_soapstream* pSoap);
          ~AxisTransport();
  
          int OpenConnection();
          void CloseConnection();
          static int Send_bytes(const char* pSendBuffer, const void* pStream);
          static int Get_bytes(char* pRecvBuffer, int nBuffSize, int* pRecvSize, const void* pStream);
          static int Send_transport_information(void* pSoapStream); /*Ax_soapstream*/
          static int Receive_transport_information(void* pSoapStream);/*Ax_soapstream*/
  
      private:
          HttpTransport* m_pHttpTransport;
          Sender* m_pSender;
          Receiver* m_pReceiver;
          Ax_soapstream* m_pSoap;
  
  }
  
  
  
      
  
  
  1.1                  ws-axis/c/src/client/transport/axis/Channel.cpp
  
  Index: Channel.cpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  #include "Platform.hpp"
  #include "Channel.hpp"
  #include <iostream>
  #include "Transport.hpp"
  
  using namespace std;
  /**
   * Create a Channel & initialize
   * 
   */
  
  Channel::Channel() : m_Sock(INVALID_SOCKET)
  {
  
  }
  
  Channel::~Channel()
  {
  	CloseChannel();
  }
  
  
  /**
   * This channel open INET channel for the time being using primitive sockets
   * Do we need any other type of channel; like shared memory, pipes etc. ????
   * 
   * @param	p_RemoteNode	End point address as hostname/IP
   * @param	p_RemoteEnd		Port #
   *
   * @return  true if successfuly open a soket to the endpoint. o/w exception is thrown
   */
  
  bool Channel::Open(std::string& p_RemoteNode, unsigned short p_RemoteEnd) throw (ChannelException)
  {
  	m_RemoteNode = p_RemoteNode;
  	m_RemoteEnd  = p_RemoteEnd;
  
  	if(!Init())
  		throw ChannelException("Cannot initialize a channel to the remote end");
  
  	sockaddr_in clAddr, svAddr;			  
  
  	if ((m_Sock = socket(PF_INET, SOCK_STREAM, 0)) != INVALID_SOCKET)
  	{
  		clAddr.sin_family = AF_INET;     // AF_INET (address family Internet).
  		clAddr.sin_port   = 0; 			 // No Specify Port required
  		clAddr.sin_addr.s_addr = INADDR_ANY;
  
  		if (bind(m_Sock, (struct sockaddr*) &clAddr, sizeof(clAddr)) == SOCKET_ERROR)
  		{
  			Error("Error - Binding");
  			CloseChannel();
  			throw ChannelException("Cannot open a channel to the remote end, shutting down the channel");
  		}
  
  		// Although the above fragment makes use of the bind() API, it would be
  		// just as effective to skip over this call as there are no specific
  		// local port ID requirements for this client. The only advantage that
  		// bind() offers is the accessibility of the port which the system chose
  		// via the .sin_port member of the cli_addr structure which will be set
  		// upon success of the bind() call.
  
  		svAddr.sin_family = AF_INET;
  		svAddr.sin_port   = htons(m_RemoteEnd);
  
  		struct hostent*  pHostEntry = NULL;
  
  		// probably this is the host-name of the server we are connecting to
  		if((pHostEntry = gethostbyname(m_RemoteNode.c_str())))
  		{
  			svAddr.sin_addr.s_addr = ((struct in_addr *)pHostEntry->h_addr)->s_addr;
  		}
  		else
  		{
  			// no this is the IP address
  			svAddr.sin_addr.s_addr = inet_addr(m_RemoteNode.c_str());	
  		}
  
  		// connect to the remote server.
  		if (connect(m_Sock,(struct sockaddr*)&svAddr, sizeof(svAddr)) == SOCKET_ERROR)
  		{
  			Error("Sockets error Couldn't connect socket.");
  			CloseChannel();
  			throw ChannelException("Cannot open a channel to the remote end, shutting down the channel");
  		}
  	}
  	else
  	{
  		Error("Sockets error Couldn't create socket.");
  		CloseChannel();
  		throw ChannelException("Cannot open a channel");
  	}
  	return true;
  }
  
  /**
   * OS specific initialization should do here
   *
   * @return  true if successfuly initilaize OS specific stuffs. false o/w
   */
  
  bool Channel::Init()
  {
  #ifdef WIN32
  
  	WSADATA wsaData;			// contains vendor-specific information, such as the
  								// maximum number of sockets available and the maximum
  								// datagram size.
  
  	if(WSAStartup(WS_VERSION_REQD, &wsaData))  //Filled by Windows Sockets DLLs
  	{
  		m_LastErr = "WinSock DLL not responding.";
  		Error((char *)m_LastErr.c_str());
  		return false;
  	}
  	else
  	{ 
  		// Query to see whether the available version matches what we need
  		if (( LOBYTE (wsaData.wVersion) < WS_VERSION_MAJOR()) ||
  			 (LOBYTE (wsaData.wVersion) == WS_VERSION_MAJOR() &&
  			  HIBYTE (wsaData.wVersion) < WS_VERSION_MINOR()))
  		{
  			char buf[100];
  			sprintf(buf,"Windows Sockets version %d.%d not supported by winsock2.dll",
  						LOBYTE (wsaData.wVersion), HIBYTE (wsaData.wVersion));
  			Error(buf);
  			CloseChannel();
  			return false;
  		}
  	}
  #else
      //cout << "no need for linux" << endl;
  	// other OS specific Intitialization goes here
  #endif
  	return true;
  }
  
  /**
   * Write/send a message to the remote server; sending blocks the app.
   * we may need to do this asynchronizely; preferably either non-blocking
   * send or pthread.
   *
   * @param	Message to be written to the open channel
   */
  const Channel& Channel::operator << (const std::string& msg)
  {
  	if(INVALID_SOCKET == m_Sock) 
  	{
  		Error("Writing cannot be done without having a open socket to remote end.");
  		throw ChannelException("Output streaming error on undefined channel; please open the channel first");
  	}
  
  	int size = msg.size(), nByteSent;
      
  	if((nByteSent = send(m_Sock, (char *)msg.c_str(), size, MSG_DONTROUTE )) == SOCKET_ERROR)
  	{
  		Error("Output streaming error while writing data.");
  		CloseChannel();
  		throw ChannelException("Output streaming error on Channel while writing data");
  	}
  
  	return *this;
  }
  
  /**
   * Read/receive a message from the remote server; reading may be done in chunks.
   *
   * @param	string to hold the read Message 
   */
  
  const Channel& Channel::operator >> (std::string& msg)
  {
  	if(INVALID_SOCKET == m_Sock) 
  	{
  		Error("Reading cannot be done without having a open socket.");
  		throw ChannelException("Input streaming error on undefined channel; please open the channel first");
  	}
  
  	int nByteRecv = 0;
  	const int BUF_SIZE = 4096;
  	char buf[BUF_SIZE];
  	
  	do	// Manage multiple chuncks of the message
  	{
  		if ((nByteRecv = recv(m_Sock, (char *) &buf, BUF_SIZE - 1, 0)) == SOCKET_ERROR)
  		{
  			Error("Channel error while getting data.");
  			CloseChannel();
  			throw ChannelException("Input streaming error on Channel while getting data");
  		}
  
  		if(nByteRecv)
  		{
  			buf[nByteRecv + 1] = '\0';	// got a part of the message, so add it to form 
  			msg += buf;					// the whole message
  
  			//Validate according to the transport; check whether we are in a position to return.
  			if (!m_pTransportHandler->GetStatus(msg)) 
  				break;
  		}
  		else
  			break; // we have the whole message or an error has occured
  	 }
  	 while (true);
  
  	 return *this;
  }
  
  /**
   *	Close, and clean-up any OS specific stuff
   *
   */
  
  void Channel::CloseChannel()
  {
  #ifdef WIN32
  	if(INVALID_SOCKET != m_Sock)
  		closesocket(m_Sock);
  	
  	// Check for any possible error conditions from WSACleanup() and report
  	// them before exiting, as this information might indicate a network
  	// layer problem in the system.
  
  	WSACleanup();
  #else
  	if(INVALID_SOCKET != m_Sock)
  		close(m_Sock);
  
  #endif
  }
  
  /**
   * Log any errors that cause on channel usage/initilaization
   *
   */
  
  void Channel::Error(const char * err)
  {
  #ifdef _DEBUG
  	std::cerr << err << std::endl;
  #endif
  }
  
  
  
  
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/Channel.hpp
  
  Index: Channel.hpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "SOAP" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  #if !defined(_AXIS_CHANNEL_HPP)
  #define _AXIS_CHANNEL_HPP
  
  #include <string>
  
  
  // platform specific stuff
  
  #ifdef WIN32
  
  #include <winsock2.h>
  
  // what version of WinSock is required
  const int	WS_VERSION_REQD	= 0x0101;
  
  // macros to get version major & minor
  inline WS_VERSION_MAJOR() {return HIBYTE(WS_VERSION_REQD);}
  inline WS_VERSION_MINOR() {return LOBYTE(WS_VERSION_REQD);}
  
  
  #else
  
  #include	<unistd.h>
  #include	<sys/types.h>	// basic system data types 
  #include	<sys/socket.h>	// basic socket definitions
  #include	<fcntl.h>		// for nonblocking if need
  #include	<netdb.h>
  #include 	<netinet/in.h>
  #include	<arpa/inet.h>	// inet(3) functions
  
  const unsigned int INVALID_SOCKET =  0;
  const int		   SOCKET_ERROR   = -1;
  
  // Other OS specific stuff goes here
  
  
  
  #endif
  
  
  /**
   *
   * Implements primitive socket exceptions that should be handle by the transport
   * that the SOAP message is carring
   *	
   * @brief     The primitive socket exception for tranport layer to handle.
   *
   */
  
  class ChannelException
  {
  	public:
  		/// Create with a possible cause of the exception
  		ChannelException(std::string p_Err){m_Error = p_Err;}
  		~ChannelException(){}
  
  		/// Return the cause of exception
  		const std::string& GetErr(){return m_Error;}
  
  	private:
  
  		std::string m_Error;  ///< cause of exception 
  };
  
  
  
  
  class Transport;
  
  /**
   * 
   * Implements primitive socket connection for all platforms, for sending/receiving
   * SOAP Envelops with given transport; This implementation abstract the low-level
   * communications.
   *	
   * @brief     The primitive socket implementation for SOAP Envelops passing.
   *
   */
  
  class Channel  
  {
  public:
  	Channel();
  	~Channel();
  
  	/// Open a socket to a given remote node/server address with remote port
  	bool  Open(std::string& p_RemoteNode, unsigned short p_RemoteEnd) throw (ChannelException);
  
  	/// Close all open sockets and clean up
  	void  Close(){CloseChannel();}
  
  	/// Read from a open socket and store read message in msg
  	const Channel& operator >> (std::string& msg);
  	
  	/// Write a given message (msg) to the end-point using the open socket
  	const Channel& operator << (const std::string& msg);
  	
  	/// Return last error (if any).
  	const std::string& GetLastError(){return m_LastErr;}
  
  	/// Set the SOAP transport handler.
  	void SetTransportHandler(Transport* transport){m_pTransportHandler = transport;}
  
  private:
  	/// OS specific initilization
  	bool Init();
  
  	/// Report error on read/write
  	void Error(const char * err);
  
  	/// Close & clean-up the open socket/system resources
  	void CloseChannel();
  
  	unsigned int	m_Sock;				///< Socket descriptor
  	std::string		m_RemoteNode;		///< Remote address could be IP/host-name
  	unsigned short	m_RemoteEnd;		///< Remote port number
  	std::string		m_LastErr;			///< Last error as a string 
  
  	Transport	* m_pTransportHandler;	///< Transport handler for validation purpose
  };
  
  
  
  
  #endif // _AXIS_CHANNEL_HPP
  
  
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/HttpTransport.cpp
  
  Index: HttpTransport.cpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
   
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  
  #include "Platform.hpp"
  #include "HttpTransport.hpp"
  #include <iostream>
  #include "../../../common/AxisException.h"
  
  using namespace std;
  
  /**
   *	Shutdown any established channel
   */
  
  HttpTransport::~HttpTransport()
  {
  	m_Channel.Close();
  }
  
  /**
   *	Initialize HTTP transport by establishing a channel to the remote end.
   *
   *	@return		Status of the channel establishment to the remote end provided by m_Url
   *  @trows		Channel Exception
   */
  
  bool HttpTransport::Init()
  {
  	// open a channel for transport
  	try
  	{
  		m_bStatus = true;
  		std::string host = m_Url.GetHostName();
  		m_Channel.Open(host, m_Url.GetPort());
  		m_Channel.SetTransportHandler(this);
          cout << "Transport:init() successfull" << endl;
  	}
  	catch(ChannelException& chEx)
  	{
  		std::cerr << chEx.GetErr() << std::endl;
  		throw;
  	}
  	return true;
  }
  
  
  /**
   *	Set properties of HTTP transport such as additional Header fields like SOAPAction.
   *
   *	@param	p_Property	Property name;  such as SOAPAction
   *	@param	p_Value		Property value
   */
  
  void  HttpTransport::SetProperty(const std::string& p_Property, const std::string& p_Value)
  {
  	m_AdditionalHeader.push_back(std::make_pair(p_Property, p_Value));
  }
  
  
  /**
   *	Read from a HTTP transport handler and store read payload.
   *
   *	@param	p_Payload	SOAP Envelop as Payload for HTTP transport
   *
   */
  
  const Transport& HttpTransport::operator >> (std::string& p_Payload)
  {
  	if(!m_bStatus) 
  	{
  		// We have the payload; this is due to Fault request made in earlier call 
  		// to this method
  		p_Payload = m_PayLoad;
  		return *this;
  	}
  
  	std::string tmpPacket;	// use temporary, need to workout for this
  	m_Channel >> tmpPacket;
      
  #ifdef _DEBUG
  	std::cout << "\n\n\nGot the message:\r\n\r\n" << tmpPacket << "\n\n";
  #endif
  	
  	// Validate the HTTP packet
  	if(!m_bStatus) HTTPValidate(tmpPacket);
  
  	// At this point we have the payload at hand so give it out
  	p_Payload = m_PayLoad;
  	return *this;
  }
  
  
  /**
   *	Write a given payload to the established channel by using HTTP transport as carrier.
   *
   */
  
  const Transport& HttpTransport::operator << (const std::string& p_Payload)
  {
  	HTTPBind(p_Payload);	// Bind the SOAP-Envelop with HTTP headers
  
  #ifdef _DEBUG
  	std::cout << "\n\n\n";
  	std::cout << m_OutMsg.str() << std::endl;
  #endif
  
  	// Write to the established channel
  	m_Channel << m_OutMsg.str();
  	return *this;
  }
  
  
  /**
   *	Build a HTTP packet with a given payload & additional HTTP properties
   *  Uses HTTP 1.1; if HTTP 1.0 is required we have to manage with setting 
   *	the properties. Only POST is supported for the time being; hope to
   *	support M-POST
   *
   */
  
  void HttpTransport::HTTPBind(const std::string& p_Payload)
  {
      m_OutMsg = "";
  	if(m_Typ == POST)				// only POST is supported for now, wish-list: M-POST??
  		m_OutMsg << "POST ";
  
  	// Use HTTP 1.1; if HTTP 1.0 is required we have to manage with setting the properties
  	m_OutMsg << m_Url.GetResource() << " HTTP/1.1\r\n"; // no support for proxy server yet
  	m_OutMsg << "Host: " << m_Url.GetHostName();
  
  	unsigned short port = m_Url.GetPort();
  
  	if(port != HTTP_PORT)
  		m_OutMsg << ":" << port;
  
  	m_OutMsg << "\r\n";
  	m_OutMsg << "Content-Type: text/xml; charset=\"UTF-8\"\r\n";	// We have to support other charsets
  	m_OutMsg << "Content-Length: " << p_Payload.size() << "\r\n";
  	
  	//Set header values for additional prefixes, such as SOAPAction
  	for(int i=0; i < m_AdditionalHeader.size(); i++)
  		m_OutMsg << m_AdditionalHeader[i].first << ": \"" 
  		         << m_AdditionalHeader[i].second << "\"\r\n";
  
  	m_OutMsg << "\r\n";
  	m_OutMsg << p_Payload;
  }
  
  
  /**
   *	Obtain the status of the HTTP packet validity.
   *
   *	@param	p_HttpPacket	HTTP packet
   *
   *	@return					Status of the HTTP packet validity.
   */
  
  bool HttpTransport::GetStatus(const std::string& p_HttpPacket)
  {
  	HTTPValidate(p_HttpPacket);
  	return m_bStatus;
  }
  
  
  /**
   *	Validate HTTP packets received from the channel.
   *
   *	@param	p_HttpPacket	HTTP packet
   *	
   *	@return					Status code is set
   */
  
  void HttpTransport::HTTPValidate(const std::string& p_HttpPacket)
  {
  	// for the time being just get the payload. Here we need much work
  
  	m_bStatus = true;
  	std::string::size_type pos = p_HttpPacket.find('\n'), nxtpos;
  
  	int nHttpSatus;
  
  	if(pos == std::string::npos) return; //unexpected string
  
  	std::string strLine = p_HttpPacket.substr(0, pos + 1);
  	std::string::size_type offset = pos + 1;
  
  	// Check for HTTP header validity; HTTP 1.0 / HTTP 1.0 is supported.
  	if((pos = strLine.find("HTTP/1.0")) != std::string::npos
  		|| (pos = strLine.find("HTTP/1.1")) != std::string::npos)
  	{
  		if(((pos = strLine.find_first_of("\" ", pos + strlen("HTTP/1.x"))) 
  			!= std::string::npos) &&
  			(nxtpos = strLine.find_first_of("\" ", pos)) != std::string::npos)
  		{
  			pos++;
  			// Get the HTTP status code of the packet obtained
  			nHttpSatus = atoi(strLine.substr(pos, nxtpos - pos).c_str())/100;
  		}
  		else
  			return;
  
  
  		// Status code is 2xx; so valid packet. hence go ahead and extract the payload.
  		if(nHttpSatus == 2)
  		{
  			GetPayLoad(p_HttpPacket, offset);
  		}
  		else if(nHttpSatus == 3)	// Status code is 3xx; some error has occurred
  		{
  			// error recovery mechanism should go here
  			Error(p_HttpPacket.c_str());
  			throw ChannelException("HTTP Error, cannot process response message...");
  		}
  		else if(nHttpSatus == 4)	// Status code is 4xx; some error has occurred
  		{
  			// error recovery mechanism should go here
  			Error(p_HttpPacket.c_str());
  			throw ChannelException("HTTP Error, cannot process response message...");
  		}
  		else if(nHttpSatus == 5)	// Status code is 5xx; some error has occurred
  		{
  			// error recovery mechanism should go here
  			GetPayLoad(p_HttpPacket, offset);
  			if (!m_bStatus) 
  			{
  				Error(p_HttpPacket.c_str());
  				throw AxisException(HTTP_ERROR);
  			}
  		}
  	}
  	else
  		throw ChannelException("Unknow HTTP response, cannot process response message...");
  
  }
  
  
  /**
   *	Extract payload from the HTTP packet starting from a given offset
   *
   */
  
  void HttpTransport::GetPayLoad(const std::string& p_HttpPacket, std::string::size_type& offset)
  {
  	std::string::size_type pos, nxtpos;
  	std::string strLine;
  	int len=0;
  
  	// process rest of the HTTP packet
  	while (true)
  	{
  		if((nxtpos = p_HttpPacket.find('\n', offset)) == std::string::npos) return;
  		nxtpos++;
  		strLine = p_HttpPacket.substr(offset, nxtpos - offset);
  		offset = nxtpos;
  
  		if((strLine == "\r\n") || (strLine == "\n") || strLine.size() <= 1)
  			break;
  
  		// Get the payload size from the header.
  		if((pos = strLine.find("Content-Length:")) != std::string::npos) 
  			len = atoi(strLine.substr(pos + strlen("Content-Length: ")).c_str());
  	}
  
  	m_PayLoad = p_HttpPacket.substr(offset);
  
  	pos = m_PayLoad.rfind('0');
  
  	if(std::string::npos != pos && m_PayLoad[pos+1] != '\"')
  	{
  		//nxtpos = m_PayLoad.find("1df");
  		//if(std::string::npos != nxtpos && '\n' == m_PayLoad[nxtpos+4])
  		{
  			m_bStatus = false; // we have the payload
  			// Extract the SOAP message
  			m_PayLoad = m_PayLoad.substr(m_PayLoad.find('<'));
  			m_PayLoad = m_PayLoad.substr(0, m_PayLoad.rfind('>') + 1);
  		}
  	}
  
  #ifdef _DEBUG
  	std::cout << "Payload:\n" << m_PayLoad << std::endl;
  #endif
  
  }
  
  
  /**
   *	Report error on read/write
   *
   */
  
  void HttpTransport::Error(const char * err)
  {
  #ifdef _DEBUG
  	std::cerr << err << std::endl;
  #endif
  }
  
  void HttpTransport::ClearAdditionalHeaders()
  {
      m_AdditionalHeader.clear();
  }
  
  
  1.1                  ws-axis/c/src/client/transport/axis/HttpTransport.hpp
  
  Index: HttpTransport.hpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "SOAP" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  
  #if !defined(_AXIS_HTTPTRANSPORT_HPP)
  #define _AXIS_HTTPTRANSPORT_HPP
  
  #include <sstream>
  #include <vector>
  #include "Transport.hpp"
  
  
  /**
   * 
   * Implements HTTP transport as SOAP-Envelop carrier, for sending/receiving
   * SOAP messages with HTTP 1.1/1.0; This implementation abstract the Transport layer for the
   * SOAP payloads
   *	
   * @brief     The HTTP transport implementation for SOAP 
   *
   */
  
  
  
  class HttpTransport  : public Transport
  {
  public:
  	/// HTTP category, Only POST is used currently, MPOST is not supported yet
  	enum Type{POST, MPOST};
  
  	/// Create HTTP transport with provided URL as remote address, set HTTP category default to POST
  	HttpTransport(Url url) : m_Typ(POST) {m_Url = url;}
  
  	/// Create HTTP transport with provided remote address as URL-string, set HTTP category default to POST
  	HttpTransport(std::string& strUrl) : m_Typ(POST) {m_Url = Url(strUrl); m_strUrl = strUrl;}
  	~HttpTransport();
  
  	/// Initialize HTTP transport by establishing a channel to the remote end.
  	bool  Init();
  
  	/// Obtain the status of the HTTP packet validity
  	bool  GetStatus(const std::string& p_HttpPacket);
  
  	/// Set properties of HTTP transport such as additional Header fields like SOAPAction.
  	void  SetProperty(const std::string& p_Property, const std::string& p_Value);
  
  	/// Read from a HTTP transport handler and store read payload
  	const Transport& operator >> (std::string& p_Payload);
  
  	/// Write a given payload by using HTTP transport as carrier
  	const Transport& operator << (const std::string& p_Payload);
  
  private:
  	/// Build a HTTP packet with a given payload & additional HTTP properties
  	void HTTPBind(const std::string& p_Payload);
  
  	/// Validate HTTP packets received from the channel.
  	void HTTPValidate(const std::string& p_HttpPacket);
  
  	/// Extract payload from the HTTP packet starting from a given offset
  	void GetPayLoad(const std::string& p_HttpPacket, std::string::size_type& offset);
  
  	/// Report error on read/write
  	void Error(const char * err);
  
      void ClearAdditionalHeaders();
  
  private:
  
  	typedef std::vector< std::pair<std::string, std::string> > Header_t;
  
  	Type m_Typ;						///< Type of the HTTP; POST or MPOST
  
  	std::ostringstream m_OutMsg;	///< Holds	outgoing HTTP packet
  	std::istringstream m_InMsg;		///< Holds	incoming HTTP packet
  
  	std::string m_PayLoad;			///< Holds the payload
  	Header_t	m_AdditionalHeader; ///< Additional Header fields as name value pairs
  
  };
  
  #endif //_AXIS_HTTPTRANSPORT_HPP
  
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  noinst_LTLIBRARIES = libtransport.la
  AM_CPPFLAGS = -Wshadow -Wall -pedantic -ansi
  libtransport_la_SOURCES = Channel.cpp HttpTransport.cpp Receiver.cpp Sender.cpp \
  	Transport.cpp TransportFactory.cpp Url.cpp TransporterInterface.cpp
  
  libtransport_la_LIBADD = -lstdc++
  INCLUDES =
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/Platform.hpp
  
  Index: Platform.hpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "SOAP" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   * @author Lilantha Darshana (lilantha@erunway.com)
   *
   */
  
  
  #if !defined(_AXIS_STDAFX_H)
  #define _AXIS_STDAFX_H
  
  
  #ifdef WIN32
  
  #if _MSC_VER > 1000
  #pragma once
  #endif // _MSC_VER > 1000
  
  #define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
  
  #pragma warning ( disable : 4786 )
  
  
  //#include <afx.h>
  //#include <afxwin.h>
  
  #ifdef AXIS_EXPORTS
  #define AXIS_API __declspec(dllexport)
  #else
  #define AXIS_API __declspec(dllimport)
  #endif
  
  
  #else // WIN32
  
  #define AXIS_API
  #include <unistd.h>
  // other OS specific stuff goes here
  
  #endif
  
  #if defined(_DEBUG)
  #	include <iostream>
  #	define DebugMsg(x)	std::cout << x <<std::endl;
  #else
  #	define DebugMsg(x)
  #endif
  
  #endif // _AXIS_STDAFX_H
  
  
  
  
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/Receiver.cpp
  
  Index: Receiver.cpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  #include "Platform.hpp"
  #include "Receiver.hpp"
  #include "Transport.hpp"
  #include <iostream>
  
  
  Receiver::~Receiver()
  {
  
  }
  
  const std::string& Receiver::Recv() throw (AxisException)
  {
  	try
  	{
  		*m_pTrChannel >> repMsg;
  	}
  	catch(AxisException& ex)
  	{
  		// Get the fault message.
  		*m_pTrChannel >> repMsg;
  		#ifdef _DEBUG
  			std::cerr << ex.GetErrorMsg() << std::endl;
  		#endif
  	}
  	catch(...)
  	{
  		throw AxisException(RECEPTION_ERROR);
  	}
  
  	return repMsg;
  }
  
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/Receiver.hpp
  
  Index: Receiver.hpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "SOAP" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  
  #if !defined(_AXIS_RECEIVER_HPP)
  #define _AXIS_RECEIVER_HPP
  
  #include "../../../common/AxisException.h"
  
  class Transport;
  
  
  class Receiver  
  {
  public:
  	Receiver(Transport *pTr) : repMsg(""), m_pTrChannel(pTr){}
  	~Receiver();
  
  	const std::string& Recv() throw (AxisException);
  
  private:
  	std::string repMsg;
  
  	Transport *m_pTrChannel;
  
  	unsigned int m_RecvPort;
  };
  
  #endif // _AXIS_RECEIVER_HPP
  
  
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/Sender.cpp
  
  Index: Sender.cpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  #include "Platform.hpp"
  #include "Sender.hpp"
  #include "Transport.hpp"
  
  
  
  Sender::Sender(Transport *pTr)
  	: m_pTrChannel(pTr)
  {
  
  }
  
  Sender::~Sender()
  {
  
  }
  
  void Sender::ClearAdditionalHeaders()
  {
      m_pTrChannel->ClearAdditionalHeaders();
  }
  
  bool Sender::Send(const std::string& what) throw (AxisException)
  {
  	try
  	{
  		m_pTrChannel->Init();
  
  		*m_pTrChannel << what;
  	}
  	catch(...)
  	{
  		throw AxisException(SENDING_ERROR);
  	}
  
  	return true;
  }
  
  
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/Sender.hpp
  
  Index: Sender.hpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "SOAP" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  
  #if !defined(_AXIS_SENDER_HPP)
  #define _AXIS_SENDER_HPP
  
  #include "../../../common/AxisException.h"
  
  class Transport;
  
  class Sender  
  {
  	public:
  		Sender(Transport *pTr);
  		~Sender();
  	
  		bool Send(const std::string& what) throw (AxisException);
          void ClearAdditionalHeaders();
  
  	private:
  		Transport	*m_pTrChannel;
  };
  
  #endif // _AXIS_SENDER_HPP
  
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/Transport.cpp
  
  Index: Transport.cpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  #include "Platform.hpp"
  #include "Transport.hpp"
  
  
  
  Transport::Transport()
  {
  
  }
  
  Transport::~Transport()
  {
  
  }
  
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/Transport.hpp
  
  Index: Transport.hpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "SOAP" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  
  
  #if !defined(_AXIS_TRANSPORT_HPP)
  #define _AXIS_TRANSPORT_HPP
  
  #include "Url.hpp"
  #include "Channel.hpp"
  	
  /**
   * 
   *	Implements Transport as SOAP-Envelop carrier, for sending/receiving
   *	SOAP Envelops with any protocol; This implementation abstract the 
   *	Transport layer for the SOAP payloads
   *	
   *	@brief     The Transport interface for SOAP envelop carrier 
   *
   */
  
  class Transport  
  {
  public:
  	Transport();
  	virtual ~Transport();
  
  	virtual bool Init() { return false;}	  // Initialize transport channel
  	virtual bool GetStatus(const std::string& payload){return m_bStatus;}
  	virtual void SetProperty(const std::string& p_Property, const std::string& p_Value){}
  
  
  	virtual const Transport& operator >> (std::string& msg){return *this;}
  	virtual const Transport& operator << (const std::string& msg){return *this;}
  
  
  protected:
  
  	Url m_Url;
  	std::string m_strUrl;           
  	Channel m_Channel;
  
  	bool m_bStatus;
  
  };
  
  #endif // _AXIS_TRANSPORT_HPP
  
  
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/TransportFactory.cpp
  
  Index: TransportFactory.cpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  
  #include "Platform.hpp"
  #include "TransportFactory.hpp"
  #include "HttpTransport.hpp"
  
  
  
  TransportFactory::TransportFactory()
  {
  
  }
  
  TransportFactory::~TransportFactory()
  {
  
  }
  
  Transport* TransportFactory::GetTransport(Url& url)
  {
  	if(url.GetProtocol() == Url::http)
  	{
  		return new HttpTransport(url);
  	}
  	else if(url.GetProtocol() == Url::https)
  	{
  		return NULL; // currently not supported
  	}
  	else if(url.GetProtocol() == Url::ftp)
  	{
  		return NULL; // currently not supported
  	}
  	else
  		return NULL; // currently not supported
  }
  
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/TransportFactory.hpp
  
  Index: TransportFactory.hpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "SOAP" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  
  #if !defined(_AXIS_TRANSPORTFACTORY_HPP)
  #define _AXIS_TRANSPORTFACTORY_HPP
  
  #include "Url.hpp"
  
  class Transport;
  
  
  /**
   *	Create undeline transport for SOAP-Envelops carrier for a given URL
   *	URL determine which transport to be instantiated for carring SOAP
   *	Envelop.
   *
   *	@todo	Hope this require of creating Transport by specifing a property
   *			such as name; not just the URL.
   *	@brief  The Transport Factory to instantiate a Tranport for SOAP envelop carring
   *
   */
  
  
  
  class TransportFactory  
  {
  public:
  	TransportFactory();
  	virtual ~TransportFactory()=0;
  
  	static Transport* GetTransport(Url& url); // return transport object according to URL info
  };
  
  #endif // _AXIS_TRANSPORTFACTORY_HPP
  
  
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/Url.cpp
  
  Index: Url.cpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  
  #include "Platform.hpp"
  #include "Url.hpp"
  #include <ctype.h>
  #include <iostream>
  using namespace std;
  
  
  Url::Url()
  	: m_Protocol(unknown), m_Port(0)
  {
     //cout << "inside Url constructor" << endl; 
  }
  
  Url::Url(std::string url)
  {
  	m_URL = url;
  	if(isascii((int)url.at(0)))
  	{
  		// check this a valid URL
  		if((url.at(1) == (int)':') &&
  			((url.at(2) == (int)'/') || (url.at(2) == (int)'\\')))
  			return;
  		else // assume valid URL hence, proceed with finding entries
  			ParseURL(url);
  	}
  }
  
  Url::~Url()
  {
  
  }
  
  void Url::SetProtocol(std::string prot)
  {
  	m_Port = 0;
  	if(prot == "http")
  	{
  		m_Protocol = http;
  		m_Port = HTTP_PORT;
  	}
  	else if( prot == "file")
  	{
  		m_Protocol = file;
  	}
  	else if( prot == "ftp")
  	{
  		m_Protocol = ftp;
  		m_Port = FTP_PORT;
  	}
  	else if( prot == "https")
  	{
  
  		m_Protocol = https;
  		m_Port = HTTPS_PORT;
  	}
  	else
  		m_Protocol = unknown;
  
  }
  
  void Url::ParseURL(std::string& url)
  {
  	std::string::size_type begpos, pos;
  
  	// try to find out the protocol
  	if((pos = url.find("://")) != std::string::npos)
  	{
  		SetProtocol(url.substr(0, pos));
  		// find m_Host name
  		if(m_Protocol != unknown)
  		{
  			url = url.substr(pos + 3); // rest of the URL string
  			begpos = pos = 0;
  			std::string key(":/?");
  			
  			while(pos = url.find_first_of(key, begpos))
  			{
  				if(pos == std::string::npos) // only host name found
  				{
  					if(m_Host.empty())
  						m_Host = url;
  					if (key == "?") // found path
  						m_Path = url.substr(begpos - 1);
  					break;
  				}
  				else
  					if(pos == 0) break;
  
  				switch(url.at(pos))
  				{
  					case ':': 
  						if(m_Host.empty())
  							m_Host = url.substr(begpos, pos - begpos);
  						pos++;
  						begpos = pos;
  						key = "/?"; // scan for the rest to get the path & query
  						continue;
  
  					case '/':
  						if (key == "/?") // found port number
  						{
  							m_Port = atoi(url.substr(begpos, pos - begpos + 1).c_str());
  							if(m_Host.empty())
  								m_Host = url.substr(0, begpos - 1);
  						}
  						else
  							m_Host = url.substr(0, pos);
  						pos++;
  						begpos = pos;
  						key = "?";
  						continue;
  
  					case '?':
  						// not correctly supported
  						m_Query = url.substr(pos);
  						break;
  				}	
  				break;
  			}							
  		}
  	}
  }
  
  
  
   
  					
  
  					
  
  
  
  
  
  1.1                  ws-axis/c/src/client/transport/axis/Url.hpp
  
  Index: Url.hpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "SOAP" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  
  #if !defined(_AXIS_URL_HPP)
  #define _AXIS_URL_HPP
  
  #include <string>
  
  // Welknown ports
  const unsigned short HTTP_PORT  = 80;	
  const unsigned short HTTPS_PORT = 443;
  const unsigned short FTP_PORT   = 21;
  
  
  /**
   *	Implementation of URL to manupulate URLs.  
   *
   *	This implementation only supports subset of a URL
   *	note that # references, userinfo query string 
   *	processing are not supported for this version.
   *
   *	URLs are of the form:
   * 
   *	URL			  = protocol "://" server "/" [path]["?" query]
   *	server        = [userinfo "@"] hostname-port
   *	hostname-port = hostname [ ":" port ]
   *	userinfo	  = user[:password]
   *
   *
   *	@brief	Manupulate URLs
   */
  
  
  class Url  
  {
  public:
  
  	enum Protocol { http, https, ftp, file, unknown}; // for our purpose currently we need
  													  // http, https only. This is provided
  													  // To make extensible to
  													  // support other transports for RPC
  													  // but file????, yes we may require 
  													  // pipes; with web-service????
  
  public:
  	Url();
  	Url(std::string url);
  	~Url();
  
  	void SetProtocol(std::string prot);
  	void SetProtocol(Protocol prot){m_Protocol = prot;}
  	void SetHostName(std::string host){m_Host= host;}
  	void SetResource(std::string path){m_Path = path;}
  	void SetPort(unsigned short port){m_Port = port;}
  
  	Protocol	GetProtocol(){return m_Protocol;}
  	std::string GetHostName(){return m_Host;}
  	std::string GetResource(){return m_Path;}
  
  	unsigned short GetPort(){return m_Port;}
  
  	// other functions are not supported yet
  
  private:
  
  	void ParseURL(std::string& url);
  	
  	Protocol		m_Protocol;
  	std::string		m_Host;
  	unsigned short  m_Port;
  	std::string		m_Path;
  	std::string		m_Query;
  
      std::string m_Password;
      std::string m_User;
      std::string m_URL;
  };
  
  #endif // _AXIS_URL_HPP