Hello! I'm new here so feel free to criticize me if my question is worded poorly, or if I'm asking too much, or if you just don't like me thats fine too!
Desirable Result: I'm trying to make a C++ application which sends a SOAP message to a php server, which in turn sends back a SOAP message that the C++ application will look at and be able to understand it.
Current Result: I have a C++ application which sends a SOAP message to the php server, and the php server sends back a soap message containing a number which the C++ application "understands" and changes its reply based on what number is returned.
Problem: I can't figure out how to send the SOAP response message (as a string, character array, array of strings) back to the C app. I'm using DOM and the function which gets the response from the php server from the C++ side is like thus:
float CHBP1Dlg::GetRoomAndNameOut(LPCTSTR Name, LPCTSTR RoomNumber)
{
float Room;
int i = atoi(RoomNumber);
USES_CONVERSION;
// SOAP Request Envelop to be posted
TCHAR szSOAPReq[MAX_PATH*2] = {0};
TCHAR szSOAPReq2[MAX_PATH*2] = {0};
TCHAR szSOAPReq3[MAX_PATH*2] = {0};
sprintf(szSOAPReq, g_lpszSOAPReqMultiple3, Name);
sprintf(szSOAPReq2, g_lpszSOAPReqMultiple4, i);
strcat(szSOAPReq3, szSOAPReq);
strcat(szSOAPReq3, szSOAPReq2);
//MessageBox(szSOAPReq3);
// Create an instance of HBP
CComPtr<IXMLHTTPRequest> spSoapFunc;
HRESULT hr = spSoapFunc.CoCreateInstance(CLSID_XMLHTTP60);
CHECK_HR(hr);
// Initialize the Synchronous HTTP POST request
hr = spSoapFunc->open(_bstr_t(_T("POST")), g_lpszSOAPEndpointURL, VARIANT_FALSE);
CHECK_HR(hr);
// Set the required Content-Type header
hr = spSoapFunc->setRequestHeader(_bstr_t(_T("Content-Type")), _bstr_t(_T("text/xml")));
CHECK_HR(hr);
// Send the POST request, along with the SOAP request envelope text
hr = spSoapFunc->send(_bstr_t(szSOAPReq3));
CHECK_HR(hr);
if(200 == spSoapFunc->status) //Success
{
// using MSXML DOM to process SOAP response XML text
CComQIPtr <IXMLDOMDocument2> spResponseXMLDoc;
CComPtr <IXMLDOMNode> spResultNode;
spResponseXMLDoc = spSoapFunc->responseXML;
spResultNode = spResponseXMLDoc->selectSingleNode(_bstr_t(_T("//ResultNameAndRoom")));
if(spResultNode.p != NULL)
{
Room = spResultNode->nodeTypedValue;
MessageBox("Success");
}
else
MessageBox("Theres a problem commander");
}
else
{
MessageBox("\nError: %s\n"), W2A(spSoapFunc->statusText);
}
return Room;
}
Already tried:
-Changing float to char (haha) for all parameters: caused error with nodeTypedValue
-Changing NodeTypedValue to anything else: no good
So I know I have to do something where the DOM programming is concerned... does anyone know what that something is? How I can make it so that this function can return a string value from the result node? Any help, any comments, even if just to say "You're a moron", ANYTHING would be accepted warmly. I have posted this question on 3 forums including microsofts website with not even one response.