vs2005 调用webservice时BeginParse出错,请大侠指点一下,在线等,非常感谢!
vs2005 添加webservice,调用webservice时BeginParse出错,代码如下:
#include "stdafx.h"
#include "WebTest1.h"
#include "WebService.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 唯一的应用程序对象
CWinApp theApp;
using namespace std;
using namespace RFIDTaskImplService;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// 初始化 MFC 并在失败时显示错误
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: 更改错误代码以符合您的需要
_tprintf(_T("错误: MFC 初始化失败\n"));
nRetCode = 1;
}
else
{
// TODO: 在此处为应用程序的行为编写代码。
CoInitialize(NULL);
CRFIDTaskImplService* service = new CRFIDTaskImplService();
query qry = {0, 10, BSTR(_T("id")), BSTR(_T("ASC")), BSTR(_T(""))};
queryResponse* response = new queryResponse();
HRESULT re = service->_query(qry, response);
delete service;
delete response;
CoUninitialize();
}
return nRetCode;
}
template <typename TClient>
inline HRESULT CRFIDTaskImplServiceT<TClient>::_query(
query _query0,
queryResponse* _queryResponse
)
{
if ( _queryResponse == NULL )
return E_POINTER;
HRESULT __atlsoap_hr = InitializeSOAP(NULL);
if (FAILED(__atlsoap_hr))
{
SetClientError(SOAPCLIENT_INITIALIZE_ERROR);
return __atlsoap_hr;
}
CleanupClient();
CComPtr<IStream> __atlsoap_spReadStream;
__CRFIDTaskImplService__query_struct __params;
memset(&__params, 0x00, sizeof(__params));
__params._query0 = _query0;
__atlsoap_hr = SetClientStruct(&__params, 0);
if (FAILED(__atlsoap_hr))
{
SetClientError(SOAPCLIENT_OUTOFMEMORY);
goto __skip_cleanup;
}
__atlsoap_hr = GenerateResponse(GetWriteStream());
if (FAILED(__atlsoap_hr))
{
SetClientError(SOAPCLIENT_GENERATE_ERROR);
goto __skip_cleanup;
}
__atlsoap_hr = SendRequest(_T("SOAPAction: \"urn:query\"\r\n"));
if (FAILED(__atlsoap_hr))
{
goto __skip_cleanup;
}
__atlsoap_hr = GetReadStream(&__atlsoap_spReadStream);
if (FAILED(__atlsoap_hr))
{
SetClientError(SOAPCLIENT_READ_ERROR);
goto __skip_cleanup;
}
// cleanup any in/out-params and out-headers from previous calls
Cleanup();
__atlsoap_hr = BeginParse(__atlsoap_spReadStream);
if (FAILED(__atlsoap_hr))
{
SetClientError(SOAPCLIENT_PARSE_ERROR);
goto __cleanup;
}
*_queryResponse = __params._queryResponse;
goto __skip_cleanup;
__cleanup:
Cleanup();
__skip_cleanup:
ResetClientState(true);
memset(&__params, 0x00, sizeof(__params));
return __atlsoap_hr;
}
Debug跟进去发现__atlsoap_hr = BeginParse(__atlsoap_spReadStream);这一行代码报错,不只怎么回事?