9 Replies Latest reply on Aug 6, 2010 1:34 PM by spilon

    Problems with PI Webservices and basicHttpBinding

    Lonnie Bowling

      Hi Everyone,

       

      I'm trying to get basicHttp binding to work withPI Web services and am getting the following error when opening the PITimeSeries.svc from a browser:

       

       Server Error in '/PIWebServices' Application.

      Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http]. 

       

      Here is the edited part of the config file:

       

      
      

      <system.serviceModel>

          <bindings>

            <basicHttpBinding>

              <binding name="basicBindingConfig">

                <security mode="TransportWithMessageCredential">

                  <transport clientCredentialType="Windows" />

                  <message clientCredentialType="UserName"/>

                </security>

              </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/ENG-SANDBOX" />

                </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="true" />

              </behavior>

            </serviceBehaviors>

          </behaviors>

        </system.serviceModel>

       

       

      Everthing works fine with the default wsHttp binding. I need to get the basicHttp binding working so I can use it with Silverlight. I spent alot of time trying to figure this out today but am having no luck. Any help would be appreciated!

       

      Thanks,

       

      Lonnie

        • Re: Problems with PI Webservices and basicHttpBinding
          Lonnie Bowling

          I forgot to mention, that when I set the security mode to "None" I get this error:

           

          Server Error in '/PIWebServices' Application.
          The contract operation 'GetPIArchiveData' requires Windows identity for automatic impersonation. A Windows identity that represents the caller is not provided by binding ('BasicHttpBinding','http://xml.osisoft.com/services/PIDataService') for contract ('IPITimeSeries','http://xml.osisoft.com/services/PIDataService'.

           

          PS: Sorry, I think this topic should be in the PI Services area, I didn't see it until after I posted

          • Re: Problems with PI Webservices and basicHttpBinding
            smohr

            There are a couple of related issues here.  First, if you set up transport security, you are talking HTTPS and IIS must be configured with a certificate to make that happen.  If you set the security mode to None, you cannot set impersonateCallerForAllOperations to true -- you get the error you described.  If you are talking about a Silverlight application, you are restricted to basicHttp and customBinary for bindings.  Securing basicHttp involves certificates and SSL and it's frankly a bit ugly.  The other option is to go with no WCF security and secure your PI and AF access on the back end through PI Trusts of PI identity mappings.  There's documentation for this in the released product User Guide, and the release also has a sample web.config for basicHttp in the \PIWebServices\Help\Samples folder.

              • Re: Problems with PI Webservices and basicHttpBinding
                Lonnie Bowling

                Thanks for the replies.  I agree about SSL and don't want to communicate over HTTPS.  My desire is to get basicHTTP working with no security.  So how do I turn off WCF security for this web service?  I'm still getting this:

                 

                Server Error in '/PIWebServices' Application.

                 

                The contract operation 'GetPIArchiveData' requires Windows identity for automatic impersonation. A Windows identity that represents the caller is not provided by binding ('BasicHttpBinding','http://xml.osisoft.com/services/PIDataService') for contract ('IPITimeSeries','http://xml.osisoft.com/services/PIDataService'.

                 

                 

                 

                It seems like GetPIArchiveData wants some authenication, which it sould be getting from the app pool...  This is a test setup and the PI server is on the same box as IIS.  I have no issues with custom webservices getting data from the PI server using SDK calls.  The account the app pool is using is the default Network Services.  I changed it to the administrator account but that did not fix the problem.  I have read the user guide and have tired everything I can think of, what am I missing?

                 

                Thanks,

                 

                 

                 

                Lonnie

                  • Re: Problems with PI Webservices and basicHttpBinding
                    Lonnie Bowling

                    By the way here is my config for basicHTTP without security:

                    
                    

                     

                      <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/ENG-SANDBOX" />

                              </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="true" />

                            </behavior>

                          </serviceBehaviors>

                        </behaviors>

                      </system.serviceModel>

                     

                      • Re: Problems with PI Webservices and basicHttpBinding
                        smohr

                        Lonnie Bowling

                        So how do I turn off WCF security for this web service?
                        Change impersonateCallerForAllOperations from "true" to "false"

                          • Re: Problems with PI Webservices and basicHttpBinding
                            Lonnie Bowling

                            Bingo!  Everything now works, I knew it was something simple like that. Of course it would be nice if I had a better understanding of the in and outs of setting up bindings.

                             

                            Thanks for getting me unstuck Stephen!

                              • Re: Problems with PI Webservices and basicHttpBinding
                                Lonnie Bowling

                                Just to save others time, here is what a working example of connecting to PI Web Services using silverlight.  It was based on the example in the help file and is working.

                                 

                                Lonnie

                                public partial class MainPage : UserControl
                                {
                                    public MainPage()
                                    {
                                        
                                InitializeComponent();
                                        GetData();
                                    }

                                    void GetData()
                                    {
                                        EndpointAddress endPointAdd = new EndpointAddress(http://eng-sandbox:2080/PIWebServices/PITimeSeries.svc);
                                        BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
                                        
                                PIWebService.PITimeSeriesClient client = new PIWebService.PITimeSeriesClient(basicHttpBinding, endPointAdd);
                                        
                                client.GetProductVersionCompleted += new EventHandler<PIWebService.GetProductVersionCompletedEventArgs>(client_GetProductVersionCompleted);
                                        
                                client.GetProductVersionAsync();
                                        
                                client.GetPIArchiveDataCompleted += new EventHandler<PIWebService.GetPIArchiveDataCompletedEventArgs>(client_GetPIArchiveDataCompleted);

                                        PIArcDataRequest[] rReqs = new PIArcDataRequest[1];
                                        PIArcDataRequest req = new PIArcDataRequest();
                                       
                                TimeRange tr = new TimeRange();
                                       
                                tr.Start = "*-1H";
                                       
                                tr.End = "*";
                                       
                                req.TimeRange = tr;
                                       
                                PIArcManner arcmnr = new PIArcManner();
                                       
                                arcmnr.Boundaries = PIArcMannerBoundaries.Inside;
                                        
                                arcmnr.NumValues = 400;
                                       
                                arcmnr.RetrievalType = PIArcMannerRetrievalType.Compressed;
                                       
                                arcmnr.Updates = false; // updates are not supported in v.1.0
                                       
                                req.PIArcManner = arcmnr;
                                       
                                req.Path = "pi:\\\\eng-sandbox\\CDT158";
                                       
                                rReqs[0] = req;

                                        client.GetPIArchiveDataAsync(rReqs);
                                    }

                                    void client_GetPIArchiveDataCompleted(object sender, PIWebService.GetPIArchiveDataCompletedEventArgs e)
                                   
                                {
                                        
                                //dataGrid1.ItemsSource = e.Result.ToList();
                                        
                                //throw new NotImplementedException();
                                    
                                }

                                    void client_GetProductVersionCompleted(object sender, PIWebService.GetProductVersionCompletedEventArgs e)
                                   
                                {
                                        txtVersion.Text = "version: " + e.Result; //throw new NotImplementedException();
                                    }
                                }