Reputation: 5
I have a Silverlight app that has some WCF services that it uses. When I run the silverlight app, everything works fine. Another person can use it just fine, however, the majority of users get an error.
"An error occurred while trying to make a request to URI 'xxxxx'. 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."
I enabled WCF Tracing and noticed a few errors there when these users accessed my Silverlight app:
1) Configuration evaluation context not found. 2) Content Type application/soap+xml; charset=utf-8 was sent to a service expecting text/xml; charset=utf-8
Here are my config files:
Server config for WCF:
<?xml version="1.0"?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="All"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\log\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows"/>
<identity impersonate="false"/>
<customErrors mode="Off" />
</system.web>
<appSettings>
</appSettings>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Here is my Client Config in silverlight:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISLtoCRM" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
<binding name="BasicHttpBinding_ISLtoSQL" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://xxxx.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ISLtoCRM" contract="SLCRMSrvc.ISLtoCRM"
name="BasicHttpBinding_ISLtoCRM" />
<endpoint address="http://yyyy.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ISLtoSQL" contract="SLSQLSrvc.ISLtoSQL"
name="BasicHttpBinding_ISLtoSQL" />
</client>
</system.serviceModel>
</configuration>
The WCF service is hosted in IIS 6.1 on Windows Server 2008 R2. The application pool is set up to run under a specific user. Managed Pipeline Mode is Classic and Anonymous Authentication is enabled on the Site in IIS. All other authentication is disabled.
Any help in figuring this out? Not sure why myself and another use can access the app just fine but most users cannot. Is it a security issue or something wrong with how I created the WCF service?
UPDATED Server Config for WCF:
<?xml version="1.0"?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="All"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\log\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="Off" />
<authentication mode="Windows" />
</system.web>
<appSettings>
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="CRMWCF.SLtoCRM" behaviorConfiguration="CRMBehavior">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBinding" contract="CRMWCF.ISLtoCRM" />
</service>
<service name="CRMWCF.SLtoSQL" behaviorConfiguration="CRMBehavior">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="MyBinding" contract="CRMWCF.ISLtoSQL" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CRMBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*"/>
<add name="Access-Control-Allow-Method" value="GET,PUT,POST,DELETE,OPTIONS"/>
<add name="Access-Control-Allow-Headers" value="Content-Type"/>
</customHeaders>
</httpProtocol>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Upvotes: 0
Views: 256
Reputation: 982
Very common issue. You will need you clientaccesspolicy.xml and crossdomain.xml.
http://msdn.microsoft.com/en-us/library/cc197955(v=vs.95).aspx
Upvotes: 1