Finally after 3 days and nights i was able to find the solution for hosting RIA services on shared hosting environment and without changing anything on IIS. Yes it is possible…
Why : RIA framework dynamically creates WCF service (Domain services) and add endpoints to the service.It first check if endpoint does’nt exist then create it,and it checks for 3 endpoints (http,soap and binary).After creating end points it adds authentication schema to end points.It picks IIS authentication schema’s and tries to apply on end points and failed to apply.
If we could create desired end points in web.config RIA framework will not create or do anything with endpoints and it works succesfully ..
You just need to follow the simple steps mentioned below :
1. Add following code to you web.config to solve issue “This collection already contains an address with scheme http..”
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"> <baseAddressPrefixFilters> <add prefix="http://www.yoursite.com"/> </baseAddressPrefixFilters> </serviceHostingEnvironment>
Note: Your service can be only accessed by url mentioned in above settings. As configured above you can’t access your service via http://yoursite.com.
You could also use factory code to host WCF (see below) to resolve this error however alone with that you need to create svc files for each domain service.
2.Add AspNetCompatibilityRequirementsMode attribute to your RIA Domain services classes
Eg .Attrubtes added to AuthenticationService class under services folder
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class AuthenticationService : AuthenticationBase<User> { }
RIA framework dynamically apply these attributes after creating end points.Since we are now bypassing endpoint creation , we need to manually apply these attributes.
3. For each RIA domain service add following to you configuration file.
Eg. Is shown for AuthenticationService and UserRegistrationService
Where SparkExams is my custom namespace.
<services> <service name="SparkExams.Web.AuthenticationService" behaviorConfiguration="RIAServiceBehavior"> <endpoint address="" binding="wsHttpBinding" contract="SparkExams.Web.AuthenticationService" /> <endpoint address="/soap" binding="basicHttpBinding" contract="SparkExams.Web.AuthenticationService" /> <endpoint address="/binary" binding="customBinding" bindingConfiguration="BinaryHttpBinding" contract="SparkExams.Web.AuthenticationService" /> </service> <service name="SparkExams.Web.UserRegistrationService" behaviorConfiguration="RIAServiceBehavior"> <endpoint address="" binding="wsHttpBinding" contract="SparkExams.Web.UserRegistrationService" /> <endpoint address="/soap" binding="basicHttpBinding" contract="SparkExams.Web.UserRegistrationService" /> <endpoint address="/binary" binding="customBinding" bindingConfiguration="BinaryHttpBinding" contract="SparkExams.Web.UserRegistrationService" /> </service>
Please note that RIA adds 3 endpoints and if any of these endpoints are missing from web.config it will throw “IIS specified authentication schemes ‘Basic, Anonymous’…” error.
Add following behaviours and bindings to your web.config
<behaviors> <serviceBehaviors> <behavior name="RIAServiceBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <bindings> <customBinding> <binding name="BinaryHttpBinding"> <binaryMessageEncoding /> <httpTransport /> </binding> </customBinding> </bindings>
Test you wcf end points using WCF client test tool (Test client for Windows Communication Foundation services.) WcfTestClient.exe : Go to VS 2008 Console and type WcfTestClient.exe.
Note that there is no need to host you service,or change IIS settings by ISP.
Update : While working on SL project i have noticed that SL is not able to recieve faults/exceptions thrown by RIA domain service.Please follow article to fix the issue “Silverlight Faults in SL 3.0 with RIA Domain Services – Fix 2“ – Must read
Finally code and live demo application link are here..
Demo Application link
/rajnish/RiaTest/
Custom service link
/rajnish/RiaTest/DeployTest-Web-services-CustomService.svc
Link to binay files for above links
/rajnish/uploads/code/RiaTest/Binary.zip
//Source code of application (Web.config has been changed in binary.zip)
/rajnish/uploads/code/RiaTest/Source.zip
If you are having any problem related to hosting Sl,copy binay.zip contents to your virtual directory on web server and modify web.config (bottom)
add prefix=”/rajnish/”
If you have any problem with your code , then please download the binary.zip extract the contents and create virtual directory say RiaTest on your domain and copy the contents of Binary.zip (files like Default.aspx,DeployTestTestPage.aspx etc) to your web server.Change web.config “prefix section as mentioned above.Eg. on my webserver www.rajneeshnoonia.com i have created RiaTest virtual directory and copyied the contents of binary.zip into it.first step is to test your web service with URL like /rajnish/RiaTest/DeployTest-Web-services-CustomService.svc. if web service is ok you can launch your silverlight application.
Note: the site will not work if you try to launch with /rajnish/… rather it will work if you try /rajnish/…
What is your configuration i.e. Which Silverlight version, Which .NET version and Which RIA Services version?
LikeLike
Silverlight 3.0 , .Net 3.5 Sp1,WCF RIA Services Beta for Visual Studio 2008 SP1Visual Studio 2008 SP1
LikeLike
Can you please publish an example project? I tried it, but didn't worked. :(Endre
LikeLike
i have tried this but still getting exceptionLoad operation failed for query 'DjelatniciSelect'. The remote server returned an error: NotFound. at System.Windows.Ria.OperationBase.Complete(Exception error) at System.Windows.Ria.LoadOperation.Complete(Exception error) at System.Windows.Ria.DomainContext.CompleteLoad(IAsyncResult asyncResult) at System.Windows.Ria.DomainContext.<>c__DisplayClass17.b__13(Object )
LikeLike
I posted previous comment. Problem was on IIS there was ISAFilter check box to check if file exists. This must be turned off because RIA services are created dynamicly .. so they dont exists
LikeLike
Hi Rajneesh,After a lot of searching on the internet I finally found your posting.. Just implemented it and it WORKS!!Thanks for the great post !!J.W.
LikeLike
Hello RajneeshThanks for great post.Lot of stuff got clear.I tried out all your steps but it didnt go through.I am using Silverlight 4 with WCF Ria Services in VS 2010 Beta 2. The app works great on dev enviornment but when I deploy the app on the staging server (Win2k3 with IIS 6),I am getting this errorA binding instance has already been associated to listen URI 'http://localhost/NOMDeploy/Services/NOM-Web-NOMDomainService.svc/soap'. If two endpoints want to share the same ListenUri, they must also share the same binding object instance. The two conflicting endpoints were either specified in AddServiceEndpoint() calls, in a config file, or a combination of AddServiceEndpoint() and configNomDomainService is my custom DomainService classBelow is the web.config file of my app
LikeLike
I get an error on the first step on the web.config file:Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Unrecognized configuration section system.serviceModel/baseAddressPrefixFilters.Source Error: Line 20: <system.serviceModel>Line 21: <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />Line 22: <baseAddressPrefixFilters>Line 23: <add prefix="http://www.mysite.com" />Line 24: </baseAddressPrefixFilters>
LikeLike
Rajneesh, I tried to implement your steps but to no avail. I failed at step 2 as my domain service class did not support AspNetCompatibilityRequirements attribute. Can you please enlighten me?
LikeLike
Brad : For error "Unrecognized configuration section system.serviceModel/baseAddressPrefixFilters."Please check your asp.net version configured in IIS.This error will apear if you are using asp.net version 1.1 in IIS configurations.Version asp.net 2.0 is requiredJon : For aspnetcompatiblityrequirement attribute you must include "using System.ServiceModel.Activation;" [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]By this week (expected by tomorrow morning – tuesday) i will publish the working example On RIA business applications alone with asp.net web.config file.Link for download will be available in the same blog .
LikeLike
Rajneesh, you are all powerful. Your serviceContract emulates the default WCF RIA serviceContract on my localhosted web app when I remove the . My development server is not multi-homed. But, I another reason for customizing the serviceContract: http://forums.silverlight.net/forums/p/164399/370279.aspx#370279. Everything is working until I add the RequiresAuthentication attribute to my DomainServices. It looks like Silverlight/RIA and ASP.NET are using different authentication cookies.
LikeLike
Sorry, I tried to say "remove the <baseAddressPrefixFilters> above but forgot to use HTML entities for the angle brackets.
LikeLike
I was very hopeful when reading this posting. Thanks so much for publishing this. Unfortunately, it didn't work for me. I checked the Auth and User registration services which are working fine. When I publish to my shared hosting server at discountasp.net I get a Load Operation Failed for Query 'Get User' error. Fiddler shows a 500 status code with a description of Could not load file or assembly 'System.Web.Ria, Version=2.0.0.0'. I did in fact set this assembly to Copy Local = true and i see it in the /bin folder. I don't know what else to do, any help would be GREATLY appreciated.
LikeLike
it had work and i am using it in all my silverlight project.To resolve your problem please try to launch the svc file directly in the browser and see what come up.For example if your service class is XXX.Web.Services.MySevice then url should be something like http://www.yourWebsite.com/Silverlightapplication/Services/XXX-Web-Services-MyService.svcNormally it should come up with message saying you have succesfully created web service..Please post the errors it you recieve any .. i will try to resolve the issue.. Thanks..
LikeLike
Thank you so much for offering to help. When I access my URL like this the service works: http://www.my_domain.com/virDir/MyBusinessApplication-Web-AuthenticationService.svcWhen I use the following I get an error:http://www.my_domain.com/Services/MyBusinessApplication-Web-AuthenticationService.svcThe error is…Could not load file or assembly 'System.Web.Ria, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.Please note that I have set the System.Web.Ria reference property to CopyLocal=true. I double checked that it is in the /bin folder when I publish my site to the discountasp.net server. Thanks!
LikeLike
Have you also deployed all dependent assemblies eg. System.Web.DomainServices.dll ?Please check all your assemblies and set CopyLocal=true for all assemblies whose path is something like "C:Program FilesMicrosoft SDKsRIA Servicesv1.0LibrariesServerSystem.Web.DomainServices.dll"I have just compiled sample SL3 code to test this fix. Will try to upload this by today. You may than just download, deploy and change config file to test RIA on shared hosting domain. Don't forget to read Silverlight fault fix mentioned in the bottom of the post. Thanks
LikeLike
Finally code and live demo application link are here..Demo Application linkhttp://www.par-is.com/RiaTest/DeployTestTestPage.aspx#/HomeDemo Custom service linkhttp://www.par-is.com/RiaTest/services/DeployTest-Web-services-CustomService.svcLink to binay files for above linkshttp://www.par-is.com/RiaTest/Code/Binary.zip//Source code of application (Web.config has been changed in binary.zip)http://www.par-is.com/RiaTest/Code/Source.zipIf you are having any problem related to hosting Sl,copy binay.zip contents to your virtual directory on web server and modify web.config (bottom) add prefix="http://www.par-is.com/" Thanks
LikeLike
I have put every assembly from my web project into the bin folder, just to be sure I wasn't missing any, but I still get the same error. I downloaded the sample you posted. The only difference in our config files is that I did not configure the profile section. Instead I disabled that section and commented out the code in the user.cs and shared user files. I am going to try to configure this section and see if that is the problem. Thanks for posting this, your blog is a great resource for developers.
LikeLike
I don't think this is related with profile sections.In 1st stage try to upload binary code i have posted and just change the web.config – prefix="http://www.par-is.com/" parameter.If that works it means your enviornment is ok and you are missing some thing else , then try step by step.. 2nd stage try to launch your web service.
LikeLike
Thank you. I loaded up the binary and I still get the same error. I'm contacting discountasp.net. I'm convinced something is wrong on the server. I appreciate all your help.at System.Windows.Ria.OperationBase.InvokeCompleteAction() at System.Windows.Ria.OperationBase.Complete(Exception error) at System.Windows.Ria.LoadOperation.Complete(Exception error) at System.Windows.Ria.DomainContext.CompleteLoad(IAsyncResult asyncResult) at System.Windows.Ria.DomainContext.<>c__DisplayClass17.b__13(Object )
LikeLike
I contacted discountasp.net and they said everything is set up correctly.
This is the request that is returning the 500 error:
POST /ClientBin/DeployTest-Web-AuthenticationService.svc/binary HTTP/1.1
My web service still says:
Server Error in ‘/Services’ Application.
——————————————————————————–
Could not load file or assembly ‘System.Web.Ria, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified.
I can’t understand this error becuase the binary you supplied has these files in the /bin folder. Also, this error seems incorrect because if I remove the System.Web.Ria assembly the start up page would throw and error.
LikeLike
Hi, I got it to run. This is really dumb buy I had the file structure set up incorrectly on their server. I’m new to web development and didn’t quite understand how the web application tool on the site was working. Anyway, thanks for posting your code, the fault fix is very helpful.
LikeLike
Hi!
I wonder if anyone found the way to set the receive and send timeout for each of the 3 bindings mentioned here in the post. Thank you very much.
Middlevn.
LikeLike
You needs to create bindings for each end point and attach binding with end points using bindingConfiguration=”YourBinfConfigName” and specify receiveTimeout=”00:10:00″ sendTimeout=”00:10:00″ in your binding configurations.
See MS link: http://msdn.microsoft.com/en-us/library/system.servicemodel.basichttpbinding.aspx
Note that binding configurations for eand point /binary is already declared so you need to specify just receiveTimeout=”00:10:00″ sendTimeout=”00:10:00″.
Moreover your client application is using only one type of end point so configure single end point instead of all..
Regards
Rajneesh
LikeLike
Hi Rajneesh,
I agree with you that the endpoint /binary is already there. But It seems that adding receiveTimeout=”00:10:00″ sendTimeout=”00:10:00″ didn’t effect the final auto generate config. Here is the output of WCFClientTest.exe:
Have you check this?
It seems that the only way to change this is changing in the http module of RIA WCF (where it auto-generate the WCF configuration for these endpoints) but I still haven’t figure how. Do you have any idea dealing with this? Thanks.
Regards,
Middlevn
LikeLike
Here is the output of WCFClientTest.exe:
instead of I configured:
And the timeout of default 60s still there..
LikeLike
Sorry Rajneesh, I don’t know why I couldn’t add any xml into the replys.
LikeLike
Code:Put code in `
backticks
` (above your “Tab” key)eg.
Here goes my XML or code
`
(One backtick here not visible)
`(another backtick here not visible)__abENT__lt;httpProtocol__abENT__gt;
__abENT__lt;customHeaders__abENT__gt;
__abENT__lt;clear __abENT__#8260;__abENT__gt;
__abENT__lt;add name=__abENT__quot;X-Powered-By__abENT__quot; value=__abENT__quot;ASP__abENT__#46;NET__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;__abENT__#8260;customHeaders__abENT__gt;
__abENT__lt;__abENT__#8260;httpProtocol__abENT__gt;
Just added this support…
I have used Red gates .net reflector to check code inside C:Program FilesMicrosoft SDKsRIA Servicesv1.0LibrariesServerSystem.Web.Ria.dll,There is a function AddEndpoints()
in class System.Web.Ria.Services.DomainServiceHost which adds end points if they doesn’t exist.
Another function AddDefaultBehaviors() is called from ApplyConfiguration() to add default behaviour to the end point.. code is below
`
protected virtual void AddDefaultBehaviors()
`{
ServiceUtility__abENT__#46;EnsureBehavior__abENT__lt;AspNetCompatibilityRequirementsAttribute__abENT__gt;(base__abENT__#46;Description)__abENT__#46;RequirementsMode = AspNetCompatibilityRequirementsMode__abENT__#46;Required;
ServiceBehaviorAttribute attribute2 = ServiceUtility__abENT__#46;EnsureBehavior__abENT__lt;ServiceBehaviorAttribute__abENT__gt;(base__abENT__#46;Description);
attribute2__abENT__#46;InstanceContextMode = InstanceContextMode__abENT__#46;PerCall;
attribute2__abENT__#46;IncludeExceptionDetailInFaults = true;
attribute2__abENT__#46;AddressFilterMode = AddressFilterMode__abENT__#46;Any;
ServiceUtility__abENT__#46;EnsureBehavior__abENT__lt;ServiceMetadataBehavior__abENT__gt;(base__abENT__#46;Description)__abENT__#46;HttpGetEnabled = true;
}
I don’t find any code which is sets behaviours dynamically apart from AddEndpoints()
`
protected virtual void AddEndpoints()
`{
if (!ServiceUtility__abENT__#46;ContainsEndpointAtAddress(base__abENT__#46;Description, __abENT__quot;__abENT__quot;))
{
foreach (Uri uri in base__abENT__#46;BaseAddresses)
{
this__abENT__#46;AddRestWithJsonEndpoint(uri);
}
}
if (!ServiceUtility__abENT__#46;ContainsEndpointAtAddress(base__abENT__#46;Description, __abENT__quot;__abENT__#8260;soap__abENT__quot;))
{
foreach (Uri uri2 in base__abENT__#46;BaseAddresses)
{
this__abENT__#46;AddSoapWithXmlEndpoint(uri2);
}
}
if (!ServiceUtility__abENT__#46;ContainsEndpointAtAddress(base__abENT__#46;Description, __abENT__quot;__abENT__#8260;binary__abENT__quot;))
{
foreach (Uri uri3 in base__abENT__#46;BaseAddresses)
{
this__abENT__#46;AddSoapWithBinaryEndpoint(uri3);
}
}
}
Note that your web.config has these end points so if block always return false.
LikeLike
Here is my Web.config’s content:
First:
‘
Then
Then
And
‘
Output from WCFTestClient.exe:
‘
‘
You can see the gernerated bindingConfiguration “CustomBinding_AuthenticationService” (for “/binary” endpoint) don’t have the send and receive timeouts. Moreover, all other endpoints were unchanged according to the config in my Web.config.
So, should I need to do anything else (i.e creating custom service host) to make it apply the config? Thanks a lot.
Regards,
Middlevn
LikeLike
1st
`
__abENT__lt;serviceHostingEnvironment aspNetCompatibilityEnabled=__abENT__quot;true__abENT__quot; __abENT__gt;
`__abENT__lt;baseAddressPrefixFilters__abENT__gt;
__abENT__lt;add prefix=__abENT__quot;http:__abENT__#8260;__abENT__#8260;localhost:52878__abENT__quot;__abENT__#8260;__abENT__gt;
__abENT__lt;__abENT__#8260;baseAddressPrefixFilters__abENT__gt;
__abENT__lt;__abENT__#8260;serviceHostingEnvironment__abENT__gt;
__abENT__#46;__abENT__#46;
__abENT__lt;behavior name=__abENT__quot;RIAServiceBehavior__abENT__quot;__abENT__gt;
__abENT__lt;serviceMetadata httpGetEnabled=__abENT__quot;true__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;serviceDebug includeExceptionDetailInFaults=__abENT__quot;false__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;dataContractSerializer maxItemsInObjectGraph=__abENT__quot;2147483647__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;__abENT__#8260;behavior__abENT__gt;
__abENT__#46;__abENT__#46;
__abENT__lt;bindings__abENT__gt;
__abENT__lt;wsHttpBinding__abENT__gt;
__abENT__lt;binding name=__abENT__quot;wsHttpBinding__abENT__quot; openTimeout=__abENT__quot;00:02:00__abENT__quot; receiveTimeout=__abENT__quot;00:15:00__abENT__quot;
sendTimeout=__abENT__quot;00:04:00__abENT__quot; bypassProxyOnLocal=__abENT__quot;true__abENT__quot; maxReceivedMessageSize=__abENT__quot;2147483647__abENT__quot;__abENT__gt;
__abENT__lt;__abENT__#8260;binding__abENT__gt;
__abENT__lt;__abENT__#8260;wsHttpBinding__abENT__gt;
__abENT__lt;basicHttpBinding__abENT__gt;
__abENT__lt;binding name=__abENT__quot;basicHttpBinding__abENT__quot; openTimeout=__abENT__quot;00:02:00__abENT__quot; receiveTimeout=__abENT__quot;00:15:00__abENT__quot;
sendTimeout=__abENT__quot;00:05:00__abENT__quot; bypassProxyOnLocal=__abENT__quot;true__abENT__quot; maxReceivedMessageSize=__abENT__quot;2147483647__abENT__quot;__abENT__gt;
__abENT__lt;__abENT__#8260;binding__abENT__gt;
__abENT__lt;__abENT__#8260;basicHttpBinding__abENT__gt;
__abENT__lt;customBinding__abENT__gt;
__abENT__lt;binding name=__abENT__quot;BinaryHttpBinding__abENT__quot;
receiveTimeout=__abENT__quot;00:15:00__abENT__quot;
sendTimeout=__abENT__quot;00:10:00__abENT__quot;
openTimeout=__abENT__quot;00:10:00__abENT__quot;
closeTimeout=__abENT__quot;00:10:00__abENT__quot;__abENT__gt;
__abENT__lt;binaryMessageEncoding maxReadPoolSize=__abENT__quot;2147483647__abENT__quot; maxWritePoolSize=__abENT__quot;2147483647__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;httpTransport maxReceivedMessageSize=__abENT__quot;65536__abENT__quot; maxBufferSize=__abENT__quot;65536__abENT__quot;
maxBufferPoolSize=__abENT__quot;524288__abENT__quot; transferMode=__abENT__quot;Buffered__abENT__quot;
bypassProxyOnLocal=__abENT__quot;false__abENT__quot; useDefaultWebProxy=__abENT__quot;true__abENT__quot;__abENT__#8260;__abENT__gt;
__abENT__lt;__abENT__#8260;binding__abENT__gt;
__abENT__lt;__abENT__#8260;customBinding__abENT__gt;
__abENT__lt;__abENT__#8260;bindings__abENT__gt;
__abENT__#46;__abENT__#46;
__abENT__lt;service name=__abENT__quot;MyApp__abENT__#46;Web__abENT__#46;AuthenticationService__abENT__quot;
behaviorConfiguration=__abENT__quot;RIAServiceBehavior__abENT__quot;__abENT__gt;
__abENT__lt;endpoint address=__abENT__quot;__abENT__quot; binding=__abENT__quot;wsHttpBinding__abENT__quot;
contract=__abENT__quot;MyApp__abENT__#46;Web__abENT__#46;AuthenticationService__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;endpoint address=__abENT__quot;__abENT__#8260;soap__abENT__quot;
binding=__abENT__quot;basicHttpBinding__abENT__quot;
contract=__abENT__quot;MyApp__abENT__#46;Web__abENT__#46;AuthenticationService__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;endpoint address=__abENT__quot;__abENT__#8260;binary__abENT__quot;
binding=__abENT__quot;customBinding__abENT__quot;
bindingConfiguration=__abENT__quot;BinaryHttpBinding__abENT__quot;
contract=__abENT__quot;MyApp__abENT__#46;Web__abENT__#46;AuthenticationService__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;__abENT__#8260;service__abENT__gt;
2nd:
`
__abENT__lt;?xml version=__abENT__quot;1__abENT__#46;0__abENT__quot; encoding=__abENT__quot;utf-8__abENT__quot;?__abENT__gt;
`__abENT__lt;configuration__abENT__gt;
__abENT__lt;system__abENT__#46;serviceModel__abENT__gt;
__abENT__lt;bindings__abENT__gt;
__abENT__lt;basicHttpBinding__abENT__gt;
__abENT__lt;binding name=__abENT__quot;BasicHttpBinding_AuthenticationService__abENT__quot; closeTimeout=__abENT__quot;00:01:00__abENT__quot;
openTimeout=__abENT__quot;00:01:00__abENT__quot; receiveTimeout=__abENT__quot;00:10:00__abENT__quot; sendTimeout=__abENT__quot;00:01:00__abENT__quot;
allowCookies=__abENT__quot;false__abENT__quot; bypassProxyOnLocal=__abENT__quot;false__abENT__quot; hostNameComparisonMode=__abENT__quot;StrongWildcard__abENT__quot;
maxBufferSize=__abENT__quot;65536__abENT__quot; maxBufferPoolSize=__abENT__quot;524288__abENT__quot; maxReceivedMessageSize=__abENT__quot;65536__abENT__quot;
messageEncoding=__abENT__quot;Text__abENT__quot; textEncoding=__abENT__quot;utf-8__abENT__quot; transferMode=__abENT__quot;Buffered__abENT__quot;
useDefaultWebProxy=__abENT__quot;true__abENT__quot;__abENT__gt;
__abENT__lt;readerQuotas maxDepth=__abENT__quot;32__abENT__quot; maxStringContentLength=__abENT__quot;8192__abENT__quot; maxArrayLength=__abENT__quot;16384__abENT__quot;
maxBytesPerRead=__abENT__quot;4096__abENT__quot; maxNameTableCharCount=__abENT__quot;16384__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;security mode=__abENT__quot;None__abENT__quot;__abENT__gt;
__abENT__lt;transport clientCredentialType=__abENT__quot;None__abENT__quot; proxyCredentialType=__abENT__quot;None__abENT__quot;
realm=__abENT__quot;__abENT__quot;__abENT__gt;
__abENT__lt;extendedProtectionPolicy policyEnforcement=__abENT__quot;Never__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;__abENT__#8260;transport__abENT__gt;
__abENT__lt;message clientCredentialType=__abENT__quot;UserName__abENT__quot; algorithmSuite=__abENT__quot;Default__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;__abENT__#8260;security__abENT__gt;
__abENT__lt;__abENT__#8260;binding__abENT__gt;
__abENT__lt;__abENT__#8260;basicHttpBinding__abENT__gt;
__abENT__lt;customBinding__abENT__gt;
__abENT__lt;binding name=__abENT__quot;CustomBinding_AuthenticationService__abENT__quot;__abENT__gt;
__abENT__lt;binaryMessageEncoding maxReadPoolSize=__abENT__quot;64__abENT__quot; maxWritePoolSize=__abENT__quot;16__abENT__quot;
maxSessionSize=__abENT__quot;2048__abENT__quot;__abENT__gt;
__abENT__lt;readerQuotas maxDepth=__abENT__quot;32__abENT__quot; maxStringContentLength=__abENT__quot;8192__abENT__quot; maxArrayLength=__abENT__quot;16384__abENT__quot;
maxBytesPerRead=__abENT__quot;4096__abENT__quot; maxNameTableCharCount=__abENT__quot;16384__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;__abENT__#8260;binaryMessageEncoding__abENT__gt;
__abENT__lt;httpTransport manualAddressing=__abENT__quot;false__abENT__quot; maxBufferPoolSize=__abENT__quot;524288__abENT__quot;
maxReceivedMessageSize=__abENT__quot;65536__abENT__quot; allowCookies=__abENT__quot;false__abENT__quot; authenticationScheme=__abENT__quot;Anonymous__abENT__quot;
bypassProxyOnLocal=__abENT__quot;false__abENT__quot; hostNameComparisonMode=__abENT__quot;StrongWildcard__abENT__quot;
keepAliveEnabled=__abENT__quot;true__abENT__quot; maxBufferSize=__abENT__quot;65536__abENT__quot; proxyAuthenticationScheme=__abENT__quot;Anonymous__abENT__quot;
realm=__abENT__quot;__abENT__quot; transferMode=__abENT__quot;Buffered__abENT__quot; unsafeConnectionNtlmAuthentication=__abENT__quot;false__abENT__quot;
useDefaultWebProxy=__abENT__quot;true__abENT__quot;__abENT__gt;
__abENT__lt;extendedProtectionPolicy policyEnforcement=__abENT__quot;Never__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;__abENT__#8260;httpTransport__abENT__gt;
__abENT__lt;__abENT__#8260;binding__abENT__gt;
__abENT__lt;__abENT__#8260;customBinding__abENT__gt;
__abENT__lt;wsHttpBinding__abENT__gt;
__abENT__lt;binding name=__abENT__quot;WSHttpBinding_AuthenticationService__abENT__quot; closeTimeout=__abENT__quot;00:01:00__abENT__quot;
openTimeout=__abENT__quot;00:01:00__abENT__quot; receiveTimeout=__abENT__quot;00:10:00__abENT__quot; sendTimeout=__abENT__quot;00:01:00__abENT__quot;
bypassProxyOnLocal=__abENT__quot;false__abENT__quot; transactionFlow=__abENT__quot;false__abENT__quot; hostNameComparisonMode=__abENT__quot;StrongWildcard__abENT__quot;
maxBufferPoolSize=__abENT__quot;524288__abENT__quot; maxReceivedMessageSize=__abENT__quot;65536__abENT__quot;
messageEncoding=__abENT__quot;Text__abENT__quot; textEncoding=__abENT__quot;utf-8__abENT__quot; useDefaultWebProxy=__abENT__quot;true__abENT__quot;
allowCookies=__abENT__quot;false__abENT__quot;__abENT__gt;
__abENT__lt;readerQuotas maxDepth=__abENT__quot;32__abENT__quot; maxStringContentLength=__abENT__quot;8192__abENT__quot; maxArrayLength=__abENT__quot;16384__abENT__quot;
maxBytesPerRead=__abENT__quot;4096__abENT__quot; maxNameTableCharCount=__abENT__quot;16384__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;reliableSession ordered=__abENT__quot;true__abENT__quot; inactivityTimeout=__abENT__quot;00:10:00__abENT__quot;
enabled=__abENT__quot;false__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;security mode=__abENT__quot;Message__abENT__quot;__abENT__gt;
__abENT__lt;transport clientCredentialType=__abENT__quot;Windows__abENT__quot; proxyCredentialType=__abENT__quot;None__abENT__quot;
realm=__abENT__quot;__abENT__quot;__abENT__gt;
__abENT__lt;extendedProtectionPolicy policyEnforcement=__abENT__quot;Never__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;__abENT__#8260;transport__abENT__gt;
__abENT__lt;message clientCredentialType=__abENT__quot;Windows__abENT__quot; negotiateServiceCredential=__abENT__quot;true__abENT__quot;
algorithmSuite=__abENT__quot;Default__abENT__quot; establishSecurityContext=__abENT__quot;true__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;__abENT__#8260;security__abENT__gt;
__abENT__lt;__abENT__#8260;binding__abENT__gt;
__abENT__lt;__abENT__#8260;wsHttpBinding__abENT__gt;
__abENT__lt;__abENT__#8260;bindings__abENT__gt;
__abENT__lt;client__abENT__gt;
__abENT__lt;endpoint address=__abENT__quot;http:__abENT__#8260;__abENT__#8260;localhost:52878__abENT__#8260;Services__abENT__#8260;MyApp-Web-AuthenticationService__abENT__#46;svc__abENT__quot;
binding=__abENT__quot;wsHttpBinding__abENT__quot; bindingConfiguration=__abENT__quot;WSHttpBinding_AuthenticationService__abENT__quot;
contract=__abENT__quot;AuthenticationService__abENT__quot; name=__abENT__quot;WSHttpBinding_AuthenticationService__abENT__quot;__abENT__gt;
__abENT__lt;identity__abENT__gt;
__abENT__lt;userPrincipalName value=__abENT__quot;Trung-LPT__abENT__#92;Trung__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;__abENT__#8260;identity__abENT__gt;
__abENT__lt;__abENT__#8260;endpoint__abENT__gt;
__abENT__lt;endpoint address=__abENT__quot;http:__abENT__#8260;__abENT__#8260;localhost:52878__abENT__#8260;Services__abENT__#8260;MyApp-Web-AuthenticationService__abENT__#46;svc__abENT__#8260;soap__abENT__quot;
binding=__abENT__quot;basicHttpBinding__abENT__quot; bindingConfiguration=__abENT__quot;BasicHttpBinding_AuthenticationService__abENT__quot;
contract=__abENT__quot;AuthenticationService__abENT__quot; name=__abENT__quot;BasicHttpBinding_AuthenticationService__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;endpoint address=__abENT__quot;http:__abENT__#8260;__abENT__#8260;localhost:52878__abENT__#8260;Services__abENT__#8260;MyApp-Web-AuthenticationService__abENT__#46;svc__abENT__#8260;binary__abENT__quot;
binding=__abENT__quot;customBinding__abENT__quot; bindingConfiguration=__abENT__quot;CustomBinding_AuthenticationService__abENT__quot;
contract=__abENT__quot;AuthenticationService__abENT__quot; name=__abENT__quot;CustomBinding_AuthenticationService__abENT__quot; __abENT__#8260;__abENT__gt;
__abENT__lt;__abENT__#8260;client__abENT__gt;
__abENT__lt;__abENT__#8260;system__abENT__#46;serviceModel__abENT__gt;
__abENT__lt;__abENT__#8260;configuration__abENT__gt;
LikeLike
Relector show folowing code from (System.Windows.Ria.Services.WebDomainClient which is located in
C:Program FilesMicrosoft SDKsRIA Servicesv1.0LibrariesSilverlight)
`
Note that this is private method
private WebDomainClient(Uri serviceUri, bool usesHttps, Binding binding)
{
if (serviceUri == null)
{
throw new ArgumentNullException(__abENT__quot;serviceUri__abENT__quot;);
}
if (usesHttps __abENT__amp;__abENT__amp; serviceUri__abENT__#46;IsAbsoluteUri)
{
throw new ArgumentException(Resources__abENT__#46;Data_AbsoluteUriCannotRequestHTTPS);
}
this__abENT__#46;_usesHttps = usesHttps;
this__abENT__#46;_serviceUri = serviceUri;
if (Application__abENT__#46;Current != null)
{
this__abENT__#46;ComposeAbsoluteServiceUri();
}
if (binding == null)
{
TransportBindingElement element;
if (this__abENT__#46;_serviceUri__abENT__#46;Scheme == Uri__abENT__#46;UriSchemeHttps)
{
element = new HttpsTransportBindingElement();
}
else
{
element = new HttpTransportBindingElement();
}
element__abENT__#46;set_MaxReceivedMessageSize(0x7fffffffL);
BinaryMessageEncodingBindingElement element2 = new BinaryMessageEncodingBindingElement();
this__abENT__#46;_binding = new CustomBinding(new BindingElement[] { element2, element });
this__abENT__#46;_serviceUri = new Uri(this__abENT__#46;_serviceUri__abENT__#46;OriginalString + __abENT__quot;__abENT__#8260;binary__abENT__quot;, UriKind__abENT__#46;Absolute);
}
else
{
this__abENT__#46;_binding = binding;
}
}`
If you Observe your auto generated RIA Code DeployTest.Web.g.cs
`
public CustomContext() :
`this(new WebDomainClient__abENT__lt;ICustomServiceContract__abENT__gt;(new Uri(__abENT__quot;DeployTest-Web-Services-CustomService__abENT__#46;svc__abENT__quot;, UriKind__abENT__#46;Relative)))
{
}
i.e binding is created and is hidden inside RIA code which you can’t change or access
(From : http://stackoverflow.com/questions/1912762/configuring-the-timeout-for-a-wcf-ria-services-call-from-a-silverlight-3-client/2171163#2171163)
`
public sealed partial class AppDomainContext
{
partial void OnCreated()
{
var webDomainClient = ((WebDomainClient__abENT__lt;AppDomainContext__abENT__#46;IAppDomainServiceContract__abENT__gt;)this__abENT__#46;DomainClient);
__abENT__#8260;__abENT__#8260; Can I use reflection here to get hold of the Binding
var bindingField = webDomainClient__abENT__#46;GetType()__abENT__#46;GetField(__abENT__quot;_binding__abENT__quot;, BindingFlags__abENT__#46;NonPublic | BindingFlags__abENT__#46;Instance);
__abENT__#8260;__abENT__#8260; In Silverlight, the value of a private field cannot be access by using reflection so the GetValue call throws an exception
__abENT__#8260;__abENT__#8260; http:__abENT__#8260;__abENT__#8260;msdn__abENT__#46;microsoft__abENT__#46;com__abENT__#8260;en-us__abENT__#8260;library__abENT__#8260;4ek9c21e%28VS__abENT__#46;95%29__abENT__#46;aspx
var binding = bindingField__abENT__#46;GetValue(webDomainClient) as System__abENT__#46;ServiceModel__abENT__#46;Channels__abENT__#46;Binding;
__abENT__#8260;__abENT__#8260; So near yet so far!!
binding__abENT__#46;SendTimeout = new TimeSpan(0,0,1);
}
}`
If some how we could access the _binding , then we could add the timeouts etc.
Still working on this but its seams to be very difficult with current version beta version of RIA.
LikeLike
Another option is to add web service reference of your WCF service and use WCF client to invoke lengthy operations. In this case you have an option to sent timeouts in ServiceReference.config file or you needs to wait for another release of RIA (hopefully with this bug fixed).
When you debug your client site silverlight project you can see the default timeout is set to 1 min and reflector also shows that binding configurations are hard coded in RIA client side assemblies. Due to security restrictions you can’t access values of private fields via reflection or via DynamicMethods otherwise we could access the _binding field and could change the timeout values.
Regards
Rajneesh
LikeLike
Thanks a lot Rajneesh. I also hope this would be fixed ASAP.
Regards,
Middlevn
LikeLike
Good article. thank you
LikeLike
Rajneesh, I downloaded your source.zip, compiled and it worked locally. But after I published to DiscountAsp.net, running DeployTestTestPage.aspx got error “Load operation failed for query GetUser”. Fiddler showed result 404 for accessing http://TestApp.net/ClientBin/DeployTest-Web-AuthenticationService.svc/binary
I was able to open
http://TestApp.net/
in Internet Explorer, but opening
http://TestApp.net/ClientBin/DeployTest-Web-AuthenticationService.svc/binary
gave Page not found error. The App tries to access the binary folder because it uses BinaryHttpBinding? Why doesn’t it work? I tried setting Local Copy = True for all referenced DLLs. Thanks for your help.
ClientBin/DeployTest-Web-AuthenticationService.svc
LikeLike
Sorry, I meant to say I was able to open
http://TestApp.net/
but not
http://TestApp.net/ClientBin/DeployTest-Web-AuthenticationService.svc/binary
ClientBin/DeployTest-Web-AuthenticationService.svc
LikeLike
1. Create virtual directory RiaTest on discountAsp.net (inside TestApp.Net)
2. Deploy Project in RiaTest directory on your web server
3. Edit Web.Config (Inside RiaTest folder) ServiceModel section as
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled=”true” />
<baseAddressPrefixFilters>
<add prefix=http://www.TestApp.net />
</baseAddressPrefixFilters>
4. Open URL : http://www.TestApp.net/RiaTest/Services/DeployTest-Web-AuthenticationService.svc
LikeLike
Cut and paste in my previous posts messed it up.
After creating the virtual dir, I still have the same problem. As I said, fiddler showed that the app tried to open
http://www.TestApp.net/RiaTest/Services/DeployTest-Web-AuthenticationService.svc/binary
and got 500 result. I don’t know why the /binary was appended. I can open the url in Internet Explorer only without the /binary. With /binary I got Page Not Found
LikeLike
OK..
1. Try to host test.html page and see if it is comming back..
2. Try to host test.aspx page and check it to confirm that web dir is created properly and is working..
3. in web .config you may turn off custom errors to see the exact errors..
i am not able to launch http://www.testapp.net/ or http://www.testapp.net/RiaTest
LikeLike
I got it to work by using http://www.testapp.net instead of just testapp.net. I’m still trying to figure out why.
By the way, I mentioned testapp.net only as a placeholder. Thank you Rajneesh, your info is very helpful.
LikeLike
I usually don’t usually post on many Blogs,but I love your blog, I often read here, still I just has to say thank you… keep up the amazing work.
LikeLike
Good dispatch and this fill someone in on helped me alot in my college assignement. Gratefulness you seeking your information.
LikeLike
Hi Rajneesh,
I have to configure RIA services with Silverlight 4 and Visual Studio 2010 on IIS 6. The one solution u given above doesn’t seem to be working with Silverlight 4. It throws error “Load Operation Failed For Query …..”
LikeLike
The above mentioned solution was tested with following configurations
Silverlight 3.0 ,
.Net 3.5 Sp1,
WCF RIA Services Beta for Visual Studio 2008 SP1
Visual Studio 2008 SP1
Let me check with my service provider if they have .Net 4.0 on their web server where i can test and run the sample for Silverlight 4, vs 2010.
Ria has two beta versions one for vs 2008 and another for vs 2010.The above mentioned solution solves the bug within RIA beta vs 2008 version. Hope fully by tuesday i will post some fix. In the mean time can you please narrow down the issue. i.e try to launch your WCF RIA web service directly in web browser and see what errors are comming up.
LikeLike
Unfortunately my provider has not yet installed .net 4.0, i can’t simulate the issue with vs 2010 until it is installed on web server. Ria with vs2010 have different implementation (reflector has shown), so this article is applicable to vs2008!have requested my isp provider to install asap..
LikeLike
Hi,
I have a question I have updates my web to config correctly with the authenicationService and UserRegistrationService with the samples, but then when I try and run the application it complains that my configuration is incorrect becausue It cannot find the contract in the list of contracts.
<
service name=”MyApp.Web.AuthenticationService” behaviorConfiguration=”RIAServiceBehavior”>
<
endpoint address=”” binding=”wsHttpBinding” contract=”MyApp.Web.AuthenticationService” />
<
endpoint address=”/soap” binding=”basicHttpBinding” contract=”MyApp.Web.AuthenticationService” />
<
endpoint address=”/binary” binding=”customBinding” bindingConfiguration=”BinaryHttpBinding” contract=”MyApp.Web.AuthenticationService”/>
</
service>
service>
service>
service>
Got any advice?
LikeLike
Hi Robert : In the bottom of this article (before 1st comment) i have provided the source code and binaries and steps to upload on your web server. I would first try to upload the contents of binary and test if WCF RIA service and silverlight project are working properly. You may then compare the provided source code with your’s and find what is missing in your code. Note that your silverlight project will only work if you suffix www. to your domain. Live examples mentioned below..
Application : http://www.rajneeshnoonia.com/RiaTest/
WCF RIA Service : http://www.rajneeshnoonia.com/RiaTest/DeployTest-Web-services-CustomService.svc
Regards
Rajneesh Noonia
LikeLike
Hi all !!
i´m having this problem
The contract name ‘CPI.eXRM.Web.AuthenticationService’ could not be found in the list of contracts implemented by the service ‘AuthenticationService’
can some please help me !!?!
here is my webCondif
thks for the help
<bindings>
<customBinding>
<binding name=”BinaryHttpBinding”>
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name=”RIAServiceBehavior”>
<serviceMetadata httpGetEnabled=”true” />
<serviceDebug includeExceptionDetailInFaults=”true” />
<dataContractSerializer maxItemsInObjectGraph=”2147483647″ />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name=”CPI.eXRM.Web.AuthenticationService” behaviorConfiguration=”RIAServiceBehavior”>
<endpoint address=”” binding=”wsHttpBinding” contract=”CPI.eXRM.Web.AuthenticationService” />
<endpoint address=”/soap” binding=”basicHttpBinding” contract=”CPI.eXRM.Web.AuthenticationService” />
<endpoint address=”/binary” binding=”customBinding” bindingConfiguration=”BinaryHttpBinding” contract=”CPI.eXRM.Web.AuthenticationService” />
</service>
<service name=”CPI.eXRM.Web.UserRegistrationService” behaviorConfiguration=”RIAServiceBehavior”>
<endpoint address=”” binding=”wsHttpBinding” contract=”CPI.eXRM.Web.UserRegistrationService” />
<endpoint address=”/soap” binding=”basicHttpBinding” contract=”CPI.eXRM.Web.UserRegistrationService” />
<endpoint address=”/binary” binding=”customBinding” bindingConfiguration=”BinaryHttpBinding” contract=”CPI.eXRM.Web.UserRegistrationService” />
</service>
<service name=”CPI.eXRM.ServiceModel.CPIeXRMDomainService” behaviorConfiguration=”RIAServiceBehavior”>
<endpoint address=”” binding=”wsHttpBinding” contract=”CPI.eXRM.ServiceModel.CPIeXRMDomainService” />
<endpoint address=”/soap” binding=”basicHttpBinding” contract=”CPI.eXRM.ServiceModel.CPIeXRMDomainService” />
<endpoint address=”/binary” binding=”customBinding” bindingConfiguration=”BinaryHttpBinding” contract=”CPI.eXRM.ServiceModel.CPIeXRMDomainService” />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled=”true” multipleSiteBindingsEnabled=”true” >
<baseAddressPrefixFilters>
<add prefix=”http://localhost:4009“/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
LikeLike
Sorry i didn´t mention i´m using VS2010 and SL4 with ria services 1.0
thks alot
JSB
LikeLike
This article is for WCF RIA with Vs 2008. I have started working on Vs2010 RIA and will post another solution as soon as resolved.
LikeLike
when will be released this example rewritten with sl4 & 2010? I still cannot get it works on the vs2010, thanks,
LikeLike