Hi All

This is in regard to AXISCPP-634. I was trying to use the method
getAttributeAsString() in IWrapperSoapDeSerializer and was unable to get the required result.

On Looking up SoapDeSerializer.cpp I understood that getElementForAttribute was to be called before
calling getAttributeAsString.
** Code/Comments from SoapDeSerializer.cpp **
           /*
1463 * Before calling any of getAttributeAs... API functions the user should move 1464 * current Element to the right Element by calling GetElementForAttributes(..)
  1465  */
  1466 xsd__int *
  1467     SoapDeSerializer::getAttributeAsInt (const AxisChar * pName,
1468 const AxisChar * pNamespace)
  1469 {
  1470     Int simpleType;
  1471     getAttribute(pName, pNamespace, &simpleType);
  1472         return simpleType.getInt();
  1473 }

But getElementForAttribute is not available in IWrapperSoapDeSerializer
which is the object accessible in the stubs.

Also getElementForAttribute is a private method in SoapDeSerializer

SOAP - RESPONSE
<ns1:echoIntArrayResponse xmlns:ns1="http://soapinterop.org/";>
<intArrayType xsi:type="ns2:intArrayType" xmlns:ns2="http://soapinterop.org/xsd"; ref="http://www.lac.uic.edu:8080"; >
<item>0</item>

What I would ideally like to do is
extract the ref tag above in the axis client stub code within the deserialize function found in intArrayType.cpp

int Axis_DeSerialize_intArrayType(intArrayType* param, IWrapperSoapDeSerializer* pIWSDZ)
    72 {
73 *printf("\n The attribute is %s",pIWSDZ->getAttributeAsString("ref",0));* 74 param->intItem = (xsd__int_Array&)pIWSDZ->getBasicArray(XSD_INT, "intItem",0);
    75         return pIWSDZ->getStatus();
    76 }

Currently the above code returns null. output
--- The attribute is (null) ----

Line 73 was the only line added by me to the stubs.
But after doing some changes to IWrapperSoapDeSerializer to make getElementForAttribute accessible and adding

getElementForAttribute("intArrayType",0); before line 73 makes things work.

Is this the way of getting the attributes from the soap message or am I missing something?

I have attached the client stub code. I am using axiscpp checked out from the CVS on 25th July 2005

Thanks
Krishna

Dushshantha Chandradasa wrote:

HI Krishna,

If you are not a committer, you cannot assign the issue to yourself. If you can please attach the diff with respect to the svn head to the issue, I can test the changes and commit it to the SVN.

 **

------------------------------------------------------------------------

