none
Unable to send big data with MSXML2::ServerXMLHTTP60 RRS feed

  • Вопрос

  • When I try to send big data with MSXML2::ServerXMLHTTP60, I receive "Not enough storage is available to complete this operation.".

    I wrote exmaple:

    // MSXMLPOSTStreamTest.cpp : Defines the entry point for the console application.
    
    //
    
    
    
    #include "stdafx.h"
    
    #import <msxml6.dll>
    
    
    
    class CInputStream: public IStream
    
    {
    
    public:
    
    	CInputStream() throw():
    
    		m_ulReferenceCount(0),
    
    		m_bAutoDelete(m_bOnHeap)
    
    	{
    
    	}
    
    
    
    	virtual ~CInputStream() throw()
    
    	{
    
    	}
    
    
    
    	static void *operator new(size_t nSize) throw()
    
    	{
    
    		m_bOnHeap = true;
    
    		
    
    		return ::operator new(nSize);
    
    	}
    
    
    
    	STDMETHOD(QueryInterface)(/* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
    
    	{
    
    		if (ppvObject == NULL){
    
    			return E_POINTER;
    
    		}
    
    
    
    		if ((riid == IID_IUnknown) || (riid == IID_ISequentialStream) || (riid == IID_IStream)){
    
    			*ppvObject = static_cast<LPSTREAM>(this);
    
    		}
    
    		else{
    
    			*ppvObject = NULL;
    
    
    
    			return E_NOINTERFACE;
    
    		}
    
    
    
    		reinterpret_cast<LPUNKNOWN>(*ppvObject)->AddRef();
    
    
    
    		return S_OK;
    
    	}
    
    
    
    	STDMETHOD_(ULONG, AddRef)()
    
    	{
    
    		return InterlockedIncrement(reinterpret_cast<PLONG>(&m_ulReferenceCount));
    
    	}
    
    
    
    	STDMETHOD_(ULONG, Release)()
    
    	{
    
    		ULONG ulReferenceCount = InterlockedDecrement(reinterpret_cast<PLONG>(&m_ulReferenceCount));
    
    		if ((ulReferenceCount == 0) && (m_bAutoDelete)){
    
    			delete this;
    
    		}
    
    
    
    		return ulReferenceCount;
    
    	}
    
    
    
    	STDMETHOD(Read)(/* [length_is][size_is][out] */ void *pv, /* [in] */ ULONG cb, /* [out] */ ULONG *pcbRead)
    
    	{
    
    		if (pcbRead != NULL){
    
    			*pcbRead = cb;
    
    		}
    
    
    
    		return S_OK;
    
    	}
    
    
    
    	STDMETHOD(Write)(/* [size_is][in] */ const void *pv, /* [in] */ ULONG cb, /* [out] */ ULONG *pcbWritten)
    
    	{
    
    		return E_NOTIMPL;
    
    	}
    
    
    
    	STDMETHOD(Seek)(/* [in] */ LARGE_INTEGER dlibMove, /* [in] */ DWORD dwOrigin, /* [out] */ ULARGE_INTEGER *plibNewPosition)
    
    	{
    
    		return E_NOTIMPL;
    
    	}
    
    
    
    	STDMETHOD(SetSize)(/* [in] */ ULARGE_INTEGER libNewSize)
    
    	{
    
    		return E_NOTIMPL;
    
    	}
    
    
    
    	STDMETHOD(CopyTo)(/* [unique][in] */ IStream *pstm, /* [in] */ ULARGE_INTEGER cb, /* [out] */ ULARGE_INTEGER *pcbRead, /* [out] */ ULARGE_INTEGER *pcbWritten)
    
    	{
    
    		return E_NOTIMPL;
    
    	}
    
    
    
    	STDMETHOD(Commit)(/* [in] */ DWORD grfCommitFlags)
    
    	{
    
    		return E_NOTIMPL;
    
    	}
    
    
    
    	STDMETHOD(Revert)()
    
    	{
    
    		return E_NOTIMPL;
    
    	}
    
    
    
    	STDMETHOD(LockRegion)(/* [in] */ ULARGE_INTEGER libOffset, /* [in] */ ULARGE_INTEGER cb, /* [in] */ DWORD dwLockType)
    
    	{
    
    		return E_NOTIMPL;
    
    	}
    
    
    
    	STDMETHOD(UnlockRegion)(/* [in] */ ULARGE_INTEGER libOffset, /* [in] */ ULARGE_INTEGER cb, /* [in] */ DWORD dwLockType)
    
    	{
    
    		return E_NOTIMPL;
    
    	}
    
    
    
    	STDMETHOD(Stat)(/* [out] */ STATSTG *pstatstg, /* [in] */ DWORD grfStatFlag)
    
    	{
    
    		return E_NOTIMPL;
    
    	}
    
    
    
    	STDMETHOD(Clone)(/* [out] */ IStream **ppstm)
    
    	{
    
    		return E_NOTIMPL;
    
    	}
    
    
    
    private:
    
    	CInputStream(const CInputStream& isStream) throw();
    
    	CInputStream& operator =(const CInputStream& isStream) throw();
    
    
    
    	ULONG m_ulReferenceCount;
    
    	bool m_bAutoDelete;
    
    	static __declspec(thread) bool m_bOnHeap;
    
    };
    
    __declspec(thread) bool CInputStream::m_bOnHeap = false;
    
    
    
    int _tmain(int argc, _TCHAR* argv[])
    
    {
    
    	TCHAR pszURL[1024];
    
    	_tprintf_s(_T("Enter a URL: "));
    
    	_getts_s(pszURL, sizeof(pszURL) / sizeof(pszURL[0]));
    
    
    
    	CoInitialize(NULL);
    
    
    
    	try{
    
    		MSXML2::IServerXMLHTTPRequest2Ptr pRequest(__uuidof(MSXML2::ServerXMLHTTP60));
    
    		if (pRequest == NULL){
    
    			_ftprintf_s(stderr, _T("Error: Can't create MSXML2::ServerXMLHTTP60.\r\n"));
    
    
    
    			CoUninitialize();
    
    
    
    			return 1;
    
    		}
    
    
    
    		pRequest->open(_T("POST"), pszURL, VARIANT_FALSE);
    
    		pRequest->setRequestHeader(_T("Content-Type"), _T("application/octet-stream"));
    
    
    
    		pRequest->send(_variant_t(static_cast<LPUNKNOWN>(IStreamPtr(new CInputStream()))));
    
    	}
    
    	catch (const _com_error& e){
    
    		_ftprintf_s(stderr, _T("Error: %s\r\n"), ((e.Description().length() == 0) ? e.ErrorMessage() : static_cast<LPCTSTR>(e.Description())));
    
    
    
    		CoUninitialize();
    
    
    
    		return 1;
    
    	}
    
    
    
    	CoUninitialize();
    
    
    
    	return 0;
    
    }
    
    
    
    

    It must work infinity, but it doesn't.

    The problem is that MSXML doubles output buffer on each call of IStream::Read. Is there any workaround?

    • Перемещено Tagore Bandlamudi 2 октября 2010 г. 21:44 MSDN Forums consolidation (От:Разработка Windows-приложений)