Hello list.

     I have a problem receiving binary data. I've develop a C client, in
order to consume getLicenceInstallation web method, implemented on Java
that retuns a byte array.

@WebMethod(operationName="GetLicenceInstallation")
     public byte[] getLicenceInstalation(
             @WebParam(name="customer_code")String customer_code,
             @WebParam(name="customer_passwd")String customer_passwd,
             @WebParam(name="customer_mail")String customer_mail,
             @WebParam(name="licence_type_code")String licence_type_code,
             @WebParam(name="fields")byte[] fields) {

         return this.facade.activateLicence(licence_type_code,
customer_code, customer_passwd, customer_mail, fields);
     }
The return value is translated for gSOAP as:

struct ws1__GetLicenceInstallationResponse
{
     struct xsd__base64Binary*            return_                       
0;
};

struct xsd__base64Binary
{    unsigned char *__ptr;
     int __size;
     char *id, *type, *options;
};
I call the method as follow:


      struct soap soap;
      struct ws1__GetLicenceInstallation request;
      struct ws1__GetLicenceInstallationResponse response;

      request.customer_x005fcode = "XXX";
      request.customer_x005fmail = "XXX";
      request.customer_x005fpasswd = "XXX";
      request.licence_x005ftype_x005fcode = "XXX";

      soap_init(&soap);

      if (soap_call___ws1__GetLicenceInstallation(&soap, server, "",
&request, &response) == SOAP_OK)
      {
             printf("[");
             for (i=0;i<response.return_->__size;i++)
             {
                  printf("%x ", response.return_->__ptr[i]);
              }
             printf("]");

          hFile = CreateFile("licence.lcc", GENERIC_WRITE,
FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
          WriteFile(hFile, response.return_->__ptr,
response.return_->__size, NULL, NULL);
          CloseHandle(hFile);
      }

      soap_destroy(&soap);
      soap_end(&soap);
      soap_done(&soap);

The problem is that response.return_->__ptr and response.return_->__size
have incorrect values in some section of the code on screenshoot
<http://i16.photobucket.com/albums/b45/jeusdi/gSOAP2.png> .

As you can see response.return_->__size is 1246121287, however the for
section prints on console 260 items (bytes), that's correct.
Also, you can see that response.return_->ptr is NULL, however, I've
printed the values in console!!!

When I try to save the data on a file the program crashes.

Do I need no initialize response.return_ manually?

Thanks for all

Reply via email to