a***@yahoo.ca
2005-08-24 02:30:41 UTC
I don’t have enough information to figure out how to use WinInet to
get off the ground with an integration server. Probably I just don’t
know enough to understand the documentation I’ve been given. I tried
the following code. By the end of the routine, strBuffer is "ERROR:
Invalid Command". No idea where I'm going wrong, but a few questions
include:
1. The integration server is located at
stage.binxfer.fujifilmesys.com/FileReceiveServer.aspx. Did I pass this
to GetHttpConnection correctly?
2. The FujiFilm docs say "Parameters may be sent to the server using
the query string, the HTTP header, or from the post." Did I choose the
right verb, or does it look like the "init" request should use
HTTP_VERB_GET?
3. The commands recognized by the server include the “init”
command which is used to initialize an upload. Upon successful
completion of this command, a valid BatchID and AlbumID are returned to
the client.
Request Type: init
Required Parameters: AppKey, UserID, AlbumCreateFlag
Optional Parameters: UserName, UserPassword
Return Parameters: BatchID, AlbumID, UserID, RedirectURL
So, is there any chance that I put together the right command in
strFormData?
4. The documentation wasn’t specific about a Content-Type. Do I get
to chose, or does this suggest that the documentation was incomplete?
5. I get back “ERROR: Invalid Command.” Did this string come back
from the fujifilm server? I get the same message if I plug in the
location of the integration server into Internet Explorer.
Thanks in advance,
- Ashok Thirumurthi
try
{
// uses the MFC WinInet classes to simulate a Form POST request:
CInternetSession session;
CHttpConnection* pConnection = session.GetHttpConnection( _T
("stage.binxfer.fujifilmesys.com/FileReceiveServer.aspx") );
if ( pConnection && m_pPrintService )
{
CHttpFile* pFile = pConnection->OpenRequest
(CHttpConnection::HTTP_VERB_POST);
if ( pFile )
{
CString strHeaders = _T ("Content-Type:
application/index-www-form-urlencoded");
CNkvResource strRes;
std::string str;
strRes.LoadString( NKVMAKERESOURCEID( NKID_APPKEY ), &str);
std::string sUserName;
m_pPrintService->GetUserName (sUserName);
std::string sPassword;
m_pPrintService->GetPassword (sPassword);
// URL-encoded form variables -
CString strFormData;
strFormData.Format ( _T
("RequestType=init&AppKey=%s&UserID=+UserName=%s&UserPassword=%s&AlbumCreateFlag=createalways"),
str.c_str (), sUserName.c_str (), sPassword.c_str () );
if ( pFile->SendRequest (strHeaders, (LPVOID)(LPCTSTR)strFormData,
strFormData.GetLength ()) == TRUE )
{
DWORD dwReturn;
pFile->QueryInfoStatusCode (dwReturn);
if ( dwReturn == HTTP_STATUS_OK )
{
char szBuffer [1024];
UINT nRead = pFile->Read (szBuffer, 1023);
CString strBuffer = szBuffer;
if ( strBuffer.Find ("ERROR") >= 0 )
{
// strBuffer is "ERROR: Invalid Command"
}
}
}
delete pFile;
pFile = 0;
}
delete pConnection; // TODO: Persist the session and connection
until the files are uploaded
pConnection = 0;
}
}
catch ( CInternetException * e )
{
if ( e )
{
e->ReportError ();
}
}
get off the ground with an integration server. Probably I just don’t
know enough to understand the documentation I’ve been given. I tried
the following code. By the end of the routine, strBuffer is "ERROR:
Invalid Command". No idea where I'm going wrong, but a few questions
include:
1. The integration server is located at
stage.binxfer.fujifilmesys.com/FileReceiveServer.aspx. Did I pass this
to GetHttpConnection correctly?
2. The FujiFilm docs say "Parameters may be sent to the server using
the query string, the HTTP header, or from the post." Did I choose the
right verb, or does it look like the "init" request should use
HTTP_VERB_GET?
3. The commands recognized by the server include the “init”
command which is used to initialize an upload. Upon successful
completion of this command, a valid BatchID and AlbumID are returned to
the client.
Request Type: init
Required Parameters: AppKey, UserID, AlbumCreateFlag
Optional Parameters: UserName, UserPassword
Return Parameters: BatchID, AlbumID, UserID, RedirectURL
So, is there any chance that I put together the right command in
strFormData?
4. The documentation wasn’t specific about a Content-Type. Do I get
to chose, or does this suggest that the documentation was incomplete?
5. I get back “ERROR: Invalid Command.” Did this string come back
from the fujifilm server? I get the same message if I plug in the
location of the integration server into Internet Explorer.
Thanks in advance,
- Ashok Thirumurthi
try
{
// uses the MFC WinInet classes to simulate a Form POST request:
CInternetSession session;
CHttpConnection* pConnection = session.GetHttpConnection( _T
("stage.binxfer.fujifilmesys.com/FileReceiveServer.aspx") );
if ( pConnection && m_pPrintService )
{
CHttpFile* pFile = pConnection->OpenRequest
(CHttpConnection::HTTP_VERB_POST);
if ( pFile )
{
CString strHeaders = _T ("Content-Type:
application/index-www-form-urlencoded");
CNkvResource strRes;
std::string str;
strRes.LoadString( NKVMAKERESOURCEID( NKID_APPKEY ), &str);
std::string sUserName;
m_pPrintService->GetUserName (sUserName);
std::string sPassword;
m_pPrintService->GetPassword (sPassword);
// URL-encoded form variables -
CString strFormData;
strFormData.Format ( _T
("RequestType=init&AppKey=%s&UserID=+UserName=%s&UserPassword=%s&AlbumCreateFlag=createalways"),
str.c_str (), sUserName.c_str (), sPassword.c_str () );
if ( pFile->SendRequest (strHeaders, (LPVOID)(LPCTSTR)strFormData,
strFormData.GetLength ()) == TRUE )
{
DWORD dwReturn;
pFile->QueryInfoStatusCode (dwReturn);
if ( dwReturn == HTTP_STATUS_OK )
{
char szBuffer [1024];
UINT nRead = pFile->Read (szBuffer, 1023);
CString strBuffer = szBuffer;
if ( strBuffer.Find ("ERROR") >= 0 )
{
// strBuffer is "ERROR: Invalid Command"
}
}
}
delete pFile;
pFile = 0;
}
delete pConnection; // TODO: Persist the session and connection
until the files are uploaded
pConnection = 0;
}
}
catch ( CInternetException * e )
{
if ( e )
{
e->ReportError ();
}
}