代码如下 
xml如下 
<?xml version="1.0" encoding="utf-8"?> 
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> 
  <soap12:Header> 
    <ymexWebServiceHeader xmlns="http://tempuri.org/"> 
      <UserName>string </UserName> 
      <PassWord>string </PassWord> 
    </ymexWebServiceHeader> 
  </soap12:Header> 
  <soap12:Body> 
    <ymKq xmlns="http://tempuri.org/"> 
      <checkAttendanceCardNum>string </checkAttendanceCardNum> 
      <checkTime>string </checkTime> 
    </ymKq> 
  </soap12:Body> 
</soap12:Envelope> 
调用代码如下 
int CallWeb(string UserName) 
  { 
  USES_CONVERSION; 
  int temp=0; 
  CComPtr <IXMLHTTPRequest> spXMLHTTP; 
HRESULT hr = spXMLHTTP.CoCreateInstance(CLSID_XMLHTTP40); 
CHECK_HR(hr); 
//string Act=Act.append(checkAttendanceCardNum).append(" ").append(checkTime); 
  TCHAR szSOAPReq[MAX_PATH*2] = {0}; 
  sprintf(szSOAPReq, g_lpszSOAPReq,UserName); 
  // sprintf(szSOAPReq, g_lpszSOAPReq,checkTime); 
// Initialize the Synchronous HTTP POST request 
hr = spXMLHTTP->open(_bstr_t(_T("POST")), g_lpszSOAPEndpointURL, VARIANT_FALSE); 
CHECK_HR(hr); // Set the required Content-Type header 
hr = spXMLHTTP->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 = spXMLHTTP->send(_bstr_t(szSOAPReq)); 
CHECK_HR(hr); if(200 == spXMLHTTP->status) //Success 

// using MSXML DOM to process SOAP response XML text 
CComQIPtr <IXMLDOMDocument2> spResponseXMLDoc; 
CComPtr <MSXML2::IXMLDOMNode> spResultNode; 
spResponseXMLDoc = spXMLHTTP->responseXML; 
spResultNode = spResponseXMLDoc->selectSingleNode(_bstr_t(_T("//ymKqResult"))); 
if(spResultNode.p != NULL) 

temp = spResultNode->nodeTypedValue; 
printf("sucess\n"); 
} } 
else 

printf("failed\n"); 

  return temp; 
  } 
总是发送失败,请教下,如何正确发送消息或者代码改进也可 多谢