Friday, 6 September 2013

What is wrong with my Silverlight / WCF Configuration

What is wrong with my Silverlight / WCF Configuration

I've been struggling for a few hours I admit. I must be missing something
with the Bindings/Configuration between my Silverlight application and WCF
web service. It was working for awhile, but I must have accidentally
changed some settings and I can't get it to work anymore.
In Visual Studio when I debug I have both the Service and Silverlight
application launch at the same time, I have Windows authentication
disabled in the web.config files for debugging. When I deploy, I go back
and change my Configuration files to enable Windows security/transport so
I can get user credentials on the web service side.
Now when I deploy both the WCF service and the Silverlight application to
a different machine using IIS, I get an error "Not Found" from Silverlight
when it attempts to contact the WCF service. Could someone explain to me
the different configuration files that exist and what each should be
pointing to? Here are my configuration files in their respective
locations:
wwwroot\webserviceapp\web.config
<?xml version="1.0" encoding="UTF-8"?>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior"
name="WebserviceName.Service1">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="BasicHttpEndpointBinding"
name="BasicHttpEndpoint" contract="WebserviceName.IService1">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"
aspNetCompatibilityEnabled="true" />
wwwroot\web.config - this is the web.config for silverlight I guess?
<?xml version="1.0" encoding="UTF-8"?>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpoint" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard" maxBufferSize="65536"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8"
transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint
address="http://<<<ip_to_machine>>>/webserviceapp/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpEndpoint"
contract="ServiceReference1.IService1"
name="BasicHttpEndpoint" />
</client>
</system.serviceModel>
<system.webServer>
<defaultDocument>
<files>
<add value="ProjectTestPage.html" />
</files>
</defaultDocument>
</system.webServer>
wwwwroot\ClientBin\SilverlightApp.xap (the ServiceReferences.ClientConfig
file):
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpoint" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="TransportCredentialOnly" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint
address="http://<<<ip_to_machine>>>/webserviceapp/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpEndpoint"
contract="ServiceReference1.IService1"
name="BasicHttpEndpoint" />
</client>
</system.serviceModel>
These are the three configuration files which seem to drive everything,
unless I am wrong? Since I develop on one environment and deploy to
another it seems like I must change these files to point to the right
resources. When I hit my Silverlight application after I've deployed it to
the new machine I get the application loading. Once it finishes loading,
the first web service call it makes fails with exception and I get this in
the Chrome Console:
Failed to load resource: the server responded with a status of 500
(Internal Server Error)
http://<<<ip_to_machine>>>/webserviceapp/Service1.svc
Failed to load resource: the server responded with a status of 500
(Internal Server Error)
http://<<<ip_to_machine>>>/webserviceapp/Service1.svc
Uncaught Error: Unhandled Error in Silverlight Application An exception
occurred during the operation, making the result invalid. Check
InnerException for exception details. at
System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at Project.ServiceReference1.GetAllNewsCompletedEventArgs.get_Result()
at Project.View.Home1.ClientGetAllNewsCompleted(Object pSender,
GetAllNewsCompletedEventArgs pEventArgs)
at
Project.ServiceReference1.Service1Client.OnGetAllNewsCompleted(Object
state)
I'm like 99% certain that the Service is NEVER hit. I have a log statement
at the very top of the function which is being called and it never logs
anything.
IIS Configuration: Web Service Authentication: Anonymous = Disabled
ASP.NET Impersonation = Disabled Windows Authentication = Enabled
Default Web Site (where my silverlight app is hosted): Anonymous =
Disabled ASP.NET Impersonation = Disabled Windows Authentication = Enabled
Anyone have any suggestions, or need anymore information from me to help
debug?

No comments:

Post a Comment