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 ro...@apache.org on 2005/01/07 09:55:19 UTC

cvs commit: ws-axis/c/src/soap SoapAttachementHeaders.cpp SoapAttachementHeaders.hpp SoapAttachment.cpp SoapAttachment.hpp SoapSerializer.cpp SoapSerializer.h

roshan      2005/01/07 00:55:19

  Modified:    c/include/axis IWrapperSoapSerializer.hpp
               c/src/soap SoapAttachementHeaders.cpp
                        SoapAttachementHeaders.hpp SoapAttachment.cpp
                        SoapAttachment.hpp SoapSerializer.cpp
                        SoapSerializer.h
  Added:       c/include/axis ISoapAttachment.hpp
  Log:
  added the virtual interface to the SoapAttachment and added the logic to support the concept
  
  Revision  Changes    Path
  1.3       +18 -0     ws-axis/c/include/axis/IWrapperSoapSerializer.hpp
  
  Index: IWrapperSoapSerializer.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/include/axis/IWrapperSoapSerializer.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IWrapperSoapSerializer.hpp	4 Jan 2005 05:50:00 -0000	1.2
  +++ IWrapperSoapSerializer.hpp	7 Jan 2005 08:55:19 -0000	1.3
  @@ -20,6 +20,7 @@
   #include "AxisUserAPI.hpp"
   #include "TypeMapping.hpp"
   #include "WSDDDefines.hpp"
  +#include "ISoapAttachment.hpp"
   
   /*
    *  @class IWrapperSoapSerializer
  @@ -37,6 +38,11 @@
    * Added addAttachmentHeader
    */
   
  +/*
  + * Revision 1.2  2005/01/07 Roshan
  + * Added addAttachment
  + */
  +
   AXIS_CPP_NAMESPACE_START
   
   class IWrapperSoapSerializer
  @@ -127,9 +133,21 @@
   
       virtual int serializeAsChardata(void* pValue, XSDTYPE type)=0;
   
  +    virtual void addAttachment(const AxisChar* achId, ISoapAttachment* objAttach)=0;
  +
   	virtual void addAttachmentBody(const AxisChar* achId, xsd__base64Binary* pAttchBody)=0;
   
   	virtual void addAttachmentHeader(const AxisChar* achId, const AxisChar* achHeaderName, const AxisChar* achHeaderValue)=0;
  +
  +	/**
  +    * creates and returns a SoapAttachment object to the caller of this methods.
  +	*  The user can use this object and fill in the attachment details. This
  +	*  method doesn't add the created SoapAttachment object to the Serializer.
  +	*  The user will have to add this object explictly by calling the addAttachment 
  +	*  method of the IWrapperSoapSerializer interface
  +    *     
  +    */
  +	virtual ISoapAttachment* createSoapAttachement()=0;
   };
   
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.1                  ws-axis/c/include/axis/ISoapAttachment.hpp
  
  Index: ISoapAttachment.hpp
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
  /*
   * @author Nithyakala Thangarajah (nithya@opensource.lk)
   * @author Rangika Mendis (rangika@opensource.lk) 
   * @author Roshan Weerasuriya (roshan@opensource.lk, roshan@jkcsworld.com)
   *
   */
  
  // ISoapAttachment.h: interface for the ISoapAttachment class.
  //
  //////////////////////////////////////////////////////////////////////
  
  #if !defined(AFX_ISOAPATTACHMENT_H__8B3A65FD_40A6_45B2_A8C5_295DE4222952__INCLUDED_)
  #define AFX_ISOAPATTACHMENT_H__8B3A65FD_40A6_45B2_A8C5_295DE4222952__INCLUDED_
  
  #if _MSC_VER > 1000
  #pragma once
  #endif // _MSC_VER > 1000
  
  #include <axis/AxisUserAPI.hpp>
  
  AXIS_CPP_NAMESPACE_START
  
  class ISoapAttachment  
  {
  public:
  
  	/**
  	  * Allows the user to add the Attachment Body
  	  */
  	virtual void addBody(xsd__base64Binary* objBody)=0;	
  
  	/**
  	  * Allows the user to add the Attachment Headers
  	  */
  	virtual void addHeader(const char* pchName, const char* pchValue)=0;
  
  	/**
  	  * Allows the user to get the Attachment Body
  	  */
  	virtual xsd__base64Binary* getBody()=0;	
  
  	/**
  	  * Allows the user to get the required Attachment Header
  	  *
  	  * @param pchName The name of the required Attachement Header
  	  */
  	virtual const char* getHeader(const char* pchName)=0;
  
  	virtual ~ISoapAttachment() {};
  
  };
  
  AXIS_CPP_NAMESPACE_END
  
  #endif // !defined(AFX_ISOAPATTACHMENT_H__8B3A65FD_40A6_45B2_A8C5_295DE4222952__INCLUDED_)
  
  
  
  1.2       +8 -0      ws-axis/c/src/soap/SoapAttachementHeaders.cpp
  
  Index: SoapAttachementHeaders.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapAttachementHeaders.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SoapAttachementHeaders.cpp	4 Jan 2005 05:50:00 -0000	1.1
  +++ SoapAttachementHeaders.cpp	7 Jan 2005 08:55:19 -0000	1.2
  @@ -63,4 +63,12 @@
       }
   }
   
  +AxisString SoapAttachementHeaders::getHeader(AxisString sName)
  +{
  +	if (m_AttachHeaders.find(sName) == m_AttachHeaders.end())
  +		return "";
  +	else
  +		return m_AttachHeaders[sName];
  +}
  +
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.2       +1 -0      ws-axis/c/src/soap/SoapAttachementHeaders.hpp
  
  Index: SoapAttachementHeaders.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapAttachementHeaders.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SoapAttachementHeaders.hpp	4 Jan 2005 05:50:00 -0000	1.1
  +++ SoapAttachementHeaders.hpp	7 Jan 2005 08:55:19 -0000	1.2
  @@ -48,6 +48,7 @@
   private:
   	map<AxisString, AxisString> m_AttachHeaders;
   public:
  +	AxisString getHeader(AxisString sName);
   	
   	void serialize(SoapSerializer& pSZ);
   	void addHeader(AxisString name, AxisString value);
  
  
  
  1.2       +22 -3     ws-axis/c/src/soap/SoapAttachment.cpp
  
  Index: SoapAttachment.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapAttachment.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SoapAttachment.cpp	4 Jan 2005 05:50:00 -0000	1.1
  +++ SoapAttachment.cpp	7 Jan 2005 08:55:19 -0000	1.2
  @@ -36,18 +36,24 @@
   
   SoapAttachment::SoapAttachment()
   {	
  +	m_AttachementHeaders = new SoapAttachementHeaders();
  +
   	//Assigning to NULL
   	m_AttachementBody = 0;
   }
   
   SoapAttachment::~SoapAttachment()
   {
  +	delete m_AttachementHeaders;
  +	m_AttachementHeaders =0;
   
  +	delete m_AttachementBody;
  +	m_AttachementBody =0;
   }
   
  -void SoapAttachment::addHeader(AxisString name, AxisString value)
  +void SoapAttachment::addHeader(const char* pchName, const char* pchValue)
   {
  -	m_AttachementHeaders.addHeader(name, value);
  +	m_AttachementHeaders->addHeader(pchName, pchValue);
   }
   
   /*
  @@ -66,7 +72,7 @@
   {
   	/* Serialize the Attachment Headers */
   	pSZ.serialize("\n", NULL);
  -	m_AttachementHeaders.serialize(pSZ);
  +	m_AttachementHeaders->serialize(pSZ);
   
   	/* Serialize the Attachment Body */
   	//pSZ.serialize("\n", m_AttachementBody.c_str(), NULL);
  @@ -77,6 +83,19 @@
   	}
   
   	pSZ.serialize("\n", NULL);
  +}
  +
  +xsd__base64Binary* SoapAttachment::getBody()
  +{
  +	return m_AttachementBody;
  +}
  +
  +const char* SoapAttachment::getHeader(const char *pchName)
  +{
  +	if (m_AttachementHeaders->getHeader(pchName).empty())
  +		return "";
  +	else
  +		return m_AttachementHeaders->getHeader(pchName).c_str();
   }
   
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.2       +6 -3      ws-axis/c/src/soap/SoapAttachment.hpp
  
  Index: SoapAttachment.hpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapAttachment.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SoapAttachment.hpp	4 Jan 2005 05:50:00 -0000	1.1
  +++ SoapAttachment.hpp	7 Jan 2005 08:55:19 -0000	1.2
  @@ -35,6 +35,7 @@
   
   #include <axis/GDefine.hpp>
   #include <axis/AxisUserAPI.hpp>
  +#include <axis/ISoapAttachment.hpp>
   #include "SoapAttachementHeaders.hpp"
   
   #include <string>
  @@ -44,16 +45,18 @@
   
   class SoapSerializer;
   
  -class SoapAttachment
  +class SoapAttachment : public ISoapAttachment
   {
   private:
  -	SoapAttachementHeaders m_AttachementHeaders;
  +	SoapAttachementHeaders* m_AttachementHeaders;
   	xsd__base64Binary* m_AttachementBody;
   public:
  +	const char* getHeader(const char* pchName);
  +	xsd__base64Binary* getBody();
   	
   	void serialize(SoapSerializer& pSZ);
   	void addBody(xsd__base64Binary* objBody);	
  -	void addHeader(AxisString name, AxisString value);
  +	void addHeader(const char* pchName, const char* pchValue);
   	SoapAttachment();
   	virtual ~SoapAttachment();	
   };
  
  
  
  1.83      +11 -4     ws-axis/c/src/soap/SoapSerializer.cpp
  
  Index: SoapSerializer.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapSerializer.cpp,v
  retrieving revision 1.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- SoapSerializer.cpp	6 Jan 2005 05:21:52 -0000	1.82
  +++ SoapSerializer.cpp	7 Jan 2005 08:55:19 -0000	1.83
  @@ -923,19 +923,19 @@
   {
   	/*serializing the attachements*/
   
  -	map<AxisXMLString, SoapAttachment*>::iterator itCurrAttach= m_SoapAttachments.begin();
  +	map<AxisXMLString, ISoapAttachment*>::iterator itCurrAttach= m_SoapAttachments.begin();
   
   	while(itCurrAttach != m_SoapAttachments.end())
       {        
  -        ((*itCurrAttach).second)->serialize(pSZ);
  +        ((SoapAttachment*)((*itCurrAttach).second))->serialize(pSZ);
   
           itCurrAttach++;
       }
   }
   
  -void SoapSerializer::addAttachment(AxisString id, SoapAttachment* objAttach)
  +void SoapSerializer::addAttachment(const AxisChar* achId, ISoapAttachment* pAttach)
   {
  -	m_SoapAttachments[id] = objAttach;
  +	m_SoapAttachments[achId] = pAttach;
   }
   
   void SoapSerializer::addAttachmentHeader(const AxisChar* achId, const AxisChar* achHeaderName, const AxisChar* achHeaderValue)
  @@ -971,6 +971,13 @@
   void SoapSerializer::addNamespaceToNamespaceList(const AxisChar *pachNamespaceURI, const AxisChar* pachPrefix)
   {
   	m_NsStack[pachNamespaceURI] = pachPrefix;
  +}
  +
  +ISoapAttachment* SoapSerializer::createSoapAttachement()
  +{
  +	SoapAttachment* pSAttch = new SoapAttachment();
  +
  +	return pSAttch;
   }
   
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.35      +4 -2      ws-axis/c/src/soap/SoapSerializer.h
  
  Index: SoapSerializer.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapSerializer.h,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- SoapSerializer.h	6 Jan 2005 05:21:52 -0000	1.34
  +++ SoapSerializer.h	7 Jan 2005 08:55:19 -0000	1.35
  @@ -34,6 +34,7 @@
   class HeaderBlock;
   class IArrayBean;
   class Attribute;
  +class ISoapAttachment;
   
   /**
    *  @class SoapSerializer
  @@ -48,7 +49,7 @@
   class SoapSerializer : public IHandlerSoapSerializer
   {
   private:
  -	map<AxisString, SoapAttachment*> m_SoapAttachments;
  +	map<AxisString, ISoapAttachment*> m_SoapAttachments;
       int m_nCounter;
       AxisChar m_Buf[BTS_BUFFSIZE];
       SoapEnvelope* m_pSoapEnvelope;    	
  @@ -155,11 +156,12 @@
       BasicTypeSerializer m_BTSZ;
       SOAPTransport* m_pOutputStream;
   public:
  +	ISoapAttachment* createSoapAttachement();
   	void addNamespaceToNamespaceList(const AxisChar *pachNamespaceURI, const AxisChar* pachPrefix);
   	void addNamespaceToEnvelope(AxisChar *pachNamespaceURI, AxisChar* pachPrefix);
   	void addAttachmentBody(const AxisChar* achId, xsd__base64Binary* pAttchBody);
   	void addAttachmentHeader(const AxisChar* achId, const AxisChar* achHeaderName, const AxisChar* achHeaderValue);
  -	void addAttachment(AxisString id, SoapAttachment* objAttach);
  +	void addAttachment(const AxisChar* achId, ISoapAttachment* pAttach);
   	IHeaderBlock* getHeaderBlock(const AxisChar* pcName, const AxisChar* pcNamespace);
   	IHeaderBlock* getHeaderBlock();
   	IHeaderBlock* getFirstHeaderBlock();