예제 #1
0
SoapResponse* WsmResponseEncoder::encodeWsenEnumerateResponse(
    WsenEnumerateResponse* response,
    Uint32& numDataItemsEncoded)
{
    AutoPtr<SoapResponse> soapResponse(new SoapResponse(response));
    Buffer headers;

    if (response->requestedItemCount())
    {
        WsmWriter::appendStartTag(
            headers, WsmNamespaces::WS_MAN, STRLIT("TotalItemsCountEstimate"));
        WsmWriter::append(headers, response->getItemCount());
        WsmWriter::appendEndTag(
            headers, WsmNamespaces::WS_MAN, STRLIT("TotalItemsCountEstimate"));
    }

    if (!_encodeEnumerationData(
            *soapResponse.get(),
            headers,
            WS_ENUMERATION_ENUMERATE,
            response->getEnumerationContext(),
            response->isComplete(),
            response->getEnumerationData(),
            numDataItemsEncoded,
            response->getResourceUri()))
    {
        soapResponse.reset(_buildEncodingLimitFault(response));
    }

    return soapResponse.release();
}
예제 #2
0
SoapResponse* WsmResponseEncoder::_encodeWsenEnumerateResponse(
    WsenEnumerateResponse* response)
{
    SoapResponse* soapResponse = new SoapResponse(response);
    Buffer headers;

    if (response->requestedItemCount())
    {
        WsmWriter::appendStartTag(
            headers, WsmNamespaces::WS_MAN, STRLIT("TotalItemsCountEstimate"));
        WsmWriter::append(headers, response->getItemCount());
        WsmWriter::appendEndTag(
            headers, WsmNamespaces::WS_MAN, STRLIT("TotalItemsCountEstimate"));
    }

    if (!_encodeEnumerationData(
            *soapResponse, 
            headers, 
            WS_ENUMERATION_ENUMERATE,
            response->getEnumerationContext(),
            response->isComplete(),
            response->getEnumerationData(),
            response->getResourceUri()))
    {
        delete soapResponse;
        return _encodeEncodingLimitFault(response);
    }

    return soapResponse;
}
 /* purecov: begin deadcode */
