version 1.9, 2009/02/20 19:32:43
|
version 1.10, 2009/11/30 16:49:50
|
|
|
//out << '\n'; | //out << '\n'; |
} | } |
| |
|
// Append something like this to buffer: "<class:" |
|
static inline void _appendStartPrefix(Buffer& out, const char* ns) |
|
{ |
|
out.append('<'); |
|
out.append(ns, strlen(ns)); |
|
out.append(':'); |
|
} |
|
|
|
// Append something like this to buffer: "</class:" |
|
static inline void _appendEndPrefix(Buffer& out, const char* ns) |
|
{ |
|
out.append('<'); |
|
out.append('/'); |
|
out.append(ns, strlen(ns)); |
|
out.append(':'); |
|
} |
|
|
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- |
// | // |
// WsmWriter::formatHttpErrorRspMessage() | // WsmWriter::formatHttpErrorRspMessage() |
|
|
| |
void WsmWriter::appendInstanceElement( | void WsmWriter::appendInstanceElement( |
Buffer& out, | Buffer& out, |
|
const String& resourceUri, |
WsmInstance& instance, | WsmInstance& instance, |
|
const char* ns, |
Boolean isEmbedded) | Boolean isEmbedded) |
{ | { |
|
size_t nsLength = strlen(ns); |
|
|
// Class opening element: | // Class opening element: |
out << STRLIT("<class:") << instance.getClassName(); |
_appendStartPrefix(out, ns); |
out << STRLIT(" xmlns:class=\""); |
out << instance.getClassName(); |
out << WsmNamespaces::supportedNamespaces[WsmNamespaces::WS_CIM_SCHEMA]. |
out << STRLIT(" xmlns:"); |
extendedName; |
out.append(ns, nsLength); |
|
out << STRLIT("=\""); |
|
out << WsmUtils::getRootResourceUri(resourceUri); |
out << STRLIT("/") << instance.getClassName(); | out << STRLIT("/") << instance.getClassName(); |
out << STRLIT("\""); | out << STRLIT("\""); |
| |
|
|
| |
// Properties: | // Properties: |
for (Uint32 i = 0, n = instance.getPropertyCount(); i < n; i++) | for (Uint32 i = 0, n = instance.getPropertyCount(); i < n; i++) |
appendPropertyElement(out, instance.getProperty(i)); |
appendPropertyElement(out, resourceUri, instance.getProperty(i), ns); |
| |
// Class closing element: | // Class closing element: |
out << STRLIT("</class:") << instance.getClassName() << STRLIT(">"); |
_appendEndPrefix(out, ns); |
|
out << instance.getClassName() << STRLIT(">"); |
_writeNewlineForReadability(out); | _writeNewlineForReadability(out); |
} | } |
| |
void WsmWriter::appendPropertyElement( | void WsmWriter::appendPropertyElement( |
Buffer& out, | Buffer& out, |
WsmProperty& property) |
const String& resourceUri, |
|
WsmProperty& property, |
|
const char* ns) |
{ | { |
WsmValue val = property.getValue(); | WsmValue val = property.getValue(); |
String propName = property.getName(); | String propName = property.getName(); |
| |
|
// Form start element prefix. For example: "<class:" |
|
Buffer startBuffer; |
|
_appendStartPrefix(startBuffer, ns); |
|
StrLit start(startBuffer.getData(), startBuffer.size()); |
|
|
|
// Form end element prefix. For example: "</class:" |
|
Buffer endBuffer; |
|
_appendEndPrefix(endBuffer, ns); |
|
StrLit end(endBuffer.getData(), endBuffer.size()); |
|
|
if (val.isNull()) | if (val.isNull()) |
{ | { |
out << STRLIT("<class:") << propName; |
out << start << propName; |
out << " " << WsmNamespaces::supportedNamespaces[ | out << " " << WsmNamespaces::supportedNamespaces[ |
WsmNamespaces::XML_SCHEMA_INSTANCE].localName; | WsmNamespaces::XML_SCHEMA_INSTANCE].localName; |
out << STRLIT(":nil=\"true\"/>"); | out << STRLIT(":nil=\"true\"/>"); |
|
|
val.get(eprs); | val.get(eprs); |
for (Uint32 i = 0, n = eprs.size(); i < n; i++) | for (Uint32 i = 0, n = eprs.size(); i < n; i++) |
{ | { |
out << STRLIT("<class:") << propName << STRLIT(">"); |
out << start << propName << STRLIT(">"); |
_writeNewlineForReadability(out); | _writeNewlineForReadability(out); |
appendEPRElement(out, eprs[i]); | appendEPRElement(out, eprs[i]); |
out << STRLIT("</class:") << propName << STRLIT(">"); |
out << end << propName << STRLIT(">"); |
_writeNewlineForReadability(out); | _writeNewlineForReadability(out); |
} | } |
break; | break; |
|
|
val.get(instances); | val.get(instances); |
for (Uint32 i = 0, n = instances.size(); i < n; i++) | for (Uint32 i = 0, n = instances.size(); i < n; i++) |
{ | { |
out << STRLIT("<class:") << propName << STRLIT(">"); |
out << start << propName << STRLIT(">"); |
_writeNewlineForReadability(out); | _writeNewlineForReadability(out); |
appendInstanceElement(out, instances[i], true); |
appendInstanceElement(out, resourceUri, instances[i], |
out << STRLIT("</class:") << propName << STRLIT(">"); |
PEGASUS_INSTANCE_NS, true); |
|
out << end << propName << STRLIT(">"); |
_writeNewlineForReadability(out); | _writeNewlineForReadability(out); |
} | } |
break; | break; |
|
|
val.get(strs); | val.get(strs); |
for (Uint32 i = 0, n = strs.size(); i < n; i++) | for (Uint32 i = 0, n = strs.size(); i < n; i++) |
{ | { |
out << STRLIT("<class:") << propName << STRLIT(">"); |
out << start << propName << STRLIT(">"); |
_writeNewlineForReadability(out); | _writeNewlineForReadability(out); |
appendStringElement(out, strs[i]); | appendStringElement(out, strs[i]); |
out << STRLIT("</class:") << propName << STRLIT(">"); |
out << end << propName << STRLIT(">"); |
_writeNewlineForReadability(out); | _writeNewlineForReadability(out); |
} | } |
break; | break; |
|
|
{ | { |
WsmEndpointReference epr; | WsmEndpointReference epr; |
val.get(epr); | val.get(epr); |
out << STRLIT("<class:") << propName << STRLIT(">"); |
out << start << propName << STRLIT(">"); |
_writeNewlineForReadability(out); | _writeNewlineForReadability(out); |
appendEPRElement(out, epr); | appendEPRElement(out, epr); |
out << STRLIT("</class:") << propName << STRLIT(">"); |
out << end << propName << STRLIT(">"); |
_writeNewlineForReadability(out); | _writeNewlineForReadability(out); |
break; | break; |
} | } |
|
|
{ | { |
WsmInstance instance; | WsmInstance instance; |
val.get(instance); | val.get(instance); |
out << STRLIT("<class:") << propName << STRLIT(">"); |
out << start << propName << STRLIT(">"); |
_writeNewlineForReadability(out); | _writeNewlineForReadability(out); |
appendInstanceElement(out, instance, true); |
appendInstanceElement(out, resourceUri, instance, |
out << STRLIT("</class:") << propName << STRLIT(">"); |
PEGASUS_INSTANCE_NS, true); |
|
out << end << propName << STRLIT(">"); |
_writeNewlineForReadability(out); | _writeNewlineForReadability(out); |
break; | break; |
} | } |
|
|
{ | { |
String str; | String str; |
val.get(str); | val.get(str); |
out << STRLIT("<class:") << propName << STRLIT(">"); |
out << start << propName << STRLIT(">"); |
_writeNewlineForReadability(out); | _writeNewlineForReadability(out); |
appendStringElement(out, str); | appendStringElement(out, str); |
out << STRLIT("</class:") << propName << STRLIT(">"); |
out << end << propName << STRLIT(">"); |
_writeNewlineForReadability(out); | _writeNewlineForReadability(out); |
break; | break; |
} | } |
|
|
Buffer& out, | Buffer& out, |
const String& action, | const String& action, |
HttpMethod httpMethod, | HttpMethod httpMethod, |
|
Boolean omitXMLProcessingInstruction, |
const ContentLanguageList& contentLanguages, | const ContentLanguageList& contentLanguages, |
Boolean isFault, | Boolean isFault, |
Uint32 contentLength) | Uint32 contentLength) |
|
|
} | } |
out << STRLIT("\r\n"); | out << STRLIT("\r\n"); |
| |
|
if (!omitXMLProcessingInstruction) |
|
{ |
out << STRLIT("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); | out << STRLIT("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); |
|
} |
|
|
_writeNewlineForReadability(out); | _writeNewlineForReadability(out); |
} | } |
| |
|
|
appendTagValue( | appendTagValue( |
out, WsmNamespaces::WS_ADDRESSING, STRLIT("MessageID"), messageId); | out, WsmNamespaces::WS_ADDRESSING, STRLIT("MessageID"), messageId); |
| |
// Add <wsa:RelatesTo> entry |
// Add <wsa:RelatesTo> entry only if necessary. An empty relates to tag |
|
// breaks some WS-Management clients (such as WinRM). |
|
if (relatesTo.size()) |
|
{ |
appendTagValue( | appendTagValue( |
out, WsmNamespaces::WS_ADDRESSING, STRLIT("RelatesTo"), relatesTo); | out, WsmNamespaces::WS_ADDRESSING, STRLIT("RelatesTo"), relatesTo); |
} | } |
|
} |
|
|
|
void WsmWriter::appendInvokeOutputElement( |
|
Buffer& out, |
|
const String& resourceUri, |
|
const String& className, |
|
const String& methodName, |
|
WsmInstance& instance, |
|
const char* ns) |
|
{ |
|
CString mn(methodName.getCString()); |
|
|
|
// Form tagname. |
|
Buffer tagBuffer; |
|
tagBuffer.append(ns, strlen(ns)); |
|
tagBuffer.append(':'); |
|
tagBuffer.append(mn, strlen(mn)); |
|
tagBuffer.append("_OUTPUT", 7); |
|
const char* tag = tagBuffer.getData(); |
|
size_t tagSize = tagBuffer.size(); |
|
|
|
// Write start tag. |
|
out.append('<'); |
|
out.append(tag, tagSize); |
|
|
|
out << STRLIT(" xmlns:"); |
|
out.append(ns, strlen(ns)); |
|
out << STRLIT("=\""); |
|
out << WsmUtils::getRootResourceUri(resourceUri); |
|
out << STRLIT("/"); |
|
out << className; |
|
out << STRLIT("\">"); |
|
_writeNewlineForReadability(out); |
|
|
|
// Write properties: |
|
for (Uint32 i = 0, n = instance.getPropertyCount(); i < n; i++) |
|
appendPropertyElement(out, resourceUri, instance.getProperty(i), ns); |
|
|
|
// Write end tag. |
|
out << STRLIT("</"); |
|
out.append(tag, tagSize); |
|
out.append('>'); |
|
|
|
_writeNewlineForReadability(out); |
|
} |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |