By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,905 Members | 2,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,905 IT Pros & Developers. It's quick & easy.

Returning a string from DOM?

P: 5
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);


// 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);

// Create an instance of HBP
CComPtr<IXMLHTTPRequest> spSoapFunc;
HRESULT hr = spSoapFunc.CoCreateInstance(CLSID_XMLHTTP60);

// Initialize the Synchronous HTTP POST request
hr = spSoapFunc->open(_bstr_t(_T("POST")), g_lpszSOAPEndpointURL, VARIANT_FALSE);

// Set the required Content-Type header
hr = spSoapFunc->setRequestHeader(_bstr_t(_T("Content-Type")), _bstr_t(_T("text/xml")));

// Send the POST request, along with the SOAP request envelope text
hr = spSoapFunc->send(_bstr_t(szSOAPReq3));

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("Theres a problem commander");
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.
Jun 18 '07 #1
Share this Question
Share on Google+
1 Reply

P: 5
Repeating statement: If anyone is out there, I don't mind if you don't have insight onto my problem, but I would appreciate ANY criticism, any insight, any comments. I am a little disappointed that forums online thus far have garnered a total of one response : /. If no one knows how to answer my question, could they at least offer me another forum to try? I don't mean to sound bitter, but I've been at this problem for a few days now and its my first time going so long for a single problem. Thanks in advance!
Jun 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.