char *dbg_node_address(node_address n)
{
  GET_NEW_GOUT;
  STRLIT("node_address ");
  PTREXP(n.address);
  STRLIT(n.address);
  STRLIT(" ");
  RET_GOUT;
}
void SCMOInternalXmlEncoder::_appendValueReferenceElement(
    Buffer& out,
    const SCMOInstance& ref)
{
    out << STRLIT("<VALUE.REFERENCE>\n");

    SCMOXmlWriter::appendInstanceNameElement(out, ref);

    out << STRLIT("</VALUE.REFERENCE>\n");
}
예제 #5
0
SoapResponse* WsmResponseEncoder::_encodeWxfPutResponse(
    WxfPutResponse* response)
{
    SoapResponse* soapResponse = new SoapResponse(response);
    Buffer headers;

    // DSP0226 R6.5-1:  A service receiving a message that contains the
    // wsman:RequestEPR header block should return a response that contains
    // a wsman:RequestedEPR header block.  This block contains the most recent
    // EPR of the resource being accessed or a status code if the service
    // cannot determine or return the EPR.  This EPR reflects any identity
    // changes that may have occurred as a result of the current operation, as
    // set forth in the following behavior.  The header block in the
    // corresponding response message has the following format:
    //     <wsman:RequestedEPR...>
    //       [ <wsa:EndpointReference>
    //          wsa:EndpointReferenceType
    //       </wsa:EndpointReference> |
    //       <wsman:EPRInvalid/> |
    //       <wsman:EPRUnknown/> ]
    //     </wsman:RequestedEPR>
    if (response->getRequestedEPR())
    {
        WsmWriter::appendStartTag(
            headers, WsmNamespaces::WS_MAN, STRLIT("RequestedEPR"));
        WsmWriter::appendStartTag(
            headers, 
            WsmNamespaces::WS_ADDRESSING, STRLIT("EndpointReference"));
        WsmWriter::appendEPRElement(headers, response->getEPR());
        WsmWriter::appendEndTag(
            headers, 
            WsmNamespaces::WS_ADDRESSING, STRLIT("EndpointReference"));
        WsmWriter::appendEndTag(
            headers, WsmNamespaces::WS_MAN, STRLIT("RequestedEPR"));
    }

    if (soapResponse->appendHeader(headers))
    {
        return soapResponse;
    }
    else
    {
        delete soapResponse;
        return _encodeUnreportableSuccess(response);
    }
}
예제 #6
0
void WsmResponseEncoder::_encodeWxfCreateResponse(WxfCreateResponse* response)
{
    SoapResponse soapResponse(response);
    Buffer body;

    WsmWriter::appendStartTag(
        body, WsmNamespaces::WS_TRANSFER, STRLIT("ResourceCreated"));
    WsmWriter::appendEPRElement(body, response->getEPR());
    WsmWriter::appendEndTag(
        body, WsmNamespaces::WS_TRANSFER, STRLIT("ResourceCreated"));

    if (soapResponse.appendBodyContent(body))
    {
        _sendResponse(&soapResponse);
    }
    else
    {
        _sendUnreportableSuccess(response);
    }
}
예제 #7
0
SoapResponse* WsmResponseEncoder::_encodeWxfCreateResponse(
    WxfCreateResponse* response)
{
    SoapResponse* soapResponse = new SoapResponse(response);
    Buffer body;

    WsmWriter::appendStartTag(
        body, WsmNamespaces::WS_TRANSFER, STRLIT("ResourceCreated"));
    WsmWriter::appendEPRElement(body, response->getEPR());
    WsmWriter::appendEndTag(
        body, WsmNamespaces::WS_TRANSFER, STRLIT("ResourceCreated"));

    if (soapResponse->appendBodyContent(body))
    {
        return soapResponse;
    }
    else
    {
        delete soapResponse;
        return _encodeUnreportableSuccess(response);
    }
}
예제 #8
0
static void task_queue_debug(task_queue *q)
{
	int	i;
	GET_GOUT;
	STRLIT("task_queue_debug ");
	for (i = 1; i <= q->curn; i++) {
		NDBG(i, d);
		PTREXP(q->x[i]);
		STREXP(q->x[i]->name);
		NDBG(q->x[i]->heap_pos, d);
		NDBG(q->x[i]->terminate, d);
		NDBG(q->x[i]->time, f);
	}
  PRINT_GOUT;
  FREE_GOUT;
}
예제 #9
0
/* Basic operations on tasks */
static task_env *activate(task_env *t)
{
	if (t) {
		MAY_DBG(FN;
		    STRLIT("activating task ");
		    PTREXP(t);
		    STREXP(t->name);
		    NDBG(t->heap_pos, d);
		    NDBG(t->time, f);
		    );
		assert(ash_nazg_gimbatul.type == type_hash("task_env"));
		if (t->heap_pos)
			task_queue_remove(&task_time_q, t->heap_pos);
		link_into(&t->l, &tasks);
		t->time = 0.0;
		t->heap_pos = 0;
		assert(ash_nazg_gimbatul.type == type_hash("task_env"));
	}
예제 #10
0
static void _checkInstance(WsmInstance& inst, const char* text)
{
    Buffer out;
    _appendSoapEnvelopeStart(out);
    WsmWriter::appendInstanceElement(out, WSM_RESOURCEURI_CIMSCHEMAV2, inst,
        PEGASUS_INSTANCE_NS, false);
    WsmWriter::appendEndTag(
        out, WsmNamespaces::SOAP_ENVELOPE, STRLIT("Envelope"));

    WsmInstance inst1;
    XmlEntry entry;
    WsmReader reader((char*)out.getData());
    reader.expectStartTag(entry, WsmNamespaces::SOAP_ENVELOPE, "Envelope");
    reader.getInstanceElement(inst1);
    reader.expectEndTag(WsmNamespaces::SOAP_ENVELOPE, "Envelope");
    if (!_compareInstances(inst, inst1))
        throw Exception(text);
}
예제 #11
0
/* Remove any element from the heap */
static task_env *task_queue_remove(task_queue *q, int i)
{
	task_env * tmp = q->x[i]; /* Will return this */
	assert(q->curn);
	/* assert(is_heap(q)); */
	MAY_DBG(FN; STRLIT("task_queue_remove "); NDBG(i, d));
	/* task_queue_debug(q); */
	TASK_MOVE(i, q->curn); /* Fill the hole */
	q->curn--; /* Heap is now smaller */
	/* Re-establish heap property */
	if (q->curn) {
		int	p = i / 2;
		if (p && q->x[p]->time > q->x[i]->time)
			task_queue_siftup(q, i);
		else
			task_queue_siftdown(q, i, q->curn);
	}
	/* task_queue_debug(q); */
	/* assert(is_heap(q)); */
	tmp->heap_pos = 0;
	return task_unref(tmp);
}
예제 #12
0
static void _appendSoapEnvelopeStart(Buffer& out)
{
    out << STRLIT("<");
    out << WsmNamespaces::supportedNamespaces[
        WsmNamespaces::SOAP_ENVELOPE].localName;
    out << STRLIT(":Envelope");

    for (unsigned int i = 0; i < WsmNamespaces::LAST; i++)
    {
        out << STRLIT(" xmlns:");
        out << WsmNamespaces::supportedNamespaces[i].localName;
        out << STRLIT("=\"");
        out << WsmNamespaces::supportedNamespaces[i].extendedName;
        out << STRLIT("\"");
    }
    out << STRLIT(">");
}
예제 #13
0
Boolean WsmResponseEncoder::_encodeEnumerationData(
    SoapResponse& soapResponse,
    Buffer& headers,
    WsmOperationType operation,
    Uint64 contextId,
    Boolean isComplete,
    WsenEnumerationData& data,
    const String& resourceUri)
{
    Buffer bodyHeader, bodyTrailer;

    PEGASUS_ASSERT(operation == WS_ENUMERATION_ENUMERATE ||
        operation == WS_ENUMERATION_PULL);

    WsmWriter::appendStartTag(
        bodyHeader, WsmNamespaces::WS_ENUMERATION, 
        operation == WS_ENUMERATION_ENUMERATE ? 
            STRLIT("EnumerateResponse") : STRLIT("PullResponse"));

#if defined(PEGASUS_BUILD_SCX)

    // WINRM rejects empty EnumerationContext elements.

    WsmWriter::appendStartTag(
        bodyHeader, WsmNamespaces::WS_ENUMERATION, 
        STRLIT("EnumerationContext"));
    WsmWriter::append(bodyHeader, contextId);
    WsmWriter::appendEndTag(
        bodyHeader, WsmNamespaces::WS_ENUMERATION, 
        STRLIT("EnumerationContext"));

#else /* defined(PEGASUS_BUILD_SCX) */

    if (!isComplete)
    {
        WsmWriter::appendStartTag(
            bodyHeader, WsmNamespaces::WS_ENUMERATION, 
            STRLIT("EnumerationContext"));
        WsmWriter::append(bodyHeader, contextId);
        WsmWriter::appendEndTag(
            bodyHeader, WsmNamespaces::WS_ENUMERATION, 
            STRLIT("EnumerationContext"));
    }
    else
    {
        WsmWriter::appendEmptyTag(
            bodyHeader, WsmNamespaces::WS_ENUMERATION, 
            STRLIT("EnumerationContext"));
    }

#endif /* !defined(PEGASUS_BUILD_SCX) */

    if (data.getSize() > 0)
    {
        WsmWriter::appendStartTag(
            bodyHeader, 
            operation == WS_ENUMERATION_ENUMERATE ? 
                WsmNamespaces::WS_MAN : WsmNamespaces::WS_ENUMERATION, 
            STRLIT("Items"));
        WsmWriter::appendEndTag(
            bodyTrailer, 
            operation == WS_ENUMERATION_ENUMERATE ? 
                WsmNamespaces::WS_MAN : WsmNamespaces::WS_ENUMERATION, 
            STRLIT("Items"));
    }

    Uint32 eosPos = bodyTrailer.size();
    Uint32 eosSize = 0;
    if (isComplete)
    {
        WsmWriter::appendEmptyTag(
            bodyTrailer, 
            operation == WS_ENUMERATION_ENUMERATE ? 
                WsmNamespaces::WS_MAN : WsmNamespaces::WS_ENUMERATION, 
            STRLIT("EndOfSequence"));
        eosSize = bodyTrailer.size() - eosPos;
    }

    WsmWriter::appendEndTag(
        bodyTrailer, WsmNamespaces::WS_ENUMERATION, 
        operation == WS_ENUMERATION_ENUMERATE ? 
            STRLIT("EnumerateResponse") : STRLIT("PullResponse"));

    // Fault the request if it can't be encoded within the limits
    if (!soapResponse.appendHeader(headers) ||
        !soapResponse.appendBodyHeader(bodyHeader) ||
        !soapResponse.appendBodyTrailer(bodyTrailer))
    {
        return false;
    }

    // Now add the list of items
    Uint32 i = 0;

    if (data.enumerationMode == WSEN_EM_OBJECT)
    {
        for (i = 0; i < data.instances.size(); i++)
        {
            Buffer body;

            if (data.polymorphismMode == WSMB_PM_EXCLUDE_SUBCLASS_PROPERTIES)
            {
                // The response does not contain the subclass properties, but
                // the class name is still that of the subclass. 
                // Replace it here.
                data.instances[i].setClassName(
                    WsmToCimRequestMapper::convertResourceUriToClassName(
                        data.classUri).getString());
            }

            WsmWriter::appendInstanceElement(body, resourceUri, 
                data.instances[i], PEGASUS_INSTANCE_NS, false);
            if (!soapResponse.appendBodyContent(body))
            {
                break;
            }
        }
    }
    else if (data.enumerationMode == WSEN_EM_EPR)
    {
        for (i = 0; i < data.eprs.size(); i++)
        {
            Buffer body;

            WsmWriter::appendStartTag(
                body, 
                WsmNamespaces::WS_ADDRESSING, 
                STRLIT("EndpointReference"));
            WsmWriter::appendEPRElement(body, data.eprs[i]);
            WsmWriter::appendEndTag(
                body, 
                WsmNamespaces::WS_ADDRESSING, 
                STRLIT("EndpointReference"));
            if (!soapResponse.appendBodyContent(body))
            {
                break;
            }
        }
    }
    else if (data.enumerationMode == WSEN_EM_OBJECT_AND_EPR)
    {
        for (i = 0; i < data.instances.size(); i++)
        {
            Buffer body;

            WsmWriter::appendStartTag(
                body, 
                WsmNamespaces::WS_MAN, 
                STRLIT("Item"));

            if (data.polymorphismMode == WSMB_PM_EXCLUDE_SUBCLASS_PROPERTIES)
            {
                // The response does not contain the subclass properties, but
                // the class name is still that of the subclass. 
                // Replace it here.
                data.instances[i].setClassName(
                    WsmToCimRequestMapper::convertResourceUriToClassName(
                        data.classUri).getString());
            }

            WsmWriter::appendInstanceElement(body, resourceUri, 
                data.instances[i], PEGASUS_INSTANCE_NS, false);
 
            WsmWriter::appendStartTag(
                body, 
                WsmNamespaces::WS_ADDRESSING, 
                STRLIT("EndpointReference"));
            WsmWriter::appendEPRElement(body, data.eprs[i]);
            WsmWriter::appendEndTag(
                body, 
                WsmNamespaces::WS_ADDRESSING, 
                STRLIT("EndpointReference"));

            WsmWriter::appendEndTag(
                body, 
                WsmNamespaces::WS_MAN, 
                STRLIT("Item"));

            if (!soapResponse.appendBodyContent(body))
            {
                break;
            }
        }
    }
    else
    {
        PEGASUS_ASSERT(0);
    }

    // If the list is not empty, but none of the items have been successfully
    // added to the soapResponse, fault the request because it cannot be
    // encoded within the specified limits.
    if (data.getSize() > 0 && i == 0)
    {
        return false;
    }

    // Remove the items we processed. The rest will be added back 
    // to the context
    if (i != 0)
    {
        data.remove(0, i);
    }

    // The request is complete but could not be encoded with MaxEnvelopeSize.
    // Clear EndOfSequence tag.
    if (isComplete && data.getSize() > 0)
    {
        soapResponse.getBodyTrailer().remove(eosPos, eosSize);
    }

    return true;
}
예제 #14
0
static void  _testResponseFormatting(void)
{
    ContentLanguageList contentLanguage;
    Buffer body, header, out;
    const char expectedHttpHeader[] =
        "HTTP/1.1 200 OK\r\nContent-Type: application/soap+xml;charset=UTF-8"
        "\r\ncontent-length: 0000000000\r\nSOAPAction: "
        "http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse\r\n\r\n";

    // Create FaultTo header
    WsmWriter::appendStartTag(
        header, WsmNamespaces::WS_ADDRESSING, STRLIT("FaultTo"));
    WsmWriter::appendTagValue(header, WsmNamespaces::WS_ADDRESSING,
        STRLIT("Address"), "http://www.acme.com:5988/wsman");
    WsmWriter::appendEndTag(
        header, WsmNamespaces::WS_ADDRESSING, STRLIT("FaultTo"));

    // Create an instance for Soap body
    WsmInstance inst("testClass");
    WsmValue val("value");
    inst.addProperty(WsmProperty("property", val));
    WsmWriter::appendInstanceElement(body, WSM_RESOURCEURI_CIMSCHEMAV2, inst,
        PEGASUS_INSTANCE_NS, false);

    String messageId = WsmUtils::getMessageId();
    WxfGetRequest request(messageId, WsmEndpointReference());
    WxfGetResponse response(inst, &request, contentLanguage);
    SoapResponse soapResponse(&response);
    soapResponse.appendHeader(header);
    soapResponse.appendBodyContent(body);
    out = soapResponse.getResponseContent();

    char* ptr = (char*) out.getData();
    if (strncmp(ptr, expectedHttpHeader, sizeof(expectedHttpHeader)-1) != 0)
        throw Exception("HTTP header incorrect");
    ptr += sizeof(expectedHttpHeader)-1;

    WsmReader reader(ptr);
    const char* xmlVersion = 0;
    const char* xmlEncoding = 0;
    reader.getXmlDeclaration(xmlVersion, xmlEncoding);
    if (strcmp(xmlVersion, "1.0") != 0 || strcmp(xmlEncoding, "utf-8") != 0)
        throw Exception("XML version or encoding incorrect");

    XmlEntry entry;
    reader.expectStartTag(entry, WsmNamespaces::SOAP_ENVELOPE, "Envelope");

    String wsaMessageId;
    String wsaAction;
    String wsaFrom;
    String wsaReplyTo;
    String wsaFaultTo;
    WsmEndpointReference epr;
    Uint32 wsmMaxEnvelopeSize = 0;
    AcceptLanguageList wsmLocale;
    Boolean wsmRequestEpr = false;
    Boolean wsmRequestItemCount = false;
    reader.decodeRequestSoapHeaders(
        wsaMessageId, epr.address, wsaAction, wsaFrom, wsaReplyTo,
        wsaFaultTo, epr.resourceUri, *epr.selectorSet, wsmMaxEnvelopeSize,
        wsmLocale, wsmRequestEpr, wsmRequestItemCount);

    if (epr.address != WSM_ADDRESS_ANONYMOUS ||
        wsaAction != WSM_ACTION_GET_RESPONSE ||
        wsaFrom != String::EMPTY ||
        wsaReplyTo != String::EMPTY ||
        wsaMessageId != response.getMessageId() ||
        wsaFaultTo != "http://www.acme.com:5988/wsman" ||
        epr.resourceUri != String::EMPTY ||
        wsmMaxEnvelopeSize != 0 ||
        wsmRequestEpr != false)
        throw Exception("Invalid Soap headers");

    // Read and verify the instance in Soap body.
    WsmInstance inst1;
    reader.expectStartTag(entry, WsmNamespaces::SOAP_ENVELOPE, "Body");
    reader.getInstanceElement(inst1);
    if (!_compareInstances(inst, inst1))
        throw Exception("Instances do not compare");
    reader.expectEndTag(WsmNamespaces::SOAP_ENVELOPE, "Body");

    reader.expectEndTag(WsmNamespaces::SOAP_ENVELOPE, "Envelope");
}
예제 #15
0
Boolean WsmResponseEncoder::_encodeEnumerationData(
    SoapResponse& soapResponse,
    Buffer& headers,
    WsmOperationType operation,
    Uint64 contextId,
    Boolean isComplete,
    WsenEnumerationData& data,
    Uint32& numDataItemsEncoded,
    const String& resourceUri)
{
    Buffer bodyHeader, bodyTrailer;

    PEGASUS_ASSERT(operation == WS_ENUMERATION_ENUMERATE ||
        operation == WS_ENUMERATION_PULL);

    numDataItemsEncoded = 0;

    WsmWriter::appendStartTag(
        bodyHeader, WsmNamespaces::WS_ENUMERATION,
        operation == WS_ENUMERATION_ENUMERATE ?
            STRLIT("EnumerateResponse") : STRLIT("PullResponse"));

    // Include an EnumerationContext in the response.  If this response
    // completes the enumeration, this element will be modified/removed below.
    Uint32 ecPos = bodyHeader.size();
    WsmWriter::appendStartTag(
        bodyHeader, WsmNamespaces::WS_ENUMERATION,
        STRLIT("EnumerationContext"));
    WsmWriter::append(bodyHeader, contextId);
    WsmWriter::appendEndTag(
        bodyHeader, WsmNamespaces::WS_ENUMERATION,
        STRLIT("EnumerationContext"));
    Uint32 ecSize = bodyHeader.size() - ecPos;

    if (data.getSize() > 0)
    {
        WsmWriter::appendStartTag(
            bodyHeader,
            operation == WS_ENUMERATION_ENUMERATE ?
                WsmNamespaces::WS_MAN : WsmNamespaces::WS_ENUMERATION,
            STRLIT("Items"));
        WsmWriter::appendEndTag(
            bodyTrailer,
            operation == WS_ENUMERATION_ENUMERATE ?
                WsmNamespaces::WS_MAN : WsmNamespaces::WS_ENUMERATION,
            STRLIT("Items"));
    }

    Uint32 eosPos = bodyTrailer.size();
    Uint32 eosSize = 0;
    if (isComplete)
    {
        // Write an EndOfSequence element with the expectation that all the
        // elements fit within MaxEnvelopeSize.  This element will be removed
        // below if the assumption proves untrue.  This element is written
        // up front before all the response data was included, because adding
        // the EndOfSequence element later might push the response size past
        // the MaxEnvelopeSize.
        WsmWriter::appendEmptyTag(
            bodyTrailer,
            operation == WS_ENUMERATION_ENUMERATE ?
                WsmNamespaces::WS_MAN : WsmNamespaces::WS_ENUMERATION,
            STRLIT("EndOfSequence"));
        eosSize = bodyTrailer.size() - eosPos;
    }

    WsmWriter::appendEndTag(
        bodyTrailer, WsmNamespaces::WS_ENUMERATION,
        operation == WS_ENUMERATION_ENUMERATE ?
            STRLIT("EnumerateResponse") : STRLIT("PullResponse"));

    // Fault the request if it can't be encoded within the limits
    if (!soapResponse.appendHeader(headers) ||
        !soapResponse.appendBodyHeader(bodyHeader) ||
        !soapResponse.appendBodyTrailer(bodyTrailer))
    {
        return false;
    }

    // Now add the list of items
    Uint32 i = 0;

    if (data.enumerationMode == WSEN_EM_OBJECT)
    {
        for (i = 0; i < data.instances.size(); i++)
        {
            Buffer body;

            if (data.polymorphismMode == WSMB_PM_EXCLUDE_SUBCLASS_PROPERTIES)
            {
                // The response does not contain the subclass properties, but
                // the class name is still that of the subclass.
                // Replace it here.
                data.instances[i].setClassName(
                    WsmToCimRequestMapper::convertResourceUriToClassName(
                        data.classUri).getString());
            }

            WsmWriter::appendInstanceElement(body, resourceUri,
                data.instances[i], PEGASUS_INSTANCE_NS, false);

            if (!soapResponse.appendBodyContent(body))
            {
                break;
            }
        }
    }
    else if (data.enumerationMode == WSEN_EM_EPR)
    {
        for (i = 0; i < data.eprs.size(); i++)
        {
            Buffer body;

            WsmWriter::appendStartTag(
                body,
                WsmNamespaces::WS_ADDRESSING,
                STRLIT("EndpointReference"));
            WsmWriter::appendEPRElement(body, data.eprs[i]);
            WsmWriter::appendEndTag(
                body,
                WsmNamespaces::WS_ADDRESSING,
                STRLIT("EndpointReference"));
            if (!soapResponse.appendBodyContent(body))
            {
                break;
            }
        }
    }
    else if (data.enumerationMode == WSEN_EM_OBJECT_AND_EPR)
    {
        for (i = 0; i < data.instances.size(); i++)
        {
            Buffer body;

            WsmWriter::appendStartTag(
                body,
                WsmNamespaces::WS_MAN,
                STRLIT("Item"));

            if (data.polymorphismMode == WSMB_PM_EXCLUDE_SUBCLASS_PROPERTIES)
            {
                // The response does not contain the subclass properties, but
                // the class name is still that of the subclass.
                // Replace it here.
                data.instances[i].setClassName(
                    WsmToCimRequestMapper::convertResourceUriToClassName(
                        data.classUri).getString());
            }

            WsmWriter::appendInstanceElement(body, resourceUri,
                data.instances[i], PEGASUS_INSTANCE_NS, false);

            WsmWriter::appendStartTag(
                body,
                WsmNamespaces::WS_ADDRESSING,
                STRLIT("EndpointReference"));
            WsmWriter::appendEPRElement(body, data.eprs[i]);
            WsmWriter::appendEndTag(
                body,
                WsmNamespaces::WS_ADDRESSING,
                STRLIT("EndpointReference"));

            WsmWriter::appendEndTag(
                body,
                WsmNamespaces::WS_MAN,
                STRLIT("Item"));

            if (!soapResponse.appendBodyContent(body))
            {
                break;
            }
        }
    }
    else
    {
        PEGASUS_ASSERT(0);
    }

    numDataItemsEncoded = i;

    // If the list is not empty, but none of the items have been successfully
    // added to the soapResponse, fault the request because it cannot be
    // encoded within the specified limits.
    if (data.getSize() > 0 && numDataItemsEncoded == 0)
    {
        return false;
    }

    if (isComplete)
    {
        if (data.getSize() > numDataItemsEncoded)
        {
            // The request is complete but could not be encoded within
            // MaxEnvelopeSize.  Clear EndOfSequence tag.
            soapResponse.getBodyTrailer().remove(eosPos, eosSize);
        }
        else
        {
            // All the enumeration results were written.  Update the
            // EnumerationContext element.
            if (operation == WS_ENUMERATION_ENUMERATE)
            {
                // DSP0226 R8.2.3-5:  A conformant service that supports
                // optimized enumeration and has not returned all items of the
                // enumeration sequence in the wsen:EnumerateResponse message
                // shall return a wsen:EnumerationContext element that is
                // initialized such that a subsequent wsen:Pull message will
                // return the set of items after those returned in the
                // wsen:EnumerateResponse. If all items of the enumeration
                // sequence have been returned in the wsen:EnumerateResponse
                // message, the service should return an empty
                // wsen:EnumerationContext element and shall return the
                // wsman:EndOfSequence element in the response.
                Buffer emptyEc(50);
                WsmWriter::appendEmptyTag(
                    emptyEc, WsmNamespaces::WS_ENUMERATION,
                    STRLIT("EnumerationContext"));
                soapResponse.getBodyHeader().remove(ecPos, ecSize);
                soapResponse.getBodyHeader().insert(
                    ecPos, emptyEc.getData(), emptyEc.size());
            }
            else
            {
                // DSP0226 R8.4-8:  If the wsen:EndOfSequence marker occurs in
                // the wsen:PullResponse message, the wsen:EnumerationContext
                // element shall be omitted, as the enumeration has completed.
                // The client cannot subsequently issue a wsen:Release message.
                soapResponse.getBodyHeader().remove(ecPos, ecSize);
            }
        }
    }

    return true;
}
예제 #16
0
#include <base/find.h>
#include <base/str.h>
#include <base/path.h>
#include <base/file.h>
#include <base/format.h>
#include <base/http.h>
#include <base/plugininfo.h>
#include <base/shlib.h>
#include <base/log.h>
#include <plugins/odata/odataplugin.h>

static PluginInfo _builtinPlugin0 =
{
    "Default",
    PHIT_METHOD_GET,
    STRLIT("/"),
    NULL,
    0,
    &__defaultPlugin 
};

static PluginInfo _builtinPlugin1 =
{
    "Default",
    PHIT_METHOD_GET,
    STRLIT("/files/*"),
    NULL,
    0,
    &__defaultPlugin
};
예제 #17
0
void PostWebPage(
    PHIT_Plugin* plugin,
    PHIT_Context* context)
{
    Buf out = BUF_INITIALIZER;

    BufCatShareFile(&out, "preamble.html");

    BufCat(&out, STRLIT("<h1>ODataLite Plugin</h1>"));
    BufCat(&out, STRLIT("<hr>"));

    /* Providers */
    {
        size_t i;

        BufCat(&out, STRLIT("<h2>Providers:</h2>"));
        BufCat(&out, STRLIT(
            "<table width=100% border=0 cellspacing=0 cellpadding=5>"));
        BufCat(&out, STRLIT("<tr bgcolor=#777777>"));

        HTMLPutTH(&out, "URIs");
        HTMLPutTH(&out, "Library");
        HTMLPutTH(&out, "Query Options");

        BufCat(&out, STRLIT("</tr>"));

        for (i = 0; i < __entriesSize; i++)
        {
            const ProviderEntry* p = __entries[i];

            if (p)
            {
                BufFmt(&out, "<tr  valign=top bgcolor=\"%s\">",
                    (i % 2) ? "#DDDDDDDD" : "lightyellow");

                /* URIs */
                {
                    size_t j;

                    BufCat(&out, STRLIT("<td>"));

                    for (j = 0; j < p->paths.size; j++)
                    {
                        BufFmt(&out, 
                            "<a "
                            "href=\"javascript:void(0);\" "
                            "onClick=\"GetPage('odata%s'); \">"
                            "<u>%s</u>"
                            "</a><br>\n",
                            p->paths.data[j].path,
                            p->paths.data[j].path);
                    }

                    BufCat(&out, STRLIT("</td>"));
                }

                /* Library */
                HTMLPutTD(&out, p->libname);

                /* Query Options */
                BufCat(&out, STRLIT("<td>"));
                {
                    unsigned int bit;

                    /* Test each bit */
                    for (bit = 0; bit < 32; bit++)
                    {
                        unsigned int mask = 1 << bit;

                        if (mask & p->queryOptions)
                        {
                            BufCatStr(&out, QueryOptionToStr(mask));
                            BufCat(&out, STRLIT("&nbsp;"));
                        }
                    }
                }
                BufCat(&out, STRLIT("</td>"));

                BufCat(&out, STRLIT("</tr>"));
            }
        }

        BufCat(&out, STRLIT("</table>"));
    }

    /* Plain-text query field */
    BufCatShareFile(&out, "odata.html");

    /* Providers.conf */
    {
        BufCat(&out, STRLIT("<h2>Files:</h2>"));
        BufFmt(&out, "<li><a href=\"/odata/%s\">%s</a></li>",
            "providers.conf", "providers.conf");
    }

    /* HTML Postamble */
    BufCatShareFile(&out, "postamble.html");
    BufCatCh(&out, '\0');

    /* Post the response */
    PHIT_Context_PostStatusLine(
        context, PHIT_STATUSCODE_200_OK, PHIT_STATUSMSG_200_OK);
    PHIT_Context_PostHeader(context, "Content-Type", "text/html");
    PHIT_Context_PostHeader(context, "Cache-Control", "no-cache");
    PHIT_Context_PostEOH(context);
    PHIT_Context_PostContent(context, out.data, out.size-1);
    PHIT_Context_PostEOC(context);

    BufDestroy(&out);
}
예제 #18
0
Buffer& operator<<(Buffer& out, const AcceptLanguageList& al)
{
    XmlGenerator::append(out, LanguageParser::buildAcceptLanguageHeader(al));
    return out;
}

Buffer& operator<<(Buffer& out, const ContentLanguageList& cl)
{
    XmlGenerator::append(out, LanguageParser::buildContentLanguageHeader(cl));
    return out;
}

const StrLit XmlGenerator::_XmlWriterTypeStrings[17] =
{
    STRLIT("TYPE=\"boolean\""),   STRLIT("TYPE=\"uint8\""),
    STRLIT("TYPE=\"sint8\""),     STRLIT("TYPE=\"uint16\""),
    STRLIT("TYPE=\"sint16\""),    STRLIT("TYPE=\"uint32\""),
    STRLIT("TYPE=\"sint32\""),    STRLIT("TYPE=\"uint64\""),
    STRLIT("TYPE=\"sint64\""),    STRLIT("TYPE=\"real32\""),
    STRLIT("TYPE=\"real64\""),    STRLIT("TYPE=\"char16\""),
    STRLIT("TYPE=\"string\""),    STRLIT("TYPE=\"datetime\""),
    STRLIT("TYPE=\"reference\""), STRLIT("TYPE=\"object\""),
    STRLIT("TYPE=\"instance\"")
};

const StrLit XmlGenerator::_XmlWriterKeyTypeStrings[17] =
{
    STRLIT("boolean"), STRLIT("numeric"),
    STRLIT("numeric"), STRLIT("numeric"),
    STRLIT("numeric"), STRLIT("numeric"),