error app
-
Thursday, August 09, 2012 7:37 AMHej people-i am making simple Silverlight Application with WCF-my service is retrieving data from my Oracle to datagrid(i am using win 7,and domain mashine).
my WCF service looks like this:
using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Data.OleDb;
namespace SilverlightApplication32.Web
{
[ServiceContract(Namespace = "")]
[SilverlightFaultBehavior]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1
{
[OperationContract]
public void DoWork()
{
// Add your operation implementation here
return;
}
[OperationContract]
public List<Employee> GetAllEmployees()
{
List<Employee> emps = new List<Employee>();
string connectionString = "connection string to Oracle";
OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);
myOleDbConnection.Open();
OleDbCommand cmd = new OleDbCommand("select naziv,adresa from tabela12 ", myOleDbConnection);
OleDbDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Employee emp = new Employee();
emp.name = reader.GetString(0);
try
{
emp.prezime = reader.GetString(1);
}
catch
{
emp.prezime = "Nema adrese";
}
emps.Add(emp);
}
return emps;
}
// Add more operations here and mark them with [OperationContract]
}
}
and my Employee class looks like :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace SilverlightApplication32.Web
{
public class Employee
{
public string name { get; set; }
public string prezime { get; set; }
}
}
my Web config look like this:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="Off" />
<trust level="Full"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="SilverlightApplication32.Web.Service1.custom Binding0">
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="SilverlightApplication32.Web.Service1">
<endpoint address="" binding="customBinding" bindingConfiguration="SilverlightApplication32.Web .Service1.customBinding0"
contract="SilverlightApplication32.Web.Service1" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>
And when i add this service to APP it work great-I get data in datagrid from Oracle. Than i try to add it to IIS7-i thing i did it OK, becouse when i try to get link that i created in II7-Example:http://10.6.6.31/SilverlightApplicat...plication.aspx it shows me my app.But when i try execute it from custom comp it did not retrieve me data. But this work Fine when i try that link from my mashine-So something has to bee with privilegies or secyrity..i read on internet that i have to add corsdoman or cleinf policy..But i did not find where or how to add this..Do i have to add this on Web site, or create new project and make .xml and add it..And where to add it-Root of application,web..??/ help please...
Thanks for sharing knowledge
)
All Replies
-
Thursday, August 09, 2012 11:52 AM
Hi,
If the web service is being accessed from a different domain that the one from where your silverlight application is hosted, you will need cross domain policy file.
Check out this link - http://msdn.microsoft.com/en-us/library/cc197955(VS.95).aspx
Regards,
Nauzad Kapadia
Please "Mark as Answer" if a post has answered your question or "Vote as Helpful" if it was helpful in some way. Here's why
- Marked As Answer by Otomii LuModerator Thursday, August 16, 2012 8:47 AM

