8 Replies Latest reply on Jul 4, 2013 10:28 PM by Ashok_NK

    PI Web Services WCF Client

    Ashok_NK

      Hi

       

      I am trying to connect to PI Web Services. I added "service reference" to my project. 

       

       

       
      Binding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
                  EndpointAddress endpointAddress = new EndpointAddress("http://bfasdfsd1/PIWebServices/PITimeSeries.svc");
                  using (PITimeSeriesClient piTimeSeriesClient = new PITimeSeriesClient(binding, endpointAddress))
                  {
                      PISummaryDataRequest piSummaryDataRequest = new PISummaryDataRequest();
                      piSummaryDataRequest.Path = @"pi:\\piServer1\sinusoid";
                      piSummaryDataRequest.TimeRange = new TimeRange() { Start = DateTime.Now.ToString(Iso8601DateTimeFormat), End = DateTime.Now.Subtract(TimeSpan.FromDays(7.0)).ToString(Iso8601DateTimeFormat) };
      
                      var requests = new[] { piSummaryDataRequest };
      
                      TimeSeries[] summaryData = piTimeSeriesClient.GetPISummaryData(requests);
      
                      WriteSummaryData(summaryData);
      
                      Console.ReadKey();
                  }
      

       

       

      Calling: 

       
      piTimeSeriesClient.GetPISummaryData(requests);
      

      Returns the following error:

       

      Content Type text/xml; charset=utf-8 was not supported by service http://bbmwdpdms01/PIWebServices/PITimeSeries.svc.  The client and service bindings may be mismatched.

       

       

       

      Is there any other additional setup or configuration requried?

        • Re: PI Web Services WCF Client
          xwang

          Hi,

           

          This problem should be caused by the web.config setting.  Please uninstall PI Web Services, and delete all files of this one.  Then, reinstall it, and make sure web.config is set up for basicHttpBinding and not wsHttpBinding.

           

          Xi Wang

           

          v-Campus team

            • Re: PI Web Services WCF Client
              Ashok_NK

              Hi

               

              I just want to clarify. Is this a problem with PI Web Services installation? It has a web.config that gets installed?

               

              If I uninstall Pi Web Services, and re-install, it should resolve?

                • Re: PI Web Services WCF Client
                  xwang

                  Hi,

                   

                  This is not the problem with PI Web Services installation, but the security setting problem.  The security setting is in the web.config file, and  re-installation is the easiest method to solve this problem.  But please make sure changing to basicHttpBinding in the installation step.

                   

                  Xi Wang

                   

                  v-Campus

                    • Re: PI Web Services WCF Client
                      Ashok_NK

                      Ok, will try tomorrow - I don't recall being prompted to specify a binding during install though... The version I installed runs in a windows service - is that the norm?

                        • Re: PI Web Services WCF Client
                          Ashok_NK

                          Hi

                           

                          I un-installed and re-installed and it still does not work.

                           

                          I have the following MSIs:

                           

                          PI Web Services 64.msi

                           

                          PI Web Services Standalone Edition 64.msi

                           

                           

                           

                          PI Web Services 64.msi - This will not install, the setup launches but the first screen has the following error and forces you to close the installer:

                           

                          "The installer was interrupted before PI Web Services 2012 could be installed. You need to restart the installer and try again.

                           

                          I tried all the obvious, restarts etc.

                           

                           

                           

                          PI Web Services Standalone Edition 64.msi - This installs, but there's no option to specify a binding...

                            • Re: PI Web Services WCF Client
                              Ashok_NK

                              I realised I had to configure the installed service to meet the environment configuration, which meant configuring the PI Services - WCF bindings/endpoints & service behaviour.

                                • Re: PI Web Services WCF Client
                                  mhamel

                                  @Ashok: I will try to answer to multiple questions asked throughout this thread.

                                   

                                  First, the error: "Content Type text/xml; charset=utf-8 was not supported by service http://bbmwdpdms01/PIWebServices/PITimeSeries.svc. The client and service bindings may be mismatched." is related to the version of SOAP message expected. Generally, this problem is seen when you try to use a SOAP 1.1 client that aims for a SOAP 1.2 Web Service. This is related to your WCF configuration.

                                   

                                  This is not a problem. You need to configure your endpoints properly for the usage you want to make. By default, if I recall well, the wsHttpBinding is configured by default (SOAP 1.2).

                                   

                                  PI Web Services can be installed in two modes: one that lives inside a web server (IIS) and the other in a standalone mode (using a Windows Service that creates a "hook" on the HTTP listener). The standalone mode is useful when you don't want to configure a Web Server.

                                   

                                  Can you explain what type of bindings you intend to use and for what type of applications?

                                    • Re: PI Web Services WCF Client
                                      Ashok_NK

                                      Hi Mathieu

                                       

                                      Thanks for the detailed response. I was able to resolve the problem through configuration of client and server endpoints by following the user guide. I also had to make sure the windows service was running under an appropriate domain account.

                                       

                                      Thanks