Easy test script for PI Web Services

Discussion created by DavidMFairchild on Sep 20, 2012
Latest reply on Sep 28, 2012 by mhamel

This question is regarding Mathieu Hamel's blog post of the same name.  A link to the code is here.


This script works nicely for me when run on the web server, but fails when I run it on a workstation.


The error I am getting is "Exception calling 'UploadString' ... the remote server returned an error: (404) Not Found."  Indicating that the web server could not find the URL expressed in $EndPoint.  $EndPoint is written to the console.  If I copy that and paste it into the address on IE I get the standard "PITimeSeriesService Service" response as expected.  I even tried launching IE from the PowerShell console to be sure there wasn't some user conflict.  But I still get the same error.


So, clearly, I can get to the URL.  So, what is the problem?


I noticed that, in the code, that $_XMLMessageTemplate doesn't provide a location for the PIArcMannerRetrievalType and NumValues.  But you do provide these two values in the String.Format() statement.  However, this does not prevent the script from running on the Web Server.  I believe it uses the default retrieval type (Compressed?).  Just for the heck of it, I added them to the code, but I still get the same error.


Here is a copy of my web.config file.  As  you can see I am using BasicHTTP until I can get the server to work.

<?xml version="1.0" encoding="UTF-8"?>



    <section name="PIWebServiceSettings" type="System.Configuration.AppSettingsSection, System.Configuration, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" requirePermission="false" />

    <section name="pidsSettings" type="System.Configuration.AppSettingsSection, System.Configuration, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" requirePermission="false" />



    <add key="AllowCalculations" value="true" />

    <add key="AllowDataEntry" value="true" />

    <add key="FloatPrecision" value="DisplayDigits" />

    <add key="UpdatePurgeInterval" value="5" />



    <add key="PIinstrumentationConfigFile" value="I:\XxxPIWebservices\PIWebServices\PIInstrumentation.config" />




  <connectionStrings />


    <compilation debug="false" targetFramework="4.0">


        <add assembly="System.Core, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />

        <add assembly="System.Configuration.Install, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />

        <add assembly="System.Management, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />

        <add assembly="System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />

        <add assembly="OSIsoft.PIDataServices.DataAccess, Version=, Culture=neutral, PublicKeyToken=53b77d1d3d7a979b" />

        <add assembly="OSIsoft.PIDataServices.Common, Version=, Culture=neutral, PublicKeyToken=53b77d1d3d7a979b" />

        <add assembly="OSIsoft.PIDataServices.Configuration, Version=, Culture=neutral, PublicKeyToken=53b77d1d3d7a979b" />

        <add assembly="OSIsoft.PIDataServices.DataService, Version=, Culture=neutral, PublicKeyToken=53b77d1d3d7a979b" />

        <add assembly="OSIsoft.PIInstrumentation, Version=, Culture=neutral, PublicKeyToken=53b77d1d3d7a979b" />

        <add assembly="OSIsoft.PIInstrumentation.Listeners, Version=, Culture=neutral, PublicKeyToken=53b77d1d3d7a979b" />



    <authentication mode="Windows" />

    <identity impersonate="false" />

    <customErrors mode="Off" defaultRedirect="GenericErrorPage.htm">

      <error statusCode="403" redirect="NoAccess.htm" />

      <error statusCode="404" redirect="FileNotFound.htm" />


    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />



    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" />



           <binding name="basicBinding" />



           <binding name="mexBinding" />




      <service behaviorConfiguration="PIDataService.Service1Behavior"


        <endpoint address="mex" binding="mexHttpBinding" name="mexBinding"

          contract="IMetadataExchange" />

        <endpoint binding="basicHttpBinding" bindingConfiguration="basicBinding"

          name="BasicEndpoint" bindingNamespace="



            <servicePrincipalName value="XXXXXXX/steas" />







        <behavior name="PIDataService.Service1Behavior">

          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />

          <serviceDebug includeExceptionDetailInFaults="true" />


            <windowsAuthentication includeWindowsGroups="true" allowAnonymousLogons="false" />

            <issuedTokenAuthentication allowUntrustedRsaIssuers="true" />


          <serviceAuthorization principalPermissionMode="UseWindowsGroups"

            impersonateCallerForAllOperations="false" />






P.S. Steve, the "Insert Code" functionality of this forum didn't seem to work for me.  It appeared to insert empty lines for the code, but there was not visible text either in the wysiwyg display or the preview.