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 wh...@apache.org on 2005/07/14 15:18:40 UTC

cvs commit: ws-axis/c/tests/auto_build/testcases/output AttDataHandlerTextRequest.out

whitlock    2005/07/14 06:18:40

  Modified:    c/src/common Param.cpp Param.h
               c/src/soap SoapAttachment.cpp SoapAttachment.hpp
                        SoapSerializer.cpp SoapSerializer.h
               c/tests/auto_build/testcases/output
                        AttDataHandlerTextRequest.out
  Added:       c/src/soap SoapAttachmentReference.cpp
                        SoapAttachmentReference.hpp
  Log:
  AXISCPP-732 Fix AttDataHandlerText. Separate out SoapAttachmentReference from SoapAttachment. For referenced attachments, this allows multiple references to point to the same attachment. This also allows client applications to reuse ISoapAttachment on multiple calls, since each call will create a separate SoapAttachmentReference.
  
  Revision  Changes    Path
  1.60      +5 -4      ws-axis/c/src/common/Param.cpp
  
  Index: Param.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/common/Param.cpp,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- Param.cpp	11 Jul 2005 05:43:51 -0000	1.59
  +++ Param.cpp	14 Jul 2005 13:18:39 -0000	1.60
  @@ -20,15 +20,16 @@
    *
    */
   
  +#include <axis/AxisUserAPI.hpp>
   #include "../engine/AxisEngine.h"
   #include "Param.h"
   #include "ArrayBean.h"
   #include "BasicTypeSerializer.h"
  -#include <stdlib.h>
  -#include <stdio.h>
   #include "AxisUtils.h"
  -#include <axis/AxisUserAPI.hpp>
   #include "AxisTrace.h"
  +#include "../soap/SoapAttachmentReference.hpp"
  +#include <stdlib.h>
  +#include <stdio.h>
   
   AXIS_CPP_NAMESPACE_START
   
  @@ -173,7 +174,7 @@
                pSZ.serializeAnyObject(m_Value.pAnyObject);
                break;
         case ATTACHMENT:
  -            m_Value.pAttachment->serializeReference(pSZ,m_sName.c_str());
  +            m_Value.pAttachmentRef->serialize(pSZ,m_sName.c_str());
               break;
         default:
               pSZ.serializeAsElement((AxisChar*) m_sName.c_str (), (IAnySimpleType*) m_AnySimpleType);
  
  
  
  1.32      +2 -2      ws-axis/c/src/common/Param.h
  
  Index: Param.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/common/Param.h,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- Param.h	16 Jun 2005 14:19:15 -0000	1.31
  +++ Param.h	14 Jul 2005 13:18:39 -0000	1.32
  @@ -29,7 +29,7 @@
   AXIS_CPP_NAMESPACE_START
   
   class ArrayBean;
  -class SoapAttachment;
  +class SoapAttachmentReference;
   
   class ParamValue
   {
  @@ -40,7 +40,7 @@
       };
       ComplexObjectHandler* pCplxObj;
       AnyType* pAnyObject; /* used to hold AnyType struct for xsd:any */
  -	SoapAttachment* pAttachment;
  +	SoapAttachmentReference* pAttachmentRef;
   };
   
   /*
  
  
  
  1.20      +1 -55     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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- SoapAttachment.cpp	30 Jun 2005 11:19:01 -0000	1.19
  +++ SoapAttachment.cpp	14 Jul 2005 13:18:39 -0000	1.20
  @@ -12,28 +12,16 @@
    *   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 Rangika Mendis (rangika@opensource.lk)
    * @author Nithyakala Thangarajah (nithya@opensource.lk)
    * @author Roshan Weerasuriya (roshan@opensource.lk, roshan@jkcsworld.com)
  - *
    */
   
  -
  -
   // SoapAttachment.cpp: implementation of the SoapAttachment class.
   
  -//
  -
  -//////////////////////////////////////////////////////////////////////
  -
  -
  -
   #include "SoapAttachment.hpp"
   #include "SoapSerializer.h"
  -#include "Attribute.h"
   
   AXIS_CPP_NAMESPACE_START
   //////////////////////////////////////////////////////////////////////
  @@ -59,14 +47,6 @@
   {
   	delete m_AttachmentHeaders;
   	m_AttachmentHeaders =0;
  -
  -	list<Attribute*>::iterator it = m_attributes.begin();
  -	while (it != m_attributes.end())
  -	{
  -		 delete (*it);
  -		it++;
  -	}
  -	m_attributes.clear();
   }
   
   void SoapAttachment::addHeader(const char* pchName, const char* pchValue)
  @@ -146,40 +126,6 @@
      return getHeader(AXIS_CONTENT_ID);
   }
   
  -void SoapAttachment::serializeReference(SoapSerializer& pSZ, const char *name)
  -{
  -	string data = "<";
  -	data += name;
  -	if (NULL==m_AttachmentBody)
  -		data += " xsi:nil=\"true\"";
  -	else
  -	{
  -		data += " href=\"cid:";
  -		data += m_AttachmentHeaders->getHeader(AXIS_CONTENT_ID);
  -		data += "\"";
  -	}
  -	pSZ.serialize(data.c_str(), NULL);
  -
  -	list<Attribute*>::iterator it = m_attributes.begin();
  -	while (it != m_attributes.end())
  -	{
  -		pSZ.serialize("\r\n  ",NULL);
  -		(*it)->serialize(pSZ);
  -		it++;
  -	}
  -	pSZ.serialize("/>\r\n",NULL);
  -}
  -
  -void SoapAttachment::addAttributes(IAttribute **attributes, int nAttributes)
  -{
  -	if (0==nAttributes || NULL==attributes) return;
  -	for (int i=0; i<nAttributes; i++)
  -		if (NULL!=attributes[i]) 
  -			m_attributes.push_back(static_cast<Attribute*>(attributes[i]));
  -
  -	return;
  -}
  -
   AXIS_CPP_NAMESPACE_END
   
   
  
  
  
  1.12      +2 -7      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SoapAttachment.hpp	20 Jun 2005 16:23:00 -0000	1.11
  +++ SoapAttachment.hpp	14 Jul 2005 13:18:39 -0000	1.12
  @@ -40,7 +40,6 @@
   #include <axis/GDefine.hpp>
   #include <axis/AxisUserAPI.hpp>
   #include <axis/ISoapAttachment.hpp>
  -#include <axis/IAttribute.hpp>
   #include "SoapAttachmentHeaders.hpp"
   #include "ContentIdSet.hpp"
   #include <string>
  @@ -54,7 +53,6 @@
   #endif
   
   class SoapSerializer;
  -class Attribute;
   
   class STORAGE_CLASS_INFO SoapAttachment : public ISoapAttachment
   {
  @@ -64,9 +62,10 @@
       char *m_binaryBody;
       int iEncodingStyle;
       ContentIdSet *m_pContentIdSet;
  -	list<Attribute*> m_attributes;
   
   public:	
  +	SoapAttachment(ContentIdSet *pContentIdSet=NULL);
  +	virtual ~SoapAttachment();	
       const char* getAttachmentId();
   	const char* getHeader(const char* pchName);
   	xsd__base64Binary* getBody();
  @@ -74,10 +73,6 @@
   	void addBody(xsd__base64Binary* objBody);
       void addBody(char* pchBinaryBody);
   	void addHeader(const char* pchName, const char* pchValue);
  -	SoapAttachment(ContentIdSet *pContentIdSet=NULL);
  -	virtual ~SoapAttachment();	
  -	void serializeReference(SoapSerializer& pSZ, const char *name);
  -	void addAttributes(IAttribute **attributes, int nAttributes);
   };
   
   AXIS_CPP_NAMESPACE_END
  
  
  
  1.136     +16 -6     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.135
  retrieving revision 1.136
  diff -u -r1.135 -r1.136
  --- SoapSerializer.cpp	13 Jul 2005 14:57:03 -0000	1.135
  +++ SoapSerializer.cpp	14 Jul 2005 13:18:39 -0000	1.136
  @@ -31,13 +31,14 @@
   #pragma warning (disable : 4786)
   #endif
   
  +#include <axis/GDefine.hpp>
   #include "SoapEnvelope.h"
   #include "SoapSerializer.h"
   #include "HeaderBlock.h"
  -#include <axis/GDefine.hpp>
   #include "../common/ArrayBean.h"
   #include "../common/BasicTypeSerializer.h"
  -#include "../soap/SoapKeywordMapping.h"
  +#include "SoapKeywordMapping.h"
  +#include "SoapAttachmentReference.hpp"
   #include "AxisSoapException.h"
   #include <stdio.h>
   #include <stdarg.h>
  @@ -68,13 +69,20 @@
   
   	/* Cleaning the memory allocated to the SoapAttachments */       
   	map<AxisXMLString, ISoapAttachment*>::iterator itCurrAttach= m_SoapAttachments.begin();
  -
   	while( itCurrAttach != m_SoapAttachments.end())
       {        
           delete( (SoapAttachment*)((*itCurrAttach).second));		
  -
           itCurrAttach++;
       }
  +	m_SoapAttachments.clear();
  +
  +	list<SoapAttachmentReference*>::iterator itAttRef= m_attachmentRefs.begin();
  +	while(itAttRef != m_attachmentRefs.end())
  +    {        
  +        delete *itAttRef;
  +        itAttRef++;
  +    }
  +	m_attachmentRefs.clear();
   }
   
   int SoapSerializer::setSoapEnvelope( SoapEnvelope * pSoapEnvelope)
  @@ -1243,13 +1251,15 @@
   {
   	if (NULL==att)
   		att = static_cast<ISoapAttachment*>(new SoapAttachment(m_pContentIdSet));
  +	SoapAttachmentReference *ref = new SoapAttachmentReference(static_cast<SoapAttachment*>(att));
  +	m_attachmentRefs.push_back(ref);
   
       Param *pParam = new Param();
  -    pParam->m_Value.pAttachment = static_cast<SoapAttachment*>(att);
  +    pParam->m_Value.pAttachmentRef = ref;
   	pParam->m_Type = ATTACHMENT;
   
   	if (NULL!=attributes && nAttributes>0) 
  -		pParam->m_Value.pAttachment->addAttributes(attributes,nAttributes);
  +		ref->addAttributes(attributes,nAttributes);
   	
   	if (m_pSoapEnvelope &&
   		(m_pSoapEnvelope->m_pSoapBody) &&
  
  
  
  1.53      +2 -0      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.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- SoapSerializer.h	20 Jun 2005 16:23:00 -0000	1.52
  +++ SoapSerializer.h	14 Jul 2005 13:18:39 -0000	1.53
  @@ -41,6 +41,7 @@
   class IArrayBean;
   class Attribute;
   class ISoapAttachment;
  +class SoapAttachmentReference;
   
   /**
    *  @class SoapSerializer
  @@ -56,6 +57,7 @@
   {
   private:
   	map<AxisString, ISoapAttachment*> m_SoapAttachments;
  +	list<SoapAttachmentReference*> m_attachmentRefs;
       int m_nCounter;
       AxisChar m_Buf[BTS_BUFFSIZE];
       SoapEnvelope* m_pSoapEnvelope;    	
  
  
  
  1.1                  ws-axis/c/src/soap/SoapAttachmentReference.cpp
  
  Index: SoapAttachmentReference.cpp
  ===================================================================
  /*
   *   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.
   */
  
  #include "SoapAttachmentReference.hpp"
  #include "SoapSerializer.h"
  #include "Attribute.h"
  
  AXIS_CPP_NAMESPACE_START
  
  SoapAttachmentReference::SoapAttachmentReference(SoapAttachment *att)
  {	
  	m_attachment = att;
  }
  
  SoapAttachmentReference::~SoapAttachmentReference() {}
  
  void SoapAttachmentReference::serialize(SoapSerializer& pSZ, const char *name)
  {
  	string data = "<";
  	data += name;
  	if (NULL==m_attachment->getBody())
  		data += " xsi:nil=\"true\"";
  	else
  	{
  		data += " href=\"cid:";
  		data += m_attachment->getHeader(AXIS_CONTENT_ID);
  		data += "\"";
  	}
  	pSZ.serialize(data.c_str(), NULL);
  
  	list<Attribute*>::iterator it = m_attributes.begin();
  	while (it != m_attributes.end())
  	{
  		pSZ.serialize("\r\n  ",NULL);
  		(*it)->serialize(pSZ);
  		it++;
  	}
  	pSZ.serialize("/>\r\n",NULL);
  }
  
  void SoapAttachmentReference::addAttributes(IAttribute **attributes, int nAttributes)
  {
  	if (0==nAttributes || NULL==attributes) return;
  	for (int i=0; i<nAttributes; i++)
  		if (NULL!=attributes[i]) 
  			m_attributes.push_back(static_cast<Attribute*>(attributes[i]));
  
  	return;
  }
  
  AXIS_CPP_NAMESPACE_END
  
  
  
  
  
  
  
  
  
  
  
  
  1.1                  ws-axis/c/src/soap/SoapAttachmentReference.hpp
  
  Index: SoapAttachmentReference.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.
   */
  
  #if !defined(SOAPATTACHMENTREFERENCE_H__INCLUDED_)
  #define SOAPATTACHMENTREFERENCE_H__INCLUDED_
  
  #include <axis/GDefine.hpp>
  #include <axis/IAttribute.hpp>
  #include "SoapAttachment.hpp"
  #include <list>
  
  using namespace std;
  
  AXIS_CPP_NAMESPACE_START
  
  class SoapSerializer;
  class Attribute;
  
  class SoapAttachmentReference
  {
  private:	
  	SoapAttachment *m_attachment;
  	list<Attribute*> m_attributes;
  
  public:	
  	SoapAttachmentReference(SoapAttachment *att);
  	virtual ~SoapAttachmentReference();	
      SoapAttachment* getAttachment();
  	void serialize(SoapSerializer& pSZ, const char *name);
  	void addAttributes(IAttribute **attributes, int nAttributes);
  };
  
  AXIS_CPP_NAMESPACE_END
  
  #endif // !defined(SOAPATTACHMENTREFERENCE_H__INCLUDED_)
  
  
  
  
  1.2       +3 -5      ws-axis/c/tests/auto_build/testcases/output/AttDataHandlerTextRequest.out
  
  Index: AttDataHandlerTextRequest.out
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/tests/auto_build/testcases/output/AttDataHandlerTextRequest.out,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttDataHandlerTextRequest.out	6 Jul 2005 11:12:18 -0000	1.1
  +++ AttDataHandlerTextRequest.out	14 Jul 2005 13:18:40 -0000	1.2
  @@ -33,14 +33,14 @@
   POST /DataHandlerService/services/DataHandlerService HTTP/1.1
   Host: localhost:13260
   SOAPAction: ""
  -Content-Type: multipart/related; type="text/xml"; boundary="------=MIME_BOUNDARY"; start="<2>"
  -Content-Length: 859
  +Content-Length: 781
  +Content-Type: multipart/related; type="text/xml"; boundary="------=MIME_BOUNDARY"; start="<3>"
   
   
   --------=MIME_BOUNDARY
   Content-Type: text/xml; charset=UTF-8
   Content-Transfer-Encoding: binary
  -Content-Id: <2>
  +Content-Id: <3>
   
   <?xml version='1.0' encoding='utf-8' ?>
   <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  @@ -48,8 +48,6 @@
   <ns1:getContentType xmlns:ns1="http://datahandler.attachment.test.org">
   <ns1:arg_0_0 href="cid:1"
      xsi:type="ns2:DataHandler"
  -   xmlns:ns2="http://xml.apache.org/xml-soap"
  -   xsi:type="ns2:DataHandler"
      xmlns:ns2="http://xml.apache.org/xml-soap"/>
   </ns1:getContentType>
   </SOAP-ENV:Body>