OK, I've moved on a bit now. Managed to iron out most of the POST I think. Here's the code I've added at the start:
(By the way - the SOAP header gave a huge horrible error - assignment of pointer to const unsigned short to pointer to char - until I added the word "unsigned" in front of it. I hope this was the right fix, all I know is that it works.)
// UPnP request to be sent via POST in XML format
char *PostData =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
" <s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
" <u:GetAudioInputName xmlns:u=\"urn:schemas-upnp-org:service:AudioIn:1\" />\n"
// SOAP header required for UPnP request
unsigned char *ExtraHeader = "SOAPACTION: \"urn:schemas-upnp-org:service:AudioIn:1#GetAudioInputName\"";
// Length of UPnP request
char PostLength = lstrlen(PostData)*sizeof(TCHAR);
// Length of SOAP header
char HeaderLength = lstrlen(ExtraHeader)*sizeof(TCHAR);
// Total length
char TotalLength = PostLength + HeaderLength;
printf("postlength is %d\n", PostLength);
printf("headerlength is %d\n", HeaderLength);
printf("totallength is %d\n", TotalLength);
Anyway, here's my new HTTP request code:
This now returns an error 87, which I beleive may be due to incorrect values of HeaderLength, PostLength and/or TotalLength.
// Send a request.
if( hRequest )
bResults = WinHttpSendRequest( hRequest,
PostLength, 0 );
Interestingly enough, when I run my program, with my "FYI" information that prints out the lengths of the header and POST data, this is what I get:
Now the 70 value looks about right, and totallength is calculating OK, but I know for a fact that the XML code I'm sending is a lot longer than 18 characters! What am i doing wrong here?
postlength is 18
headerlength is 70
totallength is 88
One more question - why do I use "*sizeof(TCHAR)" when figuring out length? I got that code from another sample somewhere.