I have the following code for sending the response, but only the first 4 bytes are sent in response. Why the behaviours is like this?
int sendRaw(struct soap *soap, const char *respMsg)
{
if (soap_response(&objSoap, SOAP_FILE)) /* OK HTTP response header */
{
soap_end_send(&objSoap);
return soap->error;
}
for(int i = 0; i < sizeof(respMsg); i++)
{
if(soap_send_raw(&objSoap,&respMsg[i],1))
{
return soap_end_send(&objSoap);
}
}
soap_end_send(&objSoap);
return SOAP_OK;
}
and my calling is like this
const char msg = "this is a rest response";
return sendRaw(&objSoap,msg);
Since respMsg
is a char *
, it's size equates that of any other pointer in your system, which given your problem description appears to be 4 bytes (32 bits):
for(int i = 0; i < sizeof(respMsg); i++)
If respMsg
is a string, then use strlen(respMsg)
[this is the case in your little example], if it is some kind of binary data, then you will need to pass along the actual size.