DavidMFairchild

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"?>

<configuration>

  <configSections>

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

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

  </configSections>

  <PIWebServiceSettings>

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

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

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

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

  </PIWebServiceSettings>

  <pidsSettings>

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

  </pidsSettings>

  <appSettings>

  </appSettings>

  <connectionStrings />

  <system.web>

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

      <assemblies>

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

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

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

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

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

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

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

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

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

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

      </assemblies>

    </compilation>

    <authentication mode="Windows" />

    <identity impersonate="false" />

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

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

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

    </customErrors>

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

  </system.web>

  <system.serviceModel>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" />

     <bindings>

        <basicHttpBinding>

           <binding name="basicBinding" />

        </basicHttpBinding>

        <mexHttpBinding>

           <binding name="mexBinding" />

        </mexHttpBinding>

     </bindings>

    <services>

      <service behaviorConfiguration="PIDataService.Service1Behavior"

        name="PIWebServices.PIDataService.PITimeSeriesSvcImpl">

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

          contract="IMetadataExchange" />

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

          name="BasicEndpoint" bindingNamespace="
http://xml.osisoft.com/services/PIDataService"

          contract="PIWebService.PIDataService.IPITimeSeries">

          <identity>

            <servicePrincipalName value="XXXXXXX/steas" />

          </identity>

        </endpoint>

      </service>

    </services>

    <behaviors>

      <serviceBehaviors>

        <behavior name="PIDataService.Service1Behavior">

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

          <serviceDebug includeExceptionDetailInFaults="true" />

          <serviceCredentials>

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

            <issuedTokenAuthentication allowUntrustedRsaIssuers="true" />

          </serviceCredentials>

          <serviceAuthorization principalPermissionMode="UseWindowsGroups"

            impersonateCallerForAllOperations="false" />

        </behavior>

      </serviceBehaviors>

    </behaviors>

  </system.serviceModel>

</configuration>



 
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.

Outcomes