*From:* krishna [mailto:[EMAIL PROTECTED]
*Sent:* Wednesday, October 12, 2005 6:17 AM
*To:* [email protected]
*Subject:* AXISCPP-634

Hi All

I am currently implementing a webservices solution using Axis C++. My webservices solution urgently requires functionality provided by AXISCPP-634. ( Setting attributes for complex types in the SOAP-RESPONSE )
http://issues.apache.org/jira/browse/AXISCPP-634.

From JIRA I understand that it is still unassigned.
If nobody is working on it, would it be possible for me to contribute in resolving AXISCPP-634??

Thanks
Krishna Kumar Rajagopalan
http://uic.edu/~krajag2 <http://uic.edu/%7Ekrajag2>


/*
 *Sample Code for Array: By Krishna Kumar Rajagopalan
 *Uses a RPC Web Service
 *
 */

#include "ArrayTestPortType.hpp"
#include <stdio.h>
#include <iostream>

unsigned int ARRAY_SIZE=1;

int main(int argc,char *argv[])
{
	char serverurl[500]="http://localhost/axis/arrayPS";;
	intArrayType arr_in;
	intArrayType *arr_out;
	arr_in.intItem.m_Size = 1;
	int arr[1];
	if( argc > 1 )
	{
		switch(argc)
		{
	  	        default: printf("\n Extra parameters specified!! Neglecting extra parameters \n");
		  	case 3:	strcpy(serverurl,argv[2]);
			case 2: arr[0]=atoi(argv[1]);
		}
	}
	else
	{		
		printf("\n Switching to defaults \n");
		arr[0]=0;
		strcpy(serverurl,"http://localhost/axis/arrayPS";);
	}

	arr_in.intItem.m_Array = new int*;
	arr_in.intItem.m_Array[0] = &arr[0];
	
	ArrayTestPortType ws(serverurl);
	printf("\n Invoking Echo int Array \n");
	try
	{
		ws.setTransportTimeout(10000);
		if ((arr_out = ws.echoIntArray(&arr_in))->intItem.m_Array == NULL )
		{
			printf("\n Received Null \n");
		}
		else
		{
			printf("\n Not null output !! ");
			cout<<"Array size is "<<arr_out->intItem.m_Size<<endl;
			for( int i=0; i < arr_out->intItem.m_Size; i++)
			{
				printf("\n Item %d is %d",i,*(arr_out->intItem.m_Array[i]));
			}
		}
	}
	catch(AxisException& e)
	{
	         printf("Exception : %s\n", e.what());
	}
        catch(exception& e)
	{
	         printf("Unknown exception has occured\n");
	}
	catch(...)
	{
	         printf("Unknown exception has occured\n");
	}
	return 0;
}
/*
 * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
 * This file contains Client Stub implementation for remote web service.
 */

#include "ArrayTestPortType.hpp"

#include <axis/AxisWrapperAPI.hpp>
#include <string.h>

using namespace std;

 extern int Axis_DeSerialize_intArrayType(intArrayType* param, IWrapperSoapDeSerializer* pDZ);
extern void* Axis_Create_intArrayType(intArrayType *Obj, bool bArray = false, int nSize=0);
extern void Axis_Delete_intArrayType(intArrayType* param, bool bArray = false, int nSize=0);
extern int Axis_Serialize_intArrayType(intArrayType* param, IWrapperSoapSerializer* pSZ, bool bArray = false);
extern int Axis_GetSize_intArrayType();

ArrayTestPortType::ArrayTestPortType(const char* pchEndpointUri, AXIS_PROTOCOL_TYPE eProtocol)
:Stub(pchEndpointUri, eProtocol)
{
}

ArrayTestPortType::ArrayTestPortType()
:Stub(" ", APTHTTP1_1)
{
	m_pCall->setEndpointURI("http://localhost/axis/arrayPS";);
}

ArrayTestPortType::~ArrayTestPortType()
{
}


/*Methods corresponding to the web service methods*/

/*
 * This method wrap the service method echoIntArray
 */
intArrayType* ArrayTestPortType::echoIntArray(intArrayType* Value0)
{
	intArrayType* pReturn = NULL;
	const char* pcCmplxFaultName;
	try
	{
		if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER)) 
			return pReturn;
	if (NULL==m_pCall->getTransportProperty("SOAPAction",false))
	{
		m_pCall->setTransportProperty(SOAPACTION_HEADER , "arrayPS#echoIntArray");
	}
		m_pCall->setSOAPVersion(SOAP_VER_1_1);
		m_pCall->setOperation("echoIntArray", "http://soapinterop.org/";);
		applyUserPreferences();
	m_pCall->addCmplxParameter(Value0, (void*)Axis_Serialize_intArrayType, (void*)Axis_Delete_intArrayType, "inputIntArrayType", Axis_URI_intArrayType);
		if (AXIS_SUCCESS == m_pCall->invoke())
		{
			if(AXIS_SUCCESS == m_pCall->checkMessage("echoIntArrayResponse", "http://soapinterop.org/";))
			{
				pReturn = (intArrayType*)m_pCall->getCmplxObject((void*) Axis_DeSerialize_intArrayType, (void*) Axis_Create_intArrayType, (void*) Axis_Delete_intArrayType,"_return", 0);
		}
		}
	m_pCall->unInitialize();
		return pReturn;
	}
	catch(AxisException& e)
	{
		int iExceptionCode = e.getExceptionCode();
		if(AXISC_NODE_VALUE_MISMATCH_EXCEPTION != iExceptionCode)
		{
			throw SoapFaultException(e);
		}
		ISoapFault* pSoapFault = (ISoapFault*)
			m_pCall->checkFault("Fault","http://localhost/axis/arrayPS"; );
		if(pSoapFault)
		{
			m_pCall->unInitialize();
			throw SoapFaultException(e);
		}
		else throw;
	}
}

/*
 * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
 * This file contains Client Stub Class for remote web service 
 */

#if !defined(__ARRAYTESTPORTTYPE_CLIENTSTUB_H__INCLUDED_)
#define __ARRAYTESTPORTTYPE_CLIENTSTUB_H__INCLUDED_

#include <axis/client/Stub.hpp>
#include <axis/SoapFaultException.hpp>
#include <axis/ISoapFault.hpp>
AXIS_CPP_NAMESPACE_USE
#include "intArrayType.hpp"

class ArrayTestPortType :public Stub
{
public:
	STORAGE_CLASS_INFO ArrayTestPortType(const char* pchEndpointUri, AXIS_PROTOCOL_TYPE eProtocol=APTHTTP1_1);
	STORAGE_CLASS_INFO ArrayTestPortType();
public:
	STORAGE_CLASS_INFO virtual ~ArrayTestPortType();
public: 
	STORAGE_CLASS_INFO intArrayType* echoIntArray(intArrayType* Value0);
};

