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 2003/06/27 06:34:58 UTC
cvs commit: xml-axis/c/src/soap HeaderBlock.h HeaderBlock.cpp
roshan 2003/06/26 21:34:58
Added: c/src/soap HeaderBlock.h HeaderBlock.cpp
Log:
committing c++ code base
Revision Changes Path
1.1 xml-axis/c/src/soap/HeaderBlock.h
Index: HeaderBlock.h
===================================================================
/* -*- 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 Roshan Weerasuriya (roshan@jkcs.slt.lk)
*
*/
// HeaderBlock.h: interface for the HeaderBlock class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_HEADERBLOCK_H__F21C94A8_40D1_4CFC_9240_DD617494CF40__INCLUDED_)
#define AFX_HEADERBLOCK_H__F21C94A8_40D1_4CFC_9240_DD617494CF40__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Attribute.h"
#include <string>
#include <list>
using namespace std;
class BasicNode;
/**
* The header entry of a SOAP Header according to SOAP 1.1 specification.
*
* All immediate child elements of the Header element are called header
* entries.
* The encoding rules for header entries are as follows:
* 1) A header entry is identified by its fully qualified element name,
* which consists of the namespace URI and the local name. All
* immediate child elements of the SOAP Header element MUST be
* namespace-qualified.
* 2) The SOAP encodingStyle attribute MAY be used to indicate the
* encoding style used for the header entries.
* 3) The SOAP mustUnderstand attribute and SOAP actor attribute MAY
* be used to indicate how to process the entry and by whom.
*
*
* @brief The header entry of a SOAP Header according to SOAP 1.1 specification
*/
class HeaderBlock
{
private:
int serializeChildren(string& sSerialized);
list<BasicNode*> m_children;
bool isSerializable();
//string attrSerialize();
int attrSerialize(string&);
string m_localname;
string m_prefix;
string m_uri;
list<Attribute*> m_attributes;
string m_value;
//string m_strSerialized;
public:
int addChild(BasicNode* pBasicNode);
//string& serialize();
int serialize(string&);
void setValue(const string &value);
void addAttribute(Attribute* attr);
void setUri(const string &uri);
void setPrefix(const string &prefix);
void setLocalName(const string &localname);
HeaderBlock();
virtual ~HeaderBlock();
};
#endif // !defined(AFX_HEADERBLOCK_H__F21C94A8_40D1_4CFC_9240_DD617494CF40__INCLUDED_)
1.1 xml-axis/c/src/soap/HeaderBlock.cpp
Index: HeaderBlock.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 "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 Roshan Weerasuriya (roshan@jkcs.slt.lk)
*
*/
// HeaderBlock.cpp: implementation of the HeaderBlock class.
//
//////////////////////////////////////////////////////////////////////
#include "HeaderBlock.h"
#include "../common/GDefine.h"
#include "BasicNode.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
HeaderBlock::HeaderBlock()
{
}
HeaderBlock::~HeaderBlock()
{
list<Attribute*>::iterator itCurrAttribute= m_attributes.begin();
while(itCurrAttribute != m_attributes.end()) {
delete (*itCurrAttribute);
itCurrAttribute++;
}
m_attributes.clear();
}
void HeaderBlock::setLocalName(const string &localname)
{
m_localname= localname;
}
void HeaderBlock::setPrefix(const string &prefix)
{
m_prefix= prefix;
}
void HeaderBlock::setUri(const string &uri)
{
m_uri= uri;
}
void HeaderBlock::addAttribute(Attribute* attr)
{
m_attributes.push_back(attr);
}
void HeaderBlock::setValue(const string &value)
{
m_value= value;
}
int HeaderBlock::serialize(string& sSerialized)
{
/*
*In the code we don't look whether the m_prefix is available or
* not. Instead directly insert it. The reason is that the SOAP
* 1.1 spec says that "All immediate child elements of the SOAP
* Header element MUST be namespace-qualified".
*/
int iStatus= SUCCESS;
do {
if(isSerializable()) {
sSerialized= sSerialized + "<" + m_prefix + ":" + m_localname +
" xmlns:"+ m_prefix +"=\""+ m_uri+ "\"";
iStatus= attrSerialize(sSerialized);
if(iStatus==FAIL) {
break;
}
sSerialized= sSerialized + ">";
iStatus= serializeChildren(sSerialized);
if(iStatus==FAIL) {
break;
}
sSerialized= sSerialized + "</"+ m_prefix + ":"+ m_localname+ ">";
// sSerialized= sSerialized + ">" + m_value + "</"+ m_prefix +
// ":"+ m_localname+ ">";
} else {
iStatus= FAIL;
}
} while(0);
return iStatus;
}
/*string& HeaderBlock::serialize()
{*/
/*
*In the code we don't look whether the m_prefix is available or
* not. Instead directly insert it. The reason is that the SOAP
* 1.1 spec says that "All immediate child elements of the SOAP
* Header element MUST be namespace-qualified".
*/
/* m_strSerialized= "";
if(isSerializable()) {
string strAttrSerialized= attrSerialize();
m_strSerialized= "<" + m_prefix + ":" + m_localname + " xmlns:"+ m_prefix +
"=\""+ m_uri+ "\"";
if(!strAttrSerialized.empty()) { //NOTE: check whether the list is empty
m_strSerialized= m_strSerialized+ " "+ strAttrSerialized;
}
m_strSerialized= m_strSerialized + ">" + m_value + "</"+ m_prefix +
":"+ m_localname+ ">";
}
return m_strSerialized;
}*/
int HeaderBlock::attrSerialize(string& sSerialized)
{
int iStatus= SUCCESS;
list<Attribute*>::iterator itCurrAttribute= m_attributes.begin();
while(itCurrAttribute != m_attributes.end()) {
iStatus= (*itCurrAttribute)->serialize(sSerialized);
if(iStatus==FAIL) {
break;
}
itCurrAttribute++;
}
return iStatus;
}
/*string HeaderBlock::attrSerialize()
{
string strAttrSerialized;
list<Attribute*>::iterator itCurrAttribute= m_attributes.begin();
while(itCurrAttribute != m_attributes.end()) {
strAttrSerialized= strAttrSerialized+ (*itCurrAttribute)->serialize();
itCurrAttribute++;
if(itCurrAttribute != m_attributes.end()) {
strAttrSerialized= strAttrSerialized+ " ";
}
}
return strAttrSerialized;
}*/
bool HeaderBlock::isSerializable()
{
//bool blnStatus= true;\
//return blnStatus;
bool bStatus= true;
if(m_localname.length() == 0) {
bStatus= false;
} else {
if(m_prefix.length() == 0) {
if(m_uri.length() != 0) {
bStatus= false;
}
} else {
if(m_uri.length() == 0) {
bStatus= false;
}
}
}
return bStatus;
}
int HeaderBlock::addChild(BasicNode *pBasicNode)
{
m_children.push_back(pBasicNode);
return SUCCESS;
}
int HeaderBlock::serializeChildren(string &sSerialized)
{
list<BasicNode*>::iterator itCurrBasicNode= m_children.begin();
while(itCurrBasicNode != m_children.end()) {
(*itCurrBasicNode)->serialize(sSerialized);
itCurrBasicNode++;
}
return SUCCESS;
}