Basically I separated the whole login registration and authentication of the Silverlight Business Application template into a WCF RIA Services class library. But I am not getting this remote server returned NotFound error.
I am supposed to use the SqlRoleProvider and SqlMembershipProvider to hook up the authentication context to my database, instead of the default express database.
I'm confused on the whole app.config and web.config thing. How do I know what goes where?
I would say nothing is impossible! There are more than one ways to dong things, all you need is to think about it.
See: http://www.codeproject.com/KB/macros/Config-Merge.aspx
Or you can use <connectionStrings configSource="App.Config"> in web.config
Here you are asking web.config to pick settings from another app.config in same directory.
Anything you want to have affect runtime behavior, or used at runtime must go into web.config. App.config doesn't get applied at runtime.
As such, things like connection strings, provider configuration etc. must all be placed in web.config. Unfortunately there is no VS mechanism to transfer/merge settings from app.config of a class library into a web project.
Related
In my VS solution, I created a console project, which I'm using as the client, and an empty project for the WCF service.
I then created the WCF service (created my contract and service type and manually constructed the app.config), and added a reference to the WCF service project in the client project.
However, when I called ServiceHost.Open() in the client, the endpoints weren't loading. I eventually determined that I needed to put all of the config information in the Client's app.config, rather than the service's app.config.
I'm not sure if this is normal, or if I'm doing something wrong. In the past, when I've used the WCF project template, this wasn't the case.
Yes, that is normal. Each .NET application (client, service, web site, etc.) has it's own configuration file. To be precise, there's a hierarchy of them, but the bottom end of that hierarchy is unique to the application.
This makes sense if you think about it -- the client would need to contact the service to ask for it's configuration, but it needs to know the endpoint information in order to even try to do that. So yes, the normal process is that client and service both have very similar information in their configuration files.
If you use Visual Studio's built-in tooling to do everything for you, it will automatically create and/or edit the configuration file for your client when you add a Service Reference to the project, copying from the metadata endpoint that WCF exposes for that purpose. Alternatively, you can use the WCF configuration editor tools to edit your client application.
Also, note that nothing actually enforces that your client and server have compatible settings; e.g. you can change the maximum sizes of many buffers/graphs/etc on one side, and not the other, and see some strange behavior. It's up to you to make sure both ends are working with mutually usable settings.
I am using VS2010 and .NET 4.0. When I create a WCF Service Application, I can easily get my service up and running. However, I am unable to find the services information such as binding configuration and address etc. Where does the template store this information so that I can modify. I know I can add my own bindings and address in the config but I want to know what is the default binding WCF template is using and modify accordingly.
I apologize for the simple (dumb) question, but in 3.5 it was in the config upon using the template
This is not something being done by the template. The application is simply using the default WCF configuration settings. See here for futher info.
Here's the end game... I need a wcf service application with username/password security over ssl. Pretty basic stuff, but I'm at my wit's end trying to make this work. I'm trying to implement the HOWTO guide from microsoft's patterns and practices as listed here:
How to: Use Username Authentication with Transport Security in WCF Calling from Windows Forms.
I've follwed each of the steps exactly... except steps 9 - 12. Those steps implement a custom authentication and authorization class. I'm having errors both with the implmentation of these custom classes and without.
First, without the custom classes... Without the custom authorization and authentication I can compile my wcf project and create the service reference in the console client application. When I run my console application it works, but when I decorate my wcf method to restrict the permissions, it appears that the client is never passing the credentials to the wcf service. If it leave the decoration off the method and step trace into the wcf method, if find that the ServiceSecurityContext.Current.PrimaryIdentity.Name is blank. I'm decorating with:
[PrincipalPermission(SecurityAction.Demand, Role = "sysadmin")]
(and yes, I've used the ASP.net configuration to create the role and the account in that role.)
Second, with the custom classes... If I include the HttpModules element as listed in step 10, I get an error stating that IIS express 7.5 doesn't do it this way any more and I need to move the configuration. With a little bit of hunting I found that I needed to move the item to . But it still complains that is can't reference the module. If I leave out the authentication module and try to just reference the authorization module, I get the same error.
I tried to include the entire web.config, but this editor didn't want to take it all. Suffice it to say that it's exactly like the msdn article except for moving the module tag.
I have some basic questions related to the conversion of Web Service (.asmx) into WCF. We have a running website which use tons of Web Services. These web services use a common dll that has the business logic. We are planning to convert the web services into WCF. Since there many web services, we are planning to convert one at a time. So to begin with there will be one WCF and many web services (asmx) residing on the production server. I have some confusion on how to make the website run with both - WCF and ASMX residing at one place. I would appreciate if someone can answer my queries:
Can I share the same web.config file for both .asmx web service and WCF service? If yes, then what all changes do I need do to to make sure both works at the same time. Adding ServiceModel tag is enough to the existing web.config?
Can I use the web.config to store some configuration parameters that can be shared between the two services - WCF and .asmx? How to call it?
Currently, the common dll (business layer) is using HTTPContext.Current to cache some values. How can I make sure that the code works for both WCF and .asmx calls? What is the best way to convert the code similar to:
xslt = (XslCompiledTransform)HttpContext.Current.Cache[fileName];
string XslFilePath = HttpContext.Current.Server.MapPath(#"~/xsl/" + fileName);
What is the WCF equivalent?
Finally, how can I deploymy WCF changes in production server? Do I just need to copy the service dll and the .svc file?
I know, I have so many questions, and these may look simple to you guys but I am finding hard to figure them out.
1) Can I share the same web.config file for both .asmx web service and
WCF service?
Yes, absolutely - the WCF config lives in the <system.serviceModel> section (mostly), so that's no an issue at all.
2) Can I use the web.config to store some configuration parameters
that can be shared between the two services - WCF and .asmx?
If you create your own custom configuration section or section group - yes, sure. Both the ASMX web service as well as your WCF code can read that custom config section - that's all standard .NET stuff, really (See: How to: Create Custom Configuration Sections Using ConfigurationSection)
3) Currently, the common dll (business layer) is using
HTTPContext.Current to cache some values.
You can turn on the ASP.NET compabitibility mode on your WCF services, and doing so, you a) tie yourself to IIS forever, and b) get access to all the usual HTTP context and stuff like that. See: WCF Services and ASP.NET for more info.
4) Finally, how can I deploy my WCF changes in production server? Do I
just need to copy the service dll and the .svc file?
Copy the service DLL(s), the SVC file, make the config changes - that's it!
Is it possible to add a service reference in visual studio, which generates the local proxy class to call the WCF service when using the netTcpBinding?
As I understood it, the service reference method requires a WSDL to be exposed by the service, which is only supported by the http bindings no?
Perhaps, could I add the service reference locally in development, but then switch the configuration to use nettcp at runtime in production?
The reason I am asking is because I am hosting in a windows service (server 2003, so no WAS, and can't use IIS). And we are unable to change the permissions to do the HTTP namespace reservation ... so we can't use the HTTP bindings. NetTcp works, but in this specific case the object graph we're passing back and forth involves objects generated in the service by an EDMX model ... so we can't share it in a contract assembly.
Thanks in advance!
Simply add a binding using mexTcpBinding.
Is it possible to add a service reference in visual studio,
which generates the local proxy class to call the
WCF service when using the netTcpBinding?
Yes, most definitely!
As I understood it, the service reference method requires a WSDL
to be exposed by the service, which is only supported by the http bindings no?
No, definitely not - WCF metadata (either its own specific format, or exposed as WSDL / XSD files) is definitely available for all SOAP-based calls - regardless of their transport.
Can you show us what you have, in terms of server-side config? Most likely, you're just missing a little config setting or something - if we see what you have, we might be able to pinpoint that and help you more!
All bindings are exposed though WSDL. If you add the NETTCP bindings svcutil will atuo generate the client correctly. I haven't used it in the ADD reference in VS as i have always preferred to generate the class with svcutil.