// FaxFinderCplus.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#using "System.dll"

using namespace System;
using namespace System::Net;
using namespace System::IO;
using namespace std;


int main()
{

	
	WebRequest ^ myRequest = WebRequest::Create("http://216.133.69.247/ffws/v1/ofax");
	NetworkCredential ^ myCredential = gcnew NetworkCredential("admin","admin");
	myRequest->Credentials = myCredential;

	myRequest ->Method = "POST";

	myRequest ->ContentType ="application/pdf";

	//Get the stream so that we can write data to it.
	Stream ^ dataStream = myRequest->GetRequestStream();


    //Open file
	ifstream textIn("D:\\Users\\windows7-32bit\\Documents\\Visual Studio 2008\\Projects\\FaxFinderCplus\\FaxFinderCplus\\schedule.xml");

	char byte_data;
	while(!textIn.eof())
	{
        //Write to a variable.
		textIn >> byte_data;
         //Write the data to the request stream.
		dataStream->WriteByte(byte_data);
	}
	//Close the file.
	textIn.close();
    // Close the Stream object.
	dataStream->Close();


    //Get the response stream
	WebResponse ^  myResponse = myRequest ->GetResponse();

	Stream ^ data = myResponse->GetResponseStream();

	StreamReader^ reader = gcnew StreamReader(data);

	String ^ responseFromServer = reader->ReadToEnd();

	Console::WriteLine(responseFromServer);

	reader->Close();
	data->Close();
	myResponse->Close();
	
	
}

