(I posted this on the gSOAP discussion forum, but I figured I might be able to 
get help here since my problem might be a Palm issue and not a gSOAP issue).

Hello,

I had a working gSOAP Palm application that I had built using gSOAP 
2.7.6c.
 
wsdl2h.exe generates the xsd__base64Binary structure for the byte[] 
data type from a .NET web service.  Everything was fine and dandy 
until I upgraded to gSOAP 2.7.7.
 
Ever since the upgrade to 2.7.7 this data structure has been giving 
me serious memory allocation problems in my application, and I can't 
make any sense of it.

Here is some simplified code to explain my problem:

My old working code had a number of methods that connect to 
different web methods.  These web methods are dealing with 
base64Binary structures in the request object. 

Here is an example of how I was doing things when it worked 
(simplified). 

void Method1()
{
char* mystring = "abcdefg";
struct _ns1__AuthenticateStudent_USCOREGeneral AuthenticateStudent;

AuthenticateStudent.base64struct= MemPtrNew(sizeof(struct 
xsd__base64Binary));
AuthenticateStudent.base64struct->__ptr = (unsigned char*)mystring;
AuthenticateStudent.base64struct->__size = StrLen(mystring);

//Call the web service
rc = soap_call___ns1__AuthenticateStudent_USCOREGeneral(soap, 
WebServiceURL, NULL, &AuthenticateStudent, 
&AuthenticateStudentResponse);  
}

Now, this code actually still works.... if i call it once.  If I 
call this method more than once I recieve the error "MyApp just read 
from memory location 0x63657373, causing a bus error.  A "bus error" 
means that the application accessed a momory location that is not in 
RAM or ROM, nor corresponds to a memory mapped hardware register".

If I have a different method that makes use of the baseBinary64 
structure, it will fail if the above method was called first.

Now, if I modify this method to continually call the webservice it 
will work fine.  But it will still fail if I call the method a 
second time.

void Method1()
{
char* mystring = "abcdefg";
struct _ns1__AuthenticateStudent_USCOREGeneral AuthenticateStudent;

AuthenticateStudent.base64struct= MemPtrNew(sizeof(struct 
xsd__base64Binary));
AuthenticateStudent.base64struct->__ptr = (unsigned char*)mystring;
AuthenticateStudent.base64struct->__size = StrLen(mystring);

//Call the web service
rc = soap_call___ns1__AuthenticateStudent_USCOREGeneral(soap, 
WebServiceURL, NULL, &AuthenticateStudent, 
&AuthenticateStudentResponse);  

MemPtrFree(AuthenticateStudent.base64struct);

AuthenticateStudent.base64struct= MemPtrNew(sizeof(struct 
xsd__base64Binary));
AuthenticateStudent.base64struct->__ptr = (unsigned char*)mystring;
AuthenticateStudent.base64struct->__size = StrLen(mystring);

//Call the web service
rc = soap_call___ns1__AuthenticateStudent_USCOREGeneral(soap, 
WebServiceURL, NULL, &AuthenticateStudent, 
&AuthenticateStudentResponse);  

... repeat ...

}

If I debug the code, the failure is occuring deep within the bowels 
of the gSOAP code.  This is also how I'm certain that its failing 
due to this data structure, since it fails on the line (my data 
structure is named "hash"):

soap_out_PointerToxsd__base64Binary(soap, "ns1:hash", -1, &a-
>hash, "");


SOAP_FMAC3 int SOAP_FMAC4 
soap_out__ns1__AuthenticateStudent_USCOREGeneral(struct soap *soap, 
const char *tag, int id, const struct 
_ns1__AuthenticateStudent_USCOREGeneral *a, const char *type)
{
        soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, 
a, SOAP_TYPE__ns1__AuthenticateStudent_USCOREGeneral), type);
        soap_out_string(soap, "ns1:szLoginID", -1, &a-
>szLoginID, "");
        soap_out_string(soap, "ns1:szPIN", -1, &a->szPIN, "");
        soap_out_string(soap, "ns1:szInstituteId", -1, &a-
>szInstituteId, "");
        soap_out_int(soap, "ns1:versionNum", -1, &a->versionNum, "");

*******IT FAILS ON THE NEXT LINE**********************************
        soap_out_PointerToxsd__base64Binary(soap, "ns1:hash", -1, &a-
>hash, "");
*******IT FAILS ON THE PREVIOUS LINE******************************
        soap_element_end_out(soap, tag);
        return SOAP_OK;
}


And just for your reference, here is the data structure for my 
authenticate user web method that uses the base64binary data 
structure, as well as the base64binary structure.

struct _ns1__AuthenticateStudent_USCOREGeneral
{
char *szLoginID;        
char *szPIN;    
char *szInstituteId;
int versionNum; 
struct xsd__base64Binary *hash; 
};

struct xsd__base64Binary
{
        unsigned char *__ptr;
        int __size;
        char *id;       /* optional element of type xsd:string */
        char *type;     /* optional element of type xsd:string */
        char *options;  /* optional element of type xsd:string */
};


So does anyone have any idea why I'm having these problems when 
using gSOAP 2.7.7 and not 2.7.6c?
-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to