15 Replies Latest reply on Jul 19, 2011 1:35 PM by Lonnie Bowling

    An error occurred while receiving the HTTP response to http://dc2piintf01.stanwell.com/PIWebServices/PITimeSeries.svc.

    OxleyCreek

      I have set up PI web services and have written a C# program to test it out. I get the error below when I run the code. Visual Studio 2010 can find the web service OK all looks fine but I cannot get it to access PI. I have included the app.config info and the error log message from the Web server - can anyone tell me what is wrong?

       

      Regards

       

      Michael

       

       

       

       

       

      class Program
          {
              static void Main(string[] args)
              {
                  ServiceReference1.PITimeSeriesClient client = new ServiceReference1.PITimeSeriesClient();
                  string[] tags = { @"pi:\\pims\sinusoid" };
                  ServiceReference1.TimeSeries[] data = client.GetPISnapshotData(tags);

                  client.Close();
                

              }
          }

       

       

       

      Error Message from Visual Studio app

       

      An error occurred while receiving the HTTP response to http://dc2piintf01.stanwell.com/PIWebServices/PITimeSeries.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.

       

      App.config

       

      <?xml version="1.0" encoding="utf-8" ?>
      <configuration>
          <system.serviceModel>
              <bindings>
                  <wsHttpBinding>
                      <binding name="BasicEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00"
                          receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
                          transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                          maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                          allowCookies="false">
                          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                          <reliableSession ordered="true" inactivityTimeout="00:10:00"
                              enabled="false" />
                          <security mode="Message">
                              <transport clientCredentialType="Windows" proxyCredentialType="None"
                                  realm="" />
                              <message clientCredentialType="Windows" negotiateServiceCredential="true"
                                  algorithmSuite="Default" />
                          </security>
                      </binding>
                  </wsHttpBinding>
              </bindings>
            <behaviors>
              <endpointBehaviors>
                <behavior name="wsImpersonationBehavior">
                  <clientCredentials>
                    <windows allowedImpersonationLevel="Delegation" />
                    <httpDigest impersonationLevel="Delegation" />
                  </clientCredentials>
                </behavior>
              </endpointBehaviors>
            </behaviors>

            <client>
              <endpoint address="http://dc2piintf01.stanwell.com/PIWebServices/PITimeSeries.svc"
                binding="wsHttpBinding" bindingConfiguration="BasicEndpoint"
                contract="ServiceReference1.IPITimeSeries" name="BasicEndpoint"
                behaviorConfiguration="wsImpersonationBehavior">
                <identity>
                  <servicePrincipalName value="HOST/DC2PIINTF01" />
                </identity>
              </endpoint>
            </client>
          </system.serviceModel>
      </configuration>

       

       

       

      Details from the error log on the Web server

       

      Log Name:      Application
      Source:        ASP.NET 2.0.50727.0
      Date:          18/07/2011 4:44:21 PM
      Event ID:      1334
      Task Category: None
      Level:         Error
      Keywords:      Classic
      User:          N/A
      Computer:      DC2PIINTF01.stanwell.com
      Description:
      An unhandled exception occurred and the process was terminated.

      Application ID: /LM/W3SVC/1/ROOT/PIWebServices

      Process ID: 1524

      Exception: System.Runtime.InteropServices.SEHException

      Message: External component has thrown an exception.

      StackTrace:    at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
         at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
         at OSIsoft.RtBaseline.DataService.ThreadManager.InvokeInternal(Delegate method, Object[] args)
         at OSIsoft.RtBaseline.DataService.PIServers.Invoke(Boolean impersonate, Delegate method, Object[] args)
         at OSIsoft.RtBaseline.DataService.PIServers.GetDefaultServer()
         at OSIsoft.RtBaseline.DataService.PIServers.GetDefaultServerName()
         at OSIsoft.RtBaseline.Services.DataSourceTypes.PI.ExecuteQueries(IList`1 states)
         at OSIsoft.RtBaseline.Common.QueryProcessorImpl.ExecuteQueryImpl(QueryState[] states, Dictionary`2 cachedTimeConversions)
         at OSIsoft.RtBaseline.Common.QueryProcessorImpl.ExecuteQueries(DataQuery[] queries)
         at PIWebServices.PIDataService.PITimeSeriesSvcImpl.Execute(Object asyncResult)
         at System.Threading.ExecutionContext.runTryCode(Object userData)
         at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
         at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
      Event Xml:
      <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
        <System>
          <Provider Name="ASP.NET 2.0.50727.0" />
          <EventID Qualifiers="49152">1334</EventID>
          <Level>2</Level>
          <Task>0</Task>
          <Keywords>0x80000000000000</Keywords>
          <TimeCreated SystemTime="2011-07-18T06:44:21.000000000Z" />
          <EventRecordID>2432</EventRecordID>
          <Channel>Application</Channel>
          <Computer>DC2PIINTF01.stanwell.com</Computer>
          <Security />
        </System>
        <EventData>
          <Data>An unhandled exception occurred and the process was terminated.

      Application ID: /LM/W3SVC/1/ROOT/PIWebServices

      Process ID: 1524

      Exception: System.Runtime.InteropServices.SEHException

      Message: External component has thrown an exception.

      StackTrace:    at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
         at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
         at OSIsoft.RtBaseline.DataService.ThreadManager.InvokeInternal(Delegate method, Object[] args)
         at OSIsoft.RtBaseline.DataService.PIServers.Invoke(Boolean impersonate, Delegate method, Object[] args)
         at OSIsoft.RtBaseline.DataService.PIServers.GetDefaultServer()
         at OSIsoft.RtBaseline.DataService.PIServers.GetDefaultServerName()
         at OSIsoft.RtBaseline.Services.DataSourceTypes.PI.ExecuteQueries(IList`1 states)
         at OSIsoft.RtBaseline.Common.QueryProcessorImpl.ExecuteQueryImpl(QueryState[] states, Dictionary`2 cachedTimeConversions)
         at OSIsoft.RtBaseline.Common.QueryProcessorImpl.ExecuteQueries(DataQuery[] queries)
         at PIWebServices.PIDataService.PITimeSeriesSvcImpl.Execute(Object asyncResult)
         at System.Threading.ExecutionContext.runTryCode(Object userData)
         at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
         at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)</Data>
        </EventData>
      </Event>

        • Re: An error occurred while receiving the HTTP response to http://dc2piintf01.stanwell.com/PIWebServices/PITimeSeries.svc.
          hanyong

          Hi Michael,

           

          I'm not sure what could be causing the exception at this point, can you also post the web.config that you are using for PI Web Services?

           

          Also have you tried testing PI Web Services using WCF Storm or other web service test clients? If you refer to the PI Web Services User Guide (downloadable from Library), there is a section "Verify Data Access" which describes the steps to install and configure WCF Storm to test PI Web Services

            • Re: An error occurred while receiving the HTTP response to http://dc2piintf01.stanwell.com/PIWebServices/PITimeSeries.svc.
              OxleyCreek

              Hi Han,

               

              Here is the result with Storm - this is running on the same machine that is hosting IIS and here is the web.config contents - any advice would be much appreciated.

               

              Thanks

               

              Michael

               

               

               

              <?xml version="1.0" encoding="UTF-8"?>
              <!--
                  Note: As an alternative to hand editing this file you can use the
                  web admin tool to configure settings for your application. Use
                  the Website->Asp.Net Configuration option in Visual Studio.
                  A full list of settings and comments can be found in
                  machine.config.comments usually located in
                  \Windows\Microsoft.Net\Framework\v2.x\Config
              -->
              <configuration>
                <configSections>
                  <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                    <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                      <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                      <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                        <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
                        <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                        <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                        <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                      </sectionGroup>
                    </sectionGroup>
                  </sectionGroup>
                  <section name="PIWebServiceSettings" type="System.Configuration.AppSettingsSection, System.Configuration, Version=2.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="Full" />
                </PIWebServiceSettings>
                <appSettings>
                </appSettings>
                <connectionStrings />
                <system.web>
                  <!--
                          Set compilation debug="true" to insert debugging
                          symbols into the compiled page. Because this
                          affects performance, set this value to true only
                          during development.
                      -->
                  <compilation debug="false">
                    <assemblies>
                      <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                      <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                      <add assembly="System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
                      <add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
                      <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                    </assemblies>
                  </compilation>
                  <!--
                          The <authentication> section enables configuration
                          of the security authentication mode used by
                          ASP.NET to identify an incoming user.
                      -->
                  <authentication mode="Windows" />
                  <identity impersonate="false" />
                  <!--
                          The <customErrors> section enables configuration
                          of what to do if/when an unhandled error occurs
                          during the execution of a request. Specifically,
                          it enables developers to configure html error pages
                          to be displayed in place of a error stack trace.

                      <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                          <error statusCode="403" redirect="NoAccess.htm" />
                          <error statusCode="404" redirect="FileNotFound.htm" />
                      </customErrors>
                      -->
                  <pages>
                    <controls>
                      <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                    </controls>
                  </pages>
                  <httpHandlers>
                    <remove verb="*" path="*.asmx" />
                    <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                    <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                    <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
                  </httpHandlers>
                  <httpModules>
                    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                  </httpModules>
                </system.web>
                <system.codedom>
                  <compilers>
                    <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
                      <providerOption name="CompilerVersion" value="v3.5" />
                      <providerOption name="WarnAsError" value="false" />
                    </compiler>
                  </compilers>
                </system.codedom>
                <!--
                      The system.webServer section is required for running ASP.NET AJAX under Internet
                      Information Services 7.0.  It is not necessary for previous version of IIS.
                  -->
                <system.webServer>
                  <validation validateIntegratedModeConfiguration="false" />
                  <modules>
                    <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                  </modules>
                  <handlers accessPolicy="Read, Execute, Script">
                    <remove name="WebServiceHandlerFactory-Integrated" />
                    <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                    <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                    <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                  </handlers>
                </system.webServer>
                <system.serviceModel>
                  <bindings>
                    <wsHttpBinding>
                      <binding name="wsBinding" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="655360" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
                        <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
                        <security mode="Message">
                          <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" />
                        </security>
                      </binding>
                    </wsHttpBinding>
                    <mexHttpBinding>
                      <binding name="mexBinding" />
                    </mexHttpBinding>
                  </bindings>
                  <services>
                    <service behaviorConfiguration="PIDataService.ServiceBehavior" name="PIWebServices.PIDataService.PITimeSeriesSvcImpl">
                      <endpoint address="mex" binding="mexHttpBinding" name="mexBasicEndpoint" contract="IMetadataExchange" />
                      <endpoint binding="wsHttpBinding" bindingConfiguration="wsBinding" name="BasicEndpoint" bindingNamespace="http://xml.osisoft.com/services/PIDataService" contract="PIWebService.PIDataService.IPITimeSeries">
                        <identity>
                          <servicePrincipalName value="HOST/DC2PIINTF01" />
                        </identity>
                      </endpoint>
                    </service>
                    <service behaviorConfiguration="PIDataService.PISearchServiceBehavior" name="PIWebServices.PISearchService.PISearchSvcImpl">
                      <endpoint binding="wsHttpBinding" bindingConfiguration="wsBinding" name="SearchEndpoint" bindingNamespace="http://xml.osisoft.com/services/PISearchService" contract="PIWebServices.PISearchService.IPISearch">
                        <identity>
                          <servicePrincipalName value="HOST/DC2PIINTF01" />
                        </identity>
                      </endpoint>
                      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
                    </service>
                  </services>
                  <behaviors>
                    <serviceBehaviors>
                      <behavior name="PIDataService.ServiceBehavior">
                        <serviceMetadata httpGetEnabled="true" />
                        <serviceDebug includeExceptionDetailInFaults="true" />
                        <serviceCredentials>
                          <windowsAuthentication includeWindowsGroups="true" allowAnonymousLogons="false" />
                          <issuedTokenAuthentication allowUntrustedRsaIssuers="true" />
                        </serviceCredentials>
                        <serviceAuthorization principalPermissionMode="UseWindowsGroups" impersonateCallerForAllOperations="true" />
                      </behavior>
                      <behavior name="PIDataService.PISearchServiceBehavior">
                        <serviceMetadata httpGetEnabled="true" />
                        <serviceDebug includeExceptionDetailInFaults="true" />
                        <serviceCredentials>
                          <windowsAuthentication includeWindowsGroups="true" allowAnonymousLogons="false" />
                          <issuedTokenAuthentication allowUntrustedRsaIssuers="true" />
                        </serviceCredentials>
                        <serviceAuthorization principalPermissionMode="UseWindowsGroups" impersonateCallerForAllOperations="true" />
                      </behavior>
                    </serviceBehaviors>
                  </behaviors>
                </system.serviceModel>
              </configuration>