Skip to main content

Microsoft Silverlight

Answered Question Silverlight beta 2 WCF service 404 errorRSS Feed

(0)

geimas5
geimas5

Member

Member

60 points

30 Posts

Silverlight beta 2 WCF service 404 error

when I try to call a WCF service from my Silverlight application I get a 404 error. when I use "Web development helper" to view the request I see that it doesn't even hit the service, only the Clientaccesspolicy.xml file, and I see that the actual content of the file is returned through the response body.

 Any thoughts?

 Details:

The service is hosted on a different machine, a windows 2003 server on the local network.
I have no problem calling a asmx service on the same computer, in the same directory(same project actually).
The Silverlight application is hosted in a web application on local IIS in http://localhost/AdministrationToolsWeb
I attempt to access the remote service using hostname(not ip): http://virwinserv01/...%5bPath%20here%5d.../IIsMan.svc
For my service i used the Silverlight WCF template.
I have no problem accessing the web service in the browser.
I have the same problem calling the authentication service after I have followed the instructions in this video: http://silverlight.net/learn/learnvideo.aspx?video=56228

My clientaccesspolicy.xml file:
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="*">
        <domain uri="*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

Exception details:

System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (404) Not Found.
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult 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 AdministrationTools.AuthenticationService.AuthenticationServiceClient.AuthenticationServiceClientChannel.EndLogin(IAsyncResult result)
   at AdministrationTools.AuthenticationService.AuthenticationServiceClient.AdministrationTools.AuthenticationService.AuthenticationService.EndLogin(IAsyncResult result)
   at AdministrationTools.AuthenticationService.AuthenticationServiceClient.OnEndLogin(IAsyncResult result)
   at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}

 

geimas5
geimas5

Member

Member

60 points

30 Posts

Re: Silverlight beta 2 WCF service 404 error

No one?

bartczernicki
bartczer...

Contributor

Contributor

4172 points

730 Posts

Re: Silverlight beta 2 WCF service 404 error

 

If you are returning large amounts of data you need to set the appropriate settings inside your web.config for bindings:

...

<binding name="LargeBuffer" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">

<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"

maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

</binding>

...

Also make sure your ServiceReferences.config in the Silverlight project needs the appropriate buffer settings:

<binding name="LargeBuffer" maxBufferSize="9999999" maxReceivedMessageSize="9999999">

<security mode="None" />

</binding>

geimas5
geimas5

Member

Member

60 points

30 Posts

Re: Silverlight beta 2 WCF service 404 error

the asmx version that returns pretty much the same data returns about 1000 bytes, so the size shouldn't be a problem.

doolittle
doolittle

Member

Member

74 points

26 Posts

Re: Silverlight beta 2 WCF service 404 error

Where is your WCF-service hosted?

Because it is very important that clientaccesspolicy.xml is in the root of your web-sit.

So for instance http://localhost/clientaccesspolicy.xml or http://virwinserv01/clientaccesspolicy.xml.

The tool 'fiddler' has helped me a lot to find the solution of such problems, maybe you should try finding the cause with that tool...

O, and do you have a crossdomain.xml?  Because you need that aswell...

Hope you can find the solution.   

geimas5
geimas5

Member

Member

60 points

30 Posts

Re: Silverlight beta 2 WCF service 404 error

yes its hosted and is available at the root of the site with http://virwinserv01/clientaccesspolicy.xml.

No i do not have s crossdomain-xml, you do not need both. looking at the logs it dose not ask for one either.

WJamesLord
WJamesLord

Member

Member

138 points

118 Posts

Re: Silverlight beta 2 WCF service 404 error

Oddly, I've seen a 404 error returned if there is a bug in the web service.

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Silverlight beta 2 WCF service 404 error

Most 404 errors people have seen in beta 2 so far are related to the cross-domain issue. Some of them are related to data size issue (also a configuration change).

People have all different ways to host and call their web service. So there is no single solution to solve them all. Do a search on 404 error (after beta2 release date) you might find serveral threads people have discussed this issue. Most people found their solution at the end.

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

