내 코드는 공급 업체가 제공하는 작은 Java 응용 프로그램과 통신합니다. 이 Java 응용 프로그램은 'machine'의 상태를 제어하는 데 사용되는 localhost : 57000에 웹 서버를 설정합니다. 이 질문의 목적을 위해 나는 '기계'의 상태를 '꺼짐'에서 '켜짐'으로 변경해야합니다. 이것이 내가 http://localhost:57000/settings.xml에서 다음 문자열로 '기계'PUT HTTP로되어있어 일어날 수 있도록 :왜 MFC :: CHttpFile 'PUT'을 사용하지 않습니까?
<settings><machine_state><status>on</status></machine_state></settings>
이 컬을 명령하는 것은 완벽하게 작동합니다 :
컬 -X PUT -H "콘텐츠 유형을 : 로컬 파일 'Settings.XML의이'그 위의 XML 문자열.
나는 컬이 MFC의 WININET 클래스와 무엇을하고 있는지 싶지있다
"http://localhost:57000/settings.xml Settings.XML의 -d @"응용 프로그램/XML. 다음 코드는 IMHO가 정확히 동일한 t를 수행해야합니다. 컬이하는 힌지. 안타깝게도 localhost 웹 서버가 코드 200을 반환하더라도 내 xml 문자열은 무시됩니다. 내가 바라는게 뭐야?
int MyHttp::HttpPutThread() NOTHROW
{
try {
m_xml = "<settings><machine_state><status>on</status></machine_state></settings>";
m_url = "settings.xml"
CInternetSession session;
SetSessionOptions(session);
CString server = "localhost:57920";
boost::scoped_ptr<CHttpConnection> phttp(session.GetHttpConnection(server));
LPCTSTR accept = 0;//"text/xml";
boost::scoped_ptr<CHttpFile> phttpfile(phttp->OpenRequest(
"PUT", //verb
"settings.xml", //object name
0, //referer
1, //context
&accept, // accept types
0, //version
INTERNET_FLAG_EXISTING_CONNECT));
CString header = "Content-Type:application/xml\r\n";
if(phttpfile->SendRequest(header,(LPVOID)m_xml.GetBuffer(), m_xml.GetLength()))
{ // LOG_DEBUG (Same as TRACE) output are shown in comment
DWORD code(0);
phttpfile->QueryInfoStatusCode(code);
LOG_DEBUG("HttpPutThread result code: %d", code); // '200'
CString object = phttpfile->GetObject();
LOG_DEBUG("object: %s", object); // 'settings.xml'
CString statustxt;
phttpfile->QueryInfo(HTTP_QUERY_STATUS_TEXT,statustxt);
LOG_DEBUG("status text:%s", statustxt); // 'HTTP/1.0 200 OK'
CString rawheaders;
phttpfile->QueryInfo(HTTP_QUERY_RAW_HEADERS,rawheaders);
LOG_DEBUG("raw headers:%s", rawheaders); // http://localhost:57000/settings.xml
LOG_DEBUG("File url:%s",phttpfile->GetFileURL());
LOG_DEBUG("Verb:%s", phttpfile->GetVerb()); // 'PUT'
} else
{
//This does not happen
LOG_DEBUG("PUT failed in AffHttp::HttpPutThread");
}
} catch(CInternetException* pe)
{
//No exceptions are thrown
LOG_DEBUG("Exception HttpPutThread:%d", pe->m_dwError);
pe->Delete();
}
return 0;
}
미리 감사드립니다.