Silverlight Client and WCF Service - System.ServiceModel.ProtocolException-UnexpectedHttpResponseCode
Last post 05-05-2008 5:14 PM by codism. 8 replies.
Sort Posts:
03-24-2008 11:04 AM
Silverlight Client and WCF Service - System.ServiceModel.ProtocolException-UnexpectedHttpResponseCode

I am new to WCF as well as SilverLight,  getting the this .Exception ..

An exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll but was not handled in user code Additional information: [UnexpectedHttpResponseCode]Arguments:Not Found

Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=2.0.30226.2&File=System.ServiceModel.dll&Key=UnexpectedHttpResponseCode

1. WCF Service - a hosted service in IIS5.1-Windows XP Professional and details as follows..
http://host/RoleService
Binding : basicHttpBinding
Contract: IRoleService
Operations:
-GetRole
-GetRoles
-Greet

2. SilverLight client with ServiceReference for endpoint http://host/RoleService/Service1.svc.

In the client program it says IClientChannel is open , but System.ServiceModel.CommunicationException is the result of call on RoleService.GreetAsync("Name").

crossdomain.xml

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <allow-access-from domain="*" secure="false"/>
</cross-domain-policy>

clientaccesspolicy.xml

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from>
        <domain uri="*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>


Already spent lot of time , I could not spend any of this much time on Java based services donno for what ever reasons, still no luck with Silverlight. Thankful if you Silverlight gurus help me out..

Thanks and Regards,
BS

bscc

Loading...
Joined on 03-24-2008
Posts 5
03-25-2008 7:58 PM
Re: Silverlight Client and WCF Service - System.ServiceModel.ProtocolException-UnexpectedHttpResponseCode

I don't have much info on an answer, but maybe this will help you go in the right direction. Your error messages are general and you can view the real ones by installing Silverlight 2 SDK Beta 1, and following the instructions here:

http://www.microsoft.com/silverlight/resources/readme.aspx

For some reason the error messages are general and are not working by default. (I did this today and it helped with debugging WCF)

brad

bradtpm

Loading...
Joined on 03-25-2008
Posts 15
03-25-2008 11:35 PM
Re: Silverlight Client and WCF Service - System.ServiceModel.ProtocolException-UnexpectedHttpResponseCode

Hi:

  Where do you put the policy file? C:\Inetpub\wwwroot?

  I suggest you to put WCF and Silverlight in the same domain to test. If it can work we can target it as cross domain issue.

Regards

Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Allen Chen – MSFT

Loading...
Joined on 03-16-2007
Posts 1,502
03-26-2008 12:28 AM
Re: Silverlight Client and WCF Service - System.ServiceModel.ProtocolException-UnexpectedHttpResponseCode

Thank you very much for the information.

First I started with Visual Studio 2005 .NET Framework 2.0

First Phase-1

-----------------

-Installed 3.0

-Ajax

-ASP.NET Futures

First Phase-2

------------------

Visual Studio 2008 and Silverlight tools for VS2008 , I am not sure Silverlight 2 SDK Beta 1 co-exists with the one already there, but why the error messages are not customized for the installation I have.....is a question to me.

Thanks and Regards,

BS

 

 

 

 

 

bscc

Loading...
Joined on 03-24-2008
Posts 5
04-04-2008 2:44 PM
Re: Silverlight Client and WCF Service - System.ServiceModel.ProtocolException-UnexpectedHttpResponseCode

I am getting the same error.. I also have clientaccesspolicy file in place although I don't see a reason why I should because everything is running on the same domain. (localhost:port). I believe the request never reaches the server as I have breakpoints all over and none of them gets hit. Not sure what is going on.. will work on a Windows app to call the same service and see if that works and post it here soon.

hpwillbe

Loading...
Joined on 09-17-2007
Posts 8
04-04-2008 4:30 PM
Re: Silverlight Client and WCF Service - System.ServiceModel.ProtocolException-UnexpectedHttpResponseCode

Ok.. I found the issue and the solution to it.

The issue is when you add a WCF service in your asp.net web project it by default adds the wsHttpBinding as a default configuration. Now looks like the Silverlight does not have WSHttpBinding implemented yet so I was using BasicHttpBinding on the client side. WSHttpBinding uses SOAP 1.2 while  BasicHttpBinding uses SOAP 1.1 & hence the protocol exception. The solution as you might guess is to change your web.config to have binding="basicHttoBinding" -> refresh the service ref in SL project and you are good to go..

I must say the error message from given by Silverlight was not much help. I had to do a winforms app to figure out the issue. Related winforms thread http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1237025&SiteID=1

So here's the question. I know wsHttpBinding gives you all sorts of bells and whistles with it.. specially around security. How do we deal with that now with Silverlight clients??

hope that helps,

Harshit

hpwillbe

Loading...
Joined on 09-17-2007
Posts 8
04-10-2008 3:08 PM
Re: Silverlight Client and WCF Service - System.ServiceModel.ProtocolException-UnexpectedHttpResponseCode

You had me excited there for a second, but it turns out that although I am having a similar problem, I had already set it up to use basic binding.

 Here is the error:

A first chance exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll

Additional information: [UnexpectedHttpResponseCode]

Arguments:Not Found

Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=2.0.30226.2&File=System.ServiceModel.dll&Key=UnexpectedHttpResponseCode

I've been working on this on an off since beta 2 release. 

Here is my service model config on the wcf host:

<system.serviceModel>

<services>

<service name="FamilyTree.WCFService.FamilyTreeService" behaviorConfiguration="FamilyTreeBehavior">

<endpoint address="" binding="basicHttpBinding" contract="FamilyTree.WCFService.IFamilyTreeService">

<identity>

<dns value="localhost"/>

</identity>

</endpoint>

<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>

<host>

<baseAddresses>

<add baseAddress="http://cepalin/FamilyTree.WCFService/FamilyTreeService.svc"/>

</baseAddresses>

</host>

</service>

</services>

<behaviors>

<serviceBehaviors>

<behavior name="FamilyTreeBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true"/>

</behavior>

</serviceBehaviors> </behaviors>

</system.serviceModel>

Here it is on the silverlight host:

<system.serviceModel>

<bindings>

<basicHttpBinding>

<binding name="BasicHttpBinding_IFamilyTreeService" 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="None">

<transport clientCredentialType="None" proxyCredentialType="None"

realm="" />

<message clientCredentialType="UserName" algorithmSuite="Default" />

</security>

</binding>

</basicHttpBinding>

</bindings>

<client>

<endpoint address=http://cepalin/FamilyTree.WCFService/FamilyTreeService.svc

binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFamilyTreeService"

contract="FamilyTreeService.IFamilyTreeService" name="BasicHttpBinding_IFamilyTreeService" />

</client>

</system.serviceModel>

 

 

Carlos63

Loading...
Joined on 04-10-2008
Posts 3
04-28-2008 7:10 AM
Re: Silverlight Client and WCF Service - System.ServiceModel.ProtocolException-UnexpectedHttpResponseCode
SionnachRoe

Loading...
Joined on 04-28-2008
Posts 1
05-05-2008 5:14 PM
Re: Silverlight Client and WCF Service - System.ServiceModel.ProtocolException-UnexpectedHttpResponseCode

I think my experience may be helpful to someone: the message "UnexpectedHttpResponseCode" is very misleading.  In my case,  my service is trying to access database by myserver\ASPNET user. Once I setup a login for my service in the database, the application runs without problem.
 

codism

Loading...
Joined on 03-21-2008
Posts 86
Page view counter