johnpapa
johnpapa

Member

Member

8 points

9 Posts

Silverlight MVP

Re: Silverlight beta 2 WCF service 404 error

When you say "when I use "Web development helper" to view the request I see that it doesn't even hit the service, only the Clientaccesspolicy.xml file," is WebDevHelper showing you the exact location of where it looks for the ClientAccessPolicy.xml file? Is that line yielding the 404? Make sure the file is in the location it is looking for it. It needs to be in the web root and not the web app root.

geimas5
geimas5

Member

Member

60 points

30 Posts

Re: Silverlight beta 2 WCF service 404 error

johnpapa:

When you say "when I use "Web development helper" to view the request I see that it doesn't even hit the service, only the Clientaccesspolicy.xml file," is WebDevHelper showing you the exact location of where it looks for the ClientAccessPolicy.xml file? Is that line yielding the 404? Make sure the file is in the location it is looking for it. It needs to be in the web root and not the web app root.

Yes using Web development helper, I see the exact location that it looks for the clientaccesspolicy.xml file. it returns a 200 and when I look at the response body I see the correct content(as pasted in my initial post). so this is not a custom error message issues. yes the clientaccesspolicy.xml file is located at my webroot: http://virwinserrv01/clientaccesspolicy.xml.

When I say that it doesn't hit the service i mean that it does not even try. after the clientaccesspolicy.xml file is returned from the server, not a single request is sendt from the Silverlight application.

@sladaper:
I always google and experiment for hours before I try asking (finding the answer on my own is the best way to learn in my opinion). I only ask when I'm stuck and are not getting anywhere on my own. so yeah, I have already gone through all the posts on this forum (and many other sites I found googling) but to no avail.

@WJamesLord:
Its quite possible that there is a bug somewhere, but I have tried using the video with the built-in authentication service with no luck. so I think the "bug" is a config issue. I was kind of expecting it to be something really easy that someone would quickly point out. I will post some related web.config, etc. in a few hours, maybe there is something there that I have missed.

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Re: Silverlight beta 2 WCF service 404 error

Geimas5,

Was this working in beta 1? Could you check the URL for your service endpoint on your ServiceReference.ClientConfig and what is it? Since this is WCF service, what binding you set on the Web.config on your Service Site?

 

 

 

 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

geimas5
geimas5

Member

Member

60 points

30 Posts

Re: Silverlight beta 2 WCF service 404 error

sladapter:

Geimas5,

Was this working in beta 1? Could you check the URL for your service endpoint on your ServiceReference.ClientConfig and what is it? Since this is WCF service, what binding you set on the Web.config on your Service Site?

  This is a new beta 2 project.

 Endpoint in ServiceReference.ClientConfig:

            <endpoint address="http://virwinserv01/AdministrativeToolsService/AuthenticationService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_AuthenticationService"
                contract="AdministrationTools.AuthenticationService.AuthenticationService"
                name="BasicHttpBinding_AuthenticationService" />

 

Binding in web.config:

      <basicHttpBinding>
        <binding name="userHttp">
          <!-- this is for demo only. Https/Transport security is recommended -->
          <security mode="None"/>
        </binding>
      </basicHttpBinding>

Service in web.config:
      <!-- this enables the WCF AuthenticationService endpoint -->
      <service name="System.Web.ApplicationServices.AuthenticationService"
               behaviorConfiguration="AuthenticationServiceTypeBehaviors">
        <endpoint contract="System.Web.ApplicationServices.AuthenticationService"
                  binding="basicHttpBinding" bindingConfiguration="userHttp"
                  bindingNamespace="http://asp.net/ApplicationServices/v200"/>
      </service>

 

And yes, i do have this part aswell:

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
  </system.serviceModel>
  <system.web.extensions>
    <scripting>
      <webServices>
        <authenticationService enabled="true" requireSSL="false"/>
      </webServices>
    </scripting>
  </system.web.extensions>

 

the other wcf services im trying to set up is configured in about the same way.

johnpapa
johnpapa

