philco

Security issue in a SilverLight project

Discussion created by philco on Jun 15, 2011
Latest reply on Jul 1, 2011 by MichaelvdV@Atos

Hi,

 

I started developing a basic silverlight project for the first time. I'm not familiar with web services and silverlight is totally new to me. So... I'm having hard times getting values from the PI web services. My code is based on Lonnie's example (many thanks!) but I'm facing a security related issue when trying to get some values. Here's the exception detail. BTW it's not a cross-domain affair.

 

System.ServiceModel.CommunicationException was unhandled by user code
  Message=An error occurred while trying to make a request to URI 'http://100srv21dev.graymont.com:81/PIWebServices/PITimeSeries.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.
  StackTrace:
       at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
       at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
       at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
       at Environmental_ScoreCard.PIWebService.PITimeSeriesClient.PITimeSeriesClientChannel.EndGetPIArchiveData(IAsyncResult result)
       at Environmental_ScoreCard.PIWebService.PITimeSeriesClient.PIWebService_IPITimeSeries_EndGetPIArchiveData(IAsyncResult result)
       at Environmental_ScoreCard.PIWebService.PITimeSeriesClient.OnEndGetPIArchiveData(IAsyncResult result)
       at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
  InnerException: System.Security.SecurityException
       Message=""
       StackTrace:
            at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
            at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
            at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
       InnerException: System.Security.SecurityException
            Message=Security error.
            StackTrace:
                 at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
                 at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
                 at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)
            InnerException:

 

I'm using the BasicHttpBinding. Here's the sub that makes the call:

 

 Private Sub GetData(ByVal pstrTagName As String)
        Try
            'Call PI Web Service
            Dim endPointAdd As EndpointAddress = New EndpointAddress("http://100srv21dev.graymont.com:81/PIWebServices/PITimeSeries.svc")
            Dim basicHttpBinding As BasicHttpBinding = New BasicHttpBinding()

 

            'Set Callback Function
            Dim client As PITimeSeriesClient = New PIWebService.PITimeSeriesClient(basicHttpBinding, endPointAdd)
            Dim myEvent As EventHandler(Of GetPISummaryDataCompletedEventArgs) = New EventHandler(Of GetPISummaryDataCompletedEventArgs)(AddressOf client_GetPISummaryDataCompleted)
            AddHandler client.GetPISummaryDataCompleted, myEvent

 

            'Build data request
            Dim requests(0) As PIArcDataRequest
            Dim request As PIArcDataRequest = New PIArcDataRequest

 

            'The manner
            Dim manner As New PIArcManner
            manner.Boundaries = PIArcMannerBoundaries.Inside
            manner.RetrievalType = PIArcMannerRetrievalType.Compressed
            manner.NumValues = 1
            request.PIArcManner = manner

 

            'The constraint
            Dim myRange As New TimeRange
            myRange.Start = "*-180d"
            myRange.End = "*"
            request.TimeRange = myRange

 

            'The path
            request.Path = pstrTagName

 

            requests(0) = request
            client.GetPIArchiveDataAsync(requests)

 

        Catch ex As Exception
            MessageBox.Show(ex.Message, "GetData", MessageBoxButton.OK)
        End Try
    End Sub

 

It's propably a basic issue but since I'm not familiar with these technologies I don't find the solution.

 

Thanks

Outcomes