#endif /* !defined(__ARRAYTESTPORTTYPE_CLIENTSTUB_H__INCLUDED_)*/
/*
 * 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.
 *
 * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
 * This file contains functions to manipulate complex type intArrayType
 */

#include "intArrayType.hpp"
#include <axis/AxisWrapperAPI.hpp>
#include <iostream>

using namespace std;

xsd__int_Array intArrayType::getintItem()
{
	return intItem ; 
}

void intArrayType::setintItem(xsd__int_Array InValue)
{
	intItem = InValue ; 
}
/*
 * This static method serialize a intArrayType type of object
 */
int Axis_Serialize_intArrayType(intArrayType* param, IWrapperSoapSerializer* pSZ, bool bArray = false)
{
	if (bArray)
	{
		pSZ->serialize("<", Axis_TypeName_intArrayType, ">", NULL);
	}
	else
	{
		bool blnIsNewPrefix = false;
		const AxisChar* sPrefix = pSZ->getNamespacePrefix(Axis_URI_intArrayType, blnIsNewPrefix);
		if (!blnIsNewPrefix)
		{
			pSZ->serialize("<", Axis_TypeName_intArrayType, " xsi:type=\"", sPrefix, ":",
				Axis_TypeName_intArrayType, "\">", NULL);
		}
		else
		{
			pSZ->serialize("<", Axis_TypeName_intArrayType, " xsi:type=\"", sPrefix, ":",
				Axis_TypeName_intArrayType, "\" xmlns:", sPrefix, "=\"",
				Axis_URI_intArrayType, "\">", NULL);
		}
	}

	pSZ->serializeBasicArray((Axis_Array*)(&param->intItem),XSD_INT, "intItem");

	pSZ->serialize("</", Axis_TypeName_intArrayType, ">", NULL);
	return AXIS_SUCCESS;
}

/*
 * This static method deserialize a intArrayType type of object
 */
int Axis_DeSerialize_intArrayType(intArrayType* param, IWrapperSoapDeSerializer* pIWSDZ)
{
	//printf("\n The attribute is %s",pIWSDZ->getAttributeAsString("ref",0));
	param->intItem = (xsd__int_Array&)pIWSDZ->getBasicArray(XSD_INT, "intItem",0);
	return pIWSDZ->getStatus();
}
void* Axis_Create_intArrayType(intArrayType* pObj, bool bArray = false, int nSize=0)
{
	if (bArray && (nSize > 0))
	{
		if (pObj)
		{
			intArrayType* pNew = new intArrayType[nSize];
			memcpy(pNew, pObj, sizeof(intArrayType)*nSize/2);
			memset(pObj, 0, sizeof(intArrayType)*nSize/2);
			delete [] pObj;
			return pNew;
		}
		else
		{
			return new intArrayType[nSize];
		}
	}
	else
		return new intArrayType;
}

/*
 * This static method delete a intArrayType type of object
 */
void Axis_Delete_intArrayType(intArrayType* param, bool bArray = false, int nSize=0)
{
	if (bArray)
	{
		delete [] param;
	}
	else
	{
		delete param;
	}
}
/*
 * This static method gives the size of intArrayType type of object
 */
int Axis_GetSize_intArrayType()
{
	return sizeof(intArrayType);
}

intArrayType::intArrayType()
{
	/*do not allocate memory to any pointer members here
	 because deserializer will allocate memory anyway. */
	intItem.m_Array = 0;
	intItem.m_Size = 0;
}

intArrayType::~intArrayType()
{
	/*delete any pointer and array members here*/
	delete [] ((xsd__int*)intItem.m_Array);
}
/*
 * 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.
 *
 * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
 * This file contains functions to manipulate complex type intArrayType
 */

#if !defined(__INTARRAYTYPE_PARAM_H__INCLUDED_)
#define __INTARRAYTYPE_PARAM_H__INCLUDED_

#include <axis/AxisUserAPI.hpp>
AXIS_CPP_NAMESPACE_USE 

/*Local name and the URI for the type*/
static const char* Axis_URI_intArrayType = "http://soapinterop.org/xsd";;
static const char* Axis_TypeName_intArrayType = "intArrayType";

class intArrayType
{
public:
	xsd__int_Array	intItem;

	xsd__int_Array getintItem();
	void setintItem(xsd__int_Array InValue);

	intArrayType();
	virtual ~intArrayType();
};

#endif /* !defined(__INTARRAYTYPE_PARAM_H__INCLUDED_)*/

Reply via email to