axis-c-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Souther <bsout...@fwdco.com>
Subject Re: [OT] Passing strings to and from C++ App
Date Mon, 07 Jun 2004 11:58:50 GMT
Thank you Stephane,
Do you know where I could find some code examples?
This client will eventually need to pass some very large strings, the size of 
which can not be predetermined.

Thanks again
-Ben



On Monday 07 June 2004 06:41 am, Stephane Antonietti wrote:
> Hi
>
> Using this method of allocating memory is very dangerous :
>
> 	char* return_value = "error";
>
> Indeed, return_value has an allocated size of 6 bytes including the null
> character. If the response is longer than 6, you get a buffer overrun.
>
> Increase the size of the return_value buffer, and the things should go
> better.
>
> Regards,
>
> Stephane
>
> Stephane Antonietti
> Sr Technical Consultant
> Experian-Scorex, Monaco
> -----------------------------------------------
> stephane@experian-scorex.com
> www.experian-scorex.com
>
> -----Original Message-----
> From: bsouther@fwdco.com [mailto:bsouther@fwdco.com]
> Sent: Friday, June 04, 2004 10:55 PM
> To: Apache AXIS C User List
> Subject: [OT] Passing strings to and from C++ App
>
> <disclaimer> Not an experienced C/C++ developer </disclaimer>
>
> I'm not sure what the best way to pass strings back and forth from a c
> app
> to an Axis Client.  The following app works with a char* but then
> displays an
> assertion error (below).
>
> Can anyone tell me what I'm doing wrong here?  Do I need to declare my
> own
> xsd__string types and do a conversion?  If so, are there any examples of
> how
> to do so out there?
>
> Thanks in advance.
>
> ==========================================
> Error Message
> ==========================================
> Debug Assertion Failed!
>
> Program: D:\axis-clients\EchoCaps\Release\EchoCaps.exe
> File: dbgheap.c
> Line: 1011
>
> Expression: _CrtIsValidHeapPointer(pUserData)
>
>
>
>
> ==========================================
> My Code
> ==========================================
> #include "EchoCaps.h"
> #include <axis/server/AxisWrapperAPI.h>
> #define ENDPOINT] =
> "http://192.168.0.103:8888/file_manager/services/EchoCaps";
>
> bool CallBase::bInitialized;
> CallFunctions CallBase::ms_VFtable;
>
> EchoCaps::EchoCaps(){
> 	m_pCall = new Call();
> 	m_pCall->SetProtocol(APTHTTP);
> 	m_pCall->SetEndpointURI(ENDPOINT);
> }
>
> EchoCaps::~EchoCaps(){
> 	delete m_pCall;
> }
>
> char* EchoCaps::capitalize(xsd__string inputString){
> 	char* return_value = "error";
> 	if (AXIS_SUCCESS != m_pCall->Initialize(CPP_RPC_PROVIDER,
> NORMAL_CHANNEL))
> 		return "failed to initialize" ;
>
> 	m_pCall->SetTransportProperty(SOAPACTION_HEADER ,
> "EchoCaps#capitalize");
> 	m_pCall->SetSOAPVersion(SOAP_VER_1_1);
>
> 	m_pCall->SetOperation("capitalize", ENDPOINT);
> 	m_pCall->AddParameter((void*)&inputString, "inputString",
> XSD_STRING);
>
> 	if (AXIS_SUCCESS == m_pCall->Invoke()){
> 		printf("Invocation went well\n\n");
>
> 		if(AXIS_SUCCESS ==
> m_pCall->CheckMessage("capitalizeResponse", ENDPOINT)){
> 			return_value =
> m_pCall->GetElementAsString("capitalizeResponse", ENDPOINT);
> 			m_pCall->UnInitialize();
> 			return return_value;
> 		}
> 	}
>
> 	m_pCall->UnInitialize();
> 	return "End of capitalize function\n\n";
> }
>
> void main(){
> 	EchoCaps echoCaps;
> 	char* input = "Input from C++ client";
> 	printf("results: %s\n\n", echoCaps.capitalize(msg));
> 	printf("done\n\n");
> }



Mime
View raw message