locked
CreateAuthenticatedSessionToken XSD invalid? RRS feed

  • Question

  • When trying to validate my request payload before sending it to the HV web service, I encountered the following error:

    Element '{urn:com.microsoft.wc.request}request': No matching global declaration available for the validation root.

    Here's the sample code:

    <?php

    $payload = '<content>Example - Real payload not needed.</content>';
    $schemaUrl = 'https://platform.healthvault-ppe.com/platform/XSD/method-createauthenticatedsessiontoken.xsd';
    libxml_use_internal_errors(true);
    $xdoc = new DOMDocument();
    $xdoc->loadXML($payload);
    if ($xdoc->schemaValidate($schemaUrl) == false)
    {
        $allErrors = libxml_get_errors();
        $errorStr = '';
        foreach ($allErrors as $error)
        {
            $errorStr .= $error->message . ' (Code ' . $error->code . ') | ';
        }
        $errorStr = substr($errorStr, 0, strlen($errorStr) - 3);
        throw new Exception('Payload is invalid - it does not match the schema. LibXML errors: ' . $errorStr);
    }

    ?>


    I haven't included the real payload in the above example as it isn't needed to reproduce the error.
    Monday, May 19, 2008 2:10 PM

Answers


  • hi Dave -

    If you see on top of the createauthenticatedsession request you will find:
    <import namespace="urn:com.microsoft.wc.types" schemaLocation="types.xsd"/>
    <import namespace="urn:com.microsoft.wc.auth" schemaLocation="auth.xsd"/>

    In general if you are validating methods then copy all the XSDs (types and auth are below the methods table) locally from:
    http://developer.healthvault.com/methods/methods.aspx
    and validate against them.

    However, in real application the extra schema validation is an overhead and you should avoid it.

    Hope this helps.

    regards,
    Vaibhav
    Monday, May 19, 2008 3:58 PM

All replies


  • hi Dave -

    If you see on top of the createauthenticatedsession request you will find:
    <import namespace="urn:com.microsoft.wc.types" schemaLocation="types.xsd"/>
    <import namespace="urn:com.microsoft.wc.auth" schemaLocation="auth.xsd"/>

    In general if you are validating methods then copy all the XSDs (types and auth are below the methods table) locally from:
    http://developer.healthvault.com/methods/methods.aspx
    and validate against them.

    However, in real application the extra schema validation is an overhead and you should avoid it.

    Hope this helps.

    regards,
    Vaibhav
    Monday, May 19, 2008 3:58 PM
  • Vaibhav,

    Thanks.  Brain froze up on me.  I didn't plan on doing the validation in a production setting -- you're right that the performance hit would be significant.

    - Dave
    Monday, May 19, 2008 6:07 PM