Member

Member

8 points

9 Posts

Silverlight MVP

Re: Silverlight beta 2 WCF service 404 error

I would test to see if you can reference this WCF service from a standard WinForm client jsut as a test to see if its the service or the communicaiton with Silverlight that is off.

SteveWong
SteveWong

Contributor

Contributor

6343 points

1,281 Posts

Answered Question

Re: Silverlight beta 2 WCF service 404 error

geimas5:

  This is a new beta 2 project.

 Endpoint in ServiceReference.ClientConfig:

            <endpoint address="http://virwinserv01/AdministrativeToolsService/AuthenticationService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_AuthenticationService"
                contract="AdministrationTools.AuthenticationService.AuthenticationService"
                name="BasicHttpBinding_AuthenticationService" />

Binding in web.config:

      <basicHttpBinding>
        <binding name="userHttp">
          <!-- this is for demo only. Https/Transport security is recommended -->
          <security mode="None"/>
        </binding>
      </basicHttpBinding>

Service in web.config:
      <!-- this enables the WCF AuthenticationService endpoint -->
      <service name="System.Web.ApplicationServices.AuthenticationService"
               behaviorConfiguration="AuthenticationServiceTypeBehaviors">
        <endpoint contract="System.Web.ApplicationServices.AuthenticationService"
                  binding="basicHttpBinding" bindingConfiguration="userHttp"
                  bindingNamespace="http://asp.net/ApplicationServices/v200"/>
      </service>

the other wcf services im trying to set up is configured in about the same way.

I think your ServiceReference.clientconfig should be like this

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_AuthenticationService" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647"
>
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="
http://virwinserv01/AdministrativeToolsService/AuthenticationService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_AuthenticationService"
                contract="AdministrationTools.AuthenticationService.AuthenticationService"
                name="BasicHttpBinding_AuthenticationService" />
        </client>
    </system.serviceModel>
</configuration>

For your Service should also be like this

<basicHttpBinding>
        <binding name="userHttp" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
           maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None"/>
        </binding>
      </basicHttpBinding>

Try if it works, but I wonder there should be some problem of the service contract there

Regards,
SteveWong (HongKong)
Please mark post as answer if they help you

Client App Dev

sladapter
sladapter

All-Star

All-Star

17441 points

3,172 Posts

Answered Question

Re: Silverlight beta 2 WCF service 404 error

geimas5,

The configuration file looks all right. And you said you already put the new clientaccesspolicy.xml file on your virwinserv01 server under inetput\wwwroot folder.  I can't think of anything else.

Do you have a large data to send back on your service call? If not, the buffer size setting change in the binding won't help you. If you do send a relatively large data ( say size is > 18KB or string length > 8200 chars), then you need change the buffer size.

If you do need change the buffer size use WCF service configuration editor (under tools) to do these changes. Here is the steps for doing that just in case you want to try it.

Open the web.config of your Service Web using WCF Service Configuration Editor:

  • Click the Bindings folder and add a new basicHttpBinding give it a name something like "LargeBuffer".
  • Change the number in MaxBufferSize/MaxReceivedMessageSize/MaxArrayLenght/MaxBytesPerRead/MaxDepth/MaxNameTableCharCount/MaxStringContentLenght to a large number. Those fields are integer fields. So the max number you can enter is 2147483647 which is the upper limit of a integer.
  • Find the first endpoint under Service Folder for Your Service, Click the BindingConfiguration and select the "LargeBuffer" binding you just created.
  • Save the web.config.
Use the same WCF Service Configuration Editor to open ServiceReferences.ClientConfig file under Silverlight project.
  • You should see your service under Client/EndPoints folder. Open that endpoint. That endpoint has bindingConfiguration set to BasicHttpBinding_YourService. Goto that binding and change the MaxBufferSize/MaxReceivedMessageSize(Just those 2 fields, not fields under the ReaderQuotasProperties)  to the same large number you set in the Web.Config.
  • Save the config file
Now you can try to run your app.
 


 

sladapter
Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities