version 1.80, 2002/09/13 21:40:42
|
version 1.83, 2002/11/14 16:50:33
|
|
|
const CIMName& cimMethod, | const CIMName& cimMethod, |
const String& cimObject, | const String& cimObject, |
const String& authenticationHeader, | const String& authenticationHeader, |
|
HttpMethod httpMethod, |
Uint32 contentLength) | Uint32 contentLength) |
{ | { |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; | char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
| |
|
// ATTN: KS 20020926 - Temporary change to issue only POST. This may |
|
// be changed in the DMTF CIM Operations standard in the future. |
|
// If we kept M-Post we would have to retry with Post. Does not |
|
// do that in client today. Permanent change is to retry until spec |
|
// updated. This change is temp to finish tests or until the retry |
|
// installed. Required because of change to wbemservices cimom |
|
#ifdef PEGASUS_SNIA_INTEROP_TEST |
|
out << "POST /cimom HTTP/1.1\r\n"; |
|
#else |
|
if (httpMethod == HTTP_METHOD_M_POST) |
|
{ |
out << "M-POST /cimom HTTP/1.1\r\n"; | out << "M-POST /cimom HTTP/1.1\r\n"; |
|
} |
|
else |
|
{ |
|
out << "POST /cimom HTTP/1.1\r\n"; |
|
} |
|
#endif |
out << "HOST: " << host << "\r\n"; | out << "HOST: " << host << "\r\n"; |
out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; | out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; |
out << "Content-Length: " << contentLength << "\r\n"; | out << "Content-Length: " << contentLength << "\r\n"; |
|
if (httpMethod == HTTP_METHOD_M_POST) |
|
{ |
out << "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="; | out << "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="; |
out << nn <<"\r\n"; | out << nn <<"\r\n"; |
out << nn << "-CIMOperation: MethodCall\r\n"; | out << nn << "-CIMOperation: MethodCall\r\n"; |
out << nn << "-CIMMethod: " << cimMethod << "\r\n"; | out << nn << "-CIMMethod: " << cimMethod << "\r\n"; |
out << nn << "-CIMObject: " << cimObject << "\r\n"; | out << nn << "-CIMObject: " << cimObject << "\r\n"; |
|
} |
|
else |
|
{ |
|
out << "CIMOperation: MethodCall\r\n"; |
|
out << "CIMMethod: " << cimMethod << "\r\n"; |
|
out << "CIMObject: " << cimObject << "\r\n"; |
|
} |
|
|
if (authenticationHeader.size()) | if (authenticationHeader.size()) |
{ | { |
out << authenticationHeader << "\r\n"; | out << authenticationHeader << "\r\n"; |
|
|
| |
void XmlWriter::appendMethodResponseHeader( | void XmlWriter::appendMethodResponseHeader( |
Array<Sint8>& out, | Array<Sint8>& out, |
|
HttpMethod httpMethod, |
Uint32 contentLength) | Uint32 contentLength) |
{ | { |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; | char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
|
|
STAT_SERVERTIME | STAT_SERVERTIME |
out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; | out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; |
out << "Content-Length: " << contentLength << "\r\n"; | out << "Content-Length: " << contentLength << "\r\n"; |
|
if (httpMethod == HTTP_METHOD_M_POST) |
|
{ |
out << "Ext:\r\n"; | out << "Ext:\r\n"; |
out << "Cache-Control: no-cache\r\n"; | out << "Cache-Control: no-cache\r\n"; |
out << "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="; | out << "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="; |
out << nn <<"\r\n"; | out << nn <<"\r\n"; |
out << nn << "-CIMOperation: MethodResponse\r\n\r\n"; | out << nn << "-CIMOperation: MethodResponse\r\n\r\n"; |
} | } |
|
else |
|
{ |
|
out << "CIMOperation: MethodResponse\r\n\r\n"; |
|
} |
|
} |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
|
const CIMName& className) | const CIMName& className) |
{ | { |
_appendIParamValueElementBegin(out, name); | _appendIParamValueElementBegin(out, name); |
|
|
|
// |
|
// A NULL (unassigned) value for a parameter is specified by an |
|
// <IPARAMVALUE> element with no subelement |
|
// |
|
if (!className.isNull ()) |
|
{ |
appendClassNameElement(out, className); | appendClassNameElement(out, className); |
|
} |
|
|
_appendIParamValueElementEnd(out); | _appendIParamValueElementEnd(out); |
} | } |
| |
|
|
Array<Sint8>& out, | Array<Sint8>& out, |
const CIMPropertyList& propertyList) | const CIMPropertyList& propertyList) |
{ | { |
// ATTN: P3 KS 4 Mar 2002 - As check shouldn't we check for null property list |
|
_appendIParamValueElementBegin(out, "PropertyList"); | _appendIParamValueElementBegin(out, "PropertyList"); |
| |
|
// |
|
// A NULL (unassigned) value for a parameter is specified by an |
|
// <IPARAMVALUE> element with no subelement |
|
// |
|
if (!propertyList.isNull ()) |
|
{ |
out << "<VALUE.ARRAY>\n"; | out << "<VALUE.ARRAY>\n"; |
for (Uint32 i = 0; i < propertyList.size(); i++) | for (Uint32 i = 0; i < propertyList.size(); i++) |
{ | { |
out << "<VALUE>" << propertyList[i] << "</VALUE>\n"; | out << "<VALUE>" << propertyList[i] << "</VALUE>\n"; |
} | } |
out << "</VALUE.ARRAY>\n"; | out << "</VALUE.ARRAY>\n"; |
|
} |
| |
_appendIParamValueElementEnd(out); | _appendIParamValueElementEnd(out); |
} | } |
|
|
const CIMName& methodName, | const CIMName& methodName, |
const Array<CIMParamValue>& parameters, | const Array<CIMParamValue>& parameters, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const String& authenticationHeader) | const String& authenticationHeader) |
{ | { |
Array<Sint8> out; | Array<Sint8> out; |
|
|
methodName, | methodName, |
localObjectPath.toString(), | localObjectPath.toString(), |
authenticationHeader, | authenticationHeader, |
|
httpMethod, |
out.size()); | out.size()); |
tmp << out; | tmp << out; |
| |
|
|
Array<Sint8> XmlWriter::formatSimpleMethodRspMessage( | Array<Sint8> XmlWriter::formatSimpleMethodRspMessage( |
const CIMName& methodName, | const CIMName& methodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const Array<Sint8>& body) | const Array<Sint8>& body) |
{ | { |
Array<Sint8> out; | Array<Sint8> out; |
|
|
_appendSimpleRspElementEnd(out); | _appendSimpleRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
appendMethodResponseHeader(tmp, out.size()); |
appendMethodResponseHeader(tmp, httpMethod, out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
Array<Sint8> XmlWriter::formatSimpleMethodErrorRspMessage( | Array<Sint8> XmlWriter::formatSimpleMethodErrorRspMessage( |
const CIMName& methodName, | const CIMName& methodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const CIMException& cimException) | const CIMException& cimException) |
{ | { |
Array<Sint8> out; | Array<Sint8> out; |
|
|
_appendSimpleRspElementEnd(out); | _appendSimpleRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
appendMethodResponseHeader(tmp, out.size()); |
appendMethodResponseHeader(tmp, httpMethod, out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
const CIMNamespaceName& nameSpace, | const CIMNamespaceName& nameSpace, |
const CIMName& iMethodName, | const CIMName& iMethodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const String& authenticationHeader, | const String& authenticationHeader, |
const Array<Sint8>& body) | const Array<Sint8>& body) |
{ | { |
|
|
iMethodName, | iMethodName, |
nameSpace.getString(), | nameSpace.getString(), |
authenticationHeader, | authenticationHeader, |
|
httpMethod, |
out.size()); | out.size()); |
tmp << out; | tmp << out; |
| |
|
|
Array<Sint8> XmlWriter::formatSimpleIMethodRspMessage( | Array<Sint8> XmlWriter::formatSimpleIMethodRspMessage( |
const CIMName& iMethodName, | const CIMName& iMethodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const Array<Sint8>& body) | const Array<Sint8>& body) |
{ | { |
Array<Sint8> out; | Array<Sint8> out; |
|
|
_appendSimpleRspElementEnd(out); | _appendSimpleRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
appendMethodResponseHeader(tmp, out.size()); |
appendMethodResponseHeader(tmp, httpMethod, out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
Array<Sint8> XmlWriter::formatSimpleIMethodErrorRspMessage( | Array<Sint8> XmlWriter::formatSimpleIMethodErrorRspMessage( |
const CIMName& iMethodName, | const CIMName& iMethodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const CIMException& cimException) | const CIMException& cimException) |
{ | { |
Array<Sint8> out; | Array<Sint8> out; |
|
|
_appendSimpleRspElementEnd(out); | _appendSimpleRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
appendMethodResponseHeader(tmp, out.size()); |
appendMethodResponseHeader(tmp, httpMethod, out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
const char* requestUri, | const char* requestUri, |
const char* host, | const char* host, |
const CIMName& cimMethod, | const CIMName& cimMethod, |
|
HttpMethod httpMethod, |
const String& authenticationHeader, | const String& authenticationHeader, |
Uint32 contentLength) | Uint32 contentLength) |
{ | { |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; | char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
| |
|
if (httpMethod == HTTP_METHOD_M_POST) |
|
{ |
out << "M-POST " << requestUri << " HTTP/1.1\r\n"; | out << "M-POST " << requestUri << " HTTP/1.1\r\n"; |
|
} |
|
else |
|
{ |
|
out << "POST " << requestUri << " HTTP/1.1\r\n"; |
|
} |
out << "HOST: " << host << "\r\n"; | out << "HOST: " << host << "\r\n"; |
out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; | out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; |
out << "Content-Length: " << contentLength << "\r\n"; | out << "Content-Length: " << contentLength << "\r\n"; |
|
if (httpMethod == HTTP_METHOD_M_POST) |
|
{ |
out << "Man: http://www.hp.com; ns="; | out << "Man: http://www.hp.com; ns="; |
out << nn <<"\r\n"; | out << nn <<"\r\n"; |
out << nn << "-CIMExport: MethodRequest\r\n"; | out << nn << "-CIMExport: MethodRequest\r\n"; |
out << nn << "-CIMExportMethod: " << cimMethod << "\r\n"; | out << nn << "-CIMExportMethod: " << cimMethod << "\r\n"; |
|
} |
|
else |
|
{ |
|
out << "CIMExport: MethodRequest\r\n"; |
|
out << "CIMExportMethod: " << cimMethod << "\r\n"; |
|
} |
|
|
if (authenticationHeader.size()) | if (authenticationHeader.size()) |
{ | { |
out << authenticationHeader << "\r\n"; | out << authenticationHeader << "\r\n"; |
|
|
| |
void XmlWriter::appendEMethodResponseHeader( | void XmlWriter::appendEMethodResponseHeader( |
Array<Sint8>& out, | Array<Sint8>& out, |
|
HttpMethod httpMethod, |
Uint32 contentLength) | Uint32 contentLength) |
{ | { |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; | char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
|
|
out << "HTTP/1.1 " HTTP_STATUS_OK "\r\n"; | out << "HTTP/1.1 " HTTP_STATUS_OK "\r\n"; |
out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; | out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; |
out << "Content-Length: " << contentLength << "\r\n"; | out << "Content-Length: " << contentLength << "\r\n"; |
|
if (httpMethod == HTTP_METHOD_M_POST) |
|
{ |
out << "Ext:\r\n"; | out << "Ext:\r\n"; |
out << "Cache-Control: no-cache\r\n"; | out << "Cache-Control: no-cache\r\n"; |
out << "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="; | out << "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="; |
out << nn <<"\r\n"; | out << nn <<"\r\n"; |
out << nn << "-CIMExport: MethodResponse\r\n\r\n"; | out << nn << "-CIMExport: MethodResponse\r\n\r\n"; |
} | } |
|
else |
|
{ |
|
out << "CIMExport: MethodResponse\r\n\r\n"; |
|
} |
|
} |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
|
const char* host, | const char* host, |
const CIMName& eMethodName, | const CIMName& eMethodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const String& authenticationHeader, | const String& authenticationHeader, |
const Array<Sint8>& body) | const Array<Sint8>& body) |
{ | { |
|
|
requestUri, | requestUri, |
host, | host, |
eMethodName, | eMethodName, |
|
httpMethod, |
authenticationHeader, | authenticationHeader, |
out.size()); | out.size()); |
tmp << out; | tmp << out; |
|
|
Array<Sint8> XmlWriter::formatSimpleEMethodRspMessage( | Array<Sint8> XmlWriter::formatSimpleEMethodRspMessage( |
const CIMName& eMethodName, | const CIMName& eMethodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const Array<Sint8>& body) | const Array<Sint8>& body) |
{ | { |
Array<Sint8> out; | Array<Sint8> out; |
|
|
_appendSimpleExportRspElementEnd(out); | _appendSimpleExportRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
appendEMethodResponseHeader(tmp, out.size()); |
appendEMethodResponseHeader(tmp, httpMethod, out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
Array<Sint8> XmlWriter::formatSimpleEMethodErrorRspMessage( | Array<Sint8> XmlWriter::formatSimpleEMethodErrorRspMessage( |
const CIMName& eMethodName, | const CIMName& eMethodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const CIMException& cimException) | const CIMException& cimException) |
{ | { |
Array<Sint8> out; | Array<Sint8> out; |
|
|
_appendSimpleExportRspElementEnd(out); | _appendSimpleExportRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
appendEMethodResponseHeader(tmp, out.size()); |
appendEMethodResponseHeader(tmp, httpMethod, out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |