10 Replies Latest reply on Sep 21, 2010 2:23 PM by mhalhead

    Web services tests

    kou2pinso

      Hello,

       

      I tested web services beta for PI 2010, but i did not succeed in getting data with any method.

       

      here is an example of code in the file named Form1.cs (included in the file "Files.zip")
      I put authentication mode to None in web.config for the web service site (file web.config.xml)

      <!--<authentication mode="Windows" />-->
      <authentication mode="None" />
      <authorization>
      <allow users="*"/>
      </authorization>
      <identity impersonate="false" />

      I checked anonymous authentification in IIS7, but I get an exception ( file exception.jpg) when I try to use any method, in my example, i get an exception when I try to launch :

       

      TimeSeries[] rts = proxy.GetPIArchiveData(rReqs);
      Is there something missing ?

       

      Thanks a lot for your help

       

      Best regards

        • Re: Web services tests
          MichaelvdV@Atos

          Can you post the details of the exception(s) here? it could be either communication/authentication/access/... exceptions... Please post the details of the base exception here. 

            • Re: Web services tests

              @Michael: the details of the exception are in the screenshot Richard provided, in the Files.zip attachment to his post. This is in French and the translated exception is "The type initializer for 'OSIsoft.RtBaseline.DataService.ServerManager' threw an exception.".

               

              @Richard: This error is most likely security-related. Since your authentication and impersonation if turned off, PI Web Services would normally rely on the identity set for your Application Pool, to do its stuff. Can you verify that identity? Also, can please share the relevant portion of the app.config file for your WinForms application?

                • Re: Web services tests
                  Tfenn

                  Hi

                   

                  I'm getting the same/similar issue.

                   

                  Long post, but included it all in case allows others to find relevant sections when doing a search...

                   

                  Here's the code

                              PIServiceReference.PITimeSeriesClient PI = new PITimeSeriesClient();
                              string sEnd = PI.Endpoint.Address.ToString();
                              PIServiceReference.PIArcDataRequest[] piarr = new PIArcDataRequest[1];
                              PIServiceReference.PIArcDataRequest pia = new PIArcDataRequest();
                              PIServiceReference.TimeSeries[] pit;// = new TimeSeries();
                              PIServiceReference.TimeRange pitr = new TimeRange();
                              
                              pia.Path=@"pi:\\sodor\sinusoid";
                              pitr.Start="*-1H";
                              pitr.End="*";
                              PIArcManner pim = new PIArcManner();
                              pim.Boundaries = PIArcMannerBoundaries.Inside;
                              pim.NumValues = 10;
                              pim.RetrievalType = PIArcMannerRetrievalType.Compressed;
                              pim.Updates = false;
                              pia.PIArcManner = pim;
                              pia.TimeRange = pitr;
                              piarr[0] = pia;
                              string piv=PI.GetProductVersion();


                  Here's the web.config

                  <?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>
                    <system.diagnostics>
                      <trace autoflush="false" />
                    </system.diagnostics>
                    <PIWebServiceSettings>
                      <add key="AllowCalculations" value="true" />
                      <add key="AllowDataEntry" value="true" />
                    </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>
                        <basicHttpBinding>
                          <binding name="basicBindingConfig">
                          </binding>
                        </basicHttpBinding>
                        <wsHttpBinding>
                          <binding name="wsBinding" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 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="basicHttpBinding" bindingConfiguration="basicBindingConfig" name="BasicEndpoint" bindingNamespace="http://xml.osisoft.com/services/PIDataService" contract="PIWebService.PIDataService.IPITimeSeries">
                            <identity>
                              <servicePrincipalName value="HOST/SODOR" />
                            </identity>
                          </endpoint>
                        </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="false" />
                          </behavior>
                        </serviceBehaviors>
                      </behaviors>
                    </system.serviceModel>
                  </configuration>


                  Here's the error message


                  System.ServiceModel.FaultException`1 was unhandled
                    Message=The type initializer for 'OSIsoft.RtBaseline.DataService.ServerManager' threw an exception.
                    Source=mscorlib
                    StackTrace:
                      Server stack trace: 
                         at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
                         at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
                         at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
                         at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
                         at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
                      Exception rethrown at [0]: 
                         at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
                         at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
                         at PIWebService.PIServiceReference.IPITimeSeries.GetProductVersion()
                         at PIWebService.PIServiceReference.PITimeSeriesClient.GetProductVersion() in C:\Users\Administrator\documents\visual studio 2010\Projects\PIWebService\PIWebService\Service References\PIServiceReference\Reference.cs:line 779
                         at PIWebService.Form1.btnGetPIData_Click(Object sender, EventArgs e) in C:\Users\Administrator\Documents\Visual Studio 2010\Projects\PIWebService\PIWebService\Form1.cs:line 45
                         at System.Windows.Forms.Control.OnClick(EventArgs e)
                         at System.Windows.Forms.Button.OnClick(EventArgs e)
                         at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
                         at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
                         at System.Windows.Forms.Control.WndProc(Message& m)
                         at System.Windows.Forms.ButtonBase.WndProc(Message& m)
                         at System.Windows.Forms.Button.WndProc(Message& m)
                         at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
                         at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
                         at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
                         at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
                         at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
                         at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
                         at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
                         at System.Windows.Forms.Application.Run(Form mainForm)
                         at PIWebService.Program.Main() in C:\Users\Administrator\documents\visual studio 2010\Projects\PIWebService\PIWebService\Program.cs:line 18
                         at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
                         at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
                         at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
                         at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
                         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
                         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
                         at System.Threading.ThreadHelper.ThreadStart()
                    InnerException: 

                   

                   

                    • Re: Web services tests

                      @Tony Fenn: Are you sure you are using the latest version of PI Web Services (PI Web Services 2010, the released version)?

                       

                      We have seen this problem occurring in some cases with the Beta version we made available prior to the release, but this seems to have been fixed in the Release version. Also, if you have been using the Beta release of PI Web Services (and its accompanying web.config file), I would like to suggest you don't use that file anymore (e.g. rename it to .old) and start from the default web.config file that comes with PI Web Services 2010 - or use one of the samples in \PIWebServices\Help\Samples.

                       

                      Hope this helps!

                        • Re: Web services tests
                          Tfenn

                          Hi

                           

                          This is a completely new install on a test system, everything downloaded fresh within the last 2-3 weeks, clean install of Windows Server2008 R2, SQL Server 2008, and PI installs.  Everything in 64 bit.

                           

                          From add/remove programs

                           

                          SDK shows version 1.3.8.388

                           

                          SDK x64 shows version 1.3.8.387

                           

                          PI Web Services 2010 - version 1.0.6

                           

                          I tried the web.config that was installed by default, the example basichttp bindings and the modified one earlier in this thread (as pasted previously).  Screenshots of everythign installed included below

                           

                          Any suggestions very gratefully received!

                           

                          osi-1.jpg

                           

                           osi-2.jpg

                            • Re: Web services tests
                              mhalhead

                              Tony,

                               

                              I noticed that you have PI Webparts installed as well. This can cause problems. The PI Webservices user guide does mention this and more importantly the correct configuration. This is something Steve pointed out to me in a previous post. I don't know if you've followed these suggestion but it certainly caused me some grief.

                               

                              PI Webservice User Guide


                              If you want to host PI Web Services 2010 on a Web Server that has PI WebParts installed, OSIsoft recommends that you: Create an IIS Web site and associated application pool that are not under the control of Microsoft SharePoint. The Web site should be configured on its own port number. You must select the Web site as the host when you run the setup kit (page 17). Verify that the application pool you set up for PI Web Services runs under a Process ID that is different from the Process ID used for PI WebParts.

                               

                              Hope this helps

                                • Re: Web services tests
                                  Tfenn

                                  To quote a previous poster "Bingo"!

                                   

                                  Yep, that was it.  I actually thought I had all the sharepoint stuff working in a separate pool, but started from scratch again and ensured the PI Web Service was in it's own site (running on port 8001) with it's own application pool. So the old addage RTFM, and in my case RTFM again

                                   

                                   

                                   

                                  many "many thanks for that post!

                                   

                                   

                                   

                                   

                                    • Re: Web services tests
                                      smohr

                                      As we've established, Tony is using the released version of the product.  Richard, the original poster, is almost certainly using a pre-release version.  The tip is that the property names, e.g., Compressed, are capitalized in the release, but were not in earlier versions.  So, Richard, please install the released version.  I think you'll like it much more than the beta.

                                       

                                      In addition, not that with the web.config as presented, security is turned off.  In calls, then, the web service will impersonate the IIS app pool identity.  Make sure this ID has rights to the PIPC\DAT folder as well as to the resources (PI Archive) that you will be using in the call.  You should also be running under .NET Full Trust.  Almost everyone is doing so, but if you are in doubt, look for the root level (typically inetpub\wwwroot) web.config file.

                                       

                                      To everyone, if you find yourself modifying web.config files estensively and you are unsure whether you have it right, you can always check one of the sample config files in the web service's Help\Samples folder.  I noticed the posted web.config file contained extraneous entries.  In this case they won't matter, but you may end up inadvertently with conflicting entries.

                                      • Re: Web services tests

                                        I'm glad Michael's suggestion solved your problem! Indeed, SharePoint tends to take control of a lot of things in the space it is being attributed...

                                        • Re: Web services tests
                                          mhalhead

                                          Glad I could help.