Need guidance in calling WCF service from Silverlight 4 - vb.net

Okay guys, I call upon your combined intellects. I have a web application with a silverlight app that calls a ria service. The ria service is defined inside the web application and everything else is just dandy.
The issue is this.
It is my understanding that in order for the silverlight application to talk and know what the ria service is, you need to add a service reference for that service. The service reference defines the ria service and sets up the connection binding. One of the files it adds is the ServiceReference.ClientConfig which has the connection binding in it. During the course of this application's development, this is the way it was set up. And it worked perfectly fine locally and on the dev server.
Unfortunately there were issues when deploying to the clients in-house server. At this point I was onto other projects while my co-worker continued with the deployment. He soon became frustrated with the goofy errors that were occurring and recruited some help. This dev came in and, albeit got it working, but in order to do so he removed the service reference from the silverlight project but left the ServiceReference.ClientConfig which pointed to the location of the service in the web application(but that's it, no definition or explanation as to what the service does and I'm not sure how the silverlight app is supposed to know how to work with it..). This works perfect on my co-workers workstation and he has deployed this version to the clients server fine.
When I open the project it doesn't run at all. And the reason why is that it doesn't know what the service is that i'm using in code. Specifically, it doesn't know where this is (names changed for clarification):
Imports SilverlightApp.ServiceReference.WebApp.Service
I have cleaned the solution, completely deleted and got the latest from source control, built the web app first and made sure the asp.net dev server was running so that the address in the ServiceReference.ClientConfig resolved correctly. But, alas, it still doesn't know what Imports SilverlightApp.ServiceReference.WebApp.Service is.
So, to get it working on my workstation, I added the ServiceReference back but kept the current connection bindings so that it matched the endpoint in the web app web config. and changed the import statement to Imports SilverlightApp.ServiceReference and everything works fine.
What is the reason for this insanity?!?!

All the things you are talking about relate to a WCF service NOT a WCF RIA Service. They work in quite different ways when consuming them in your client app.
A WCF service will require a service reference and the ServiceReference.ClientConfig.
A WCF RIA Service does not. The link to the WCF RIA service is set in the silverlight project properties in the Silverlight tab at the bottom. When you build it will generate client side context code in the Generated_Code folder. Show all files and you will see it.
Hope that helps?
Kevin

Related

How do I configure Visual Studio to see a net.tcp URL on local IIS?

I've got a WCF service using the netTcpBinding, and no other binding. It works great when I manually deploy the files to IIS, and my client application can consume the service when I enter the net.tcp://localhost(etc) url. Now I'm trying to get the project to run in Visual Studio, so I can have the service and client in the same solution, and reference the service directly instead of going through IIS, and having to redeploy files manually.
Neither IIS Express nor the Visual Studio Development Server can use net.tcp, so they're out. In the Web tab of my service project, the "Use Local IIS Web Server" or "Use Custom Web Server" looked like good options, but neither of them will accept a URL that doesn't begin with http.
Is there some way of making my WCF service use IIS, and having my client reference the service directly (so that I don't have to deploy files to IIS, and then update service reference, every time I compile)?
Start the service in WcfSvcHost, then try to add a reference to the hosted URL.
Unfortunately, the VS IDE has no technique to start services automatically, except for when you're debugging.
Also, you always need to update service references explicitly. You need to decide which of your changes are ready to be applied to which clients of your service. It would be bad to assume that all clients should be updated as soon as you make a change then compile your service.
You could add a project, which you don't deploy, but only use during development, that self-hosts the service.

Adding a service reference to a WCF service that is using Net.TCP

I am new to creating WCF services. I have created a WCF service that is using TCP. The service is running on IIS 7. From within the solution file I have a client project that I have used to test my service. I've run the client project using a TCP endpoint and it accesses the service and everything is fine.
Now, I want to access my TCP service from a new standalone project, one that is not part of the service's solution like the client project. I created a new project in VS 2008. I clicked on Add Service Reference, entered the net.tcp address (net.tcp//.......) and clicked go. An error is returned saying that the "Metadata contains a reference that cannot be resolved."
Is there something further in IIS 7 that needs to be configured? Am I correctly adding a reference to a service that is using TCP? If needed I can supply more information but at this point I am not too sure what I need to post. As I said the service works perfectly from the client project but I can't even access the service from a standalone project.
Thanks in advance for your help.
Look at your Web.config file. Do you have an entry that starts out like
<endpoint address="mex"...
and then specifies a contract="IMetadataExhange? If not then you need to add a meta data exchange endpoint.
If you have $29 to spare, you can save yourself a LOT of time and watch some great videos by Aaron Skonnard on WCF (in the beginner examples there is an 8 minute video on hosting WCF in IIS), The $29 gets you a one month subscription so you can watch anything in the library. Money very well spent in my opinion. [Edit] I forgot to mention you can get a free trial, I think it's good for a month or 4 hours of viewing whichever comes first.

Delphi7 client connecting to WCF service

I have a WCF service and 2 clients I'm testing with. The first client is written in c# .NET 3.5 and has no trouble connecting to the WCF service. The other client is written in Delphi7, and it's the one I'm interested in getting working. This is the interesting part. If I start the service then hit it with the Delphi client, it won't connect... but if I start the service then hit it with the .Net client then try the Delphi client, it works ! Could be something to do with the design-time addresses, I'm not sure. Maybe a more experienced person will know what's going on and what I need to do to get my Delphi client working without needing a .Net client running alongside it. It might be relevant to note that the service is currently being hosted in a winforms app.
regenerating the wsdl and re-importing it into Delphi 7 seems to fix it.

How can I use net.tcp without IIS?

I have a web site and build a wcf service in it. I can run the code by calling it from a test page in the web site. The web site is ran by the vs2010 development server.
I do have IIS 7 but never use it.
Now I want to use the NetTcpBinding instead of BasicHttpBinding, everyone says it should be enabled in IIS, but how can this be done without using IIS and keeping everything in 1 project?
Thanks for any help
edit: A Windows service would be a solution, but that would mean adding a project to the solution, I really want to keep everything in 1 website, took me quite some time to get the service in the website in the first place.
This is about my own test version of the website, the production server is out of my reach. The service must be expanded by other developers later on it's bad if they have to run IIS just to test the service.
One way is to host the WCF service in a Windows Service - see How to: Host WCF in a Windows Service Using TCP for sample code.
Are you talking about how to develop without using IIS7 or how to put the service into a production environment without IIS7?
If it's the latter, then Stuart's answer is correct, but otherwise I would suggest that you start to develop using the web server that you will eventually be hosting the web site/service on.
Hosting in IIS7 has several advantages over hosting in a Windows Service such as fault tolerance and process isolation already built in.
Thanks for the replies guys, it looks like I have 3 options:
1. Host the service in a seperate project.
2. Host the website in IIS.
3. Use HTTPS, also secure.
PS: My development environment is very different from production :(
In development I have unit testing and in production there are old ASP pages, that I can't even acces, but sometimes must refer to...

how to debug a WCF service once it's out of dev env

I have a WCF service that i've been able to communicate with fine while it's hosted locally.
I have it deployed to a web server in IIS now, and I can get the wsdl file without error by navigating to http://site.com:8000/service/servicename.svc?wsdl
in trying to test this, i've created a console app and was able to successfully add a service reference to this. But when I try to run a Get() method on the service reference, it just hangs with no response.
How can I begin to debug this?
Thanks!
When you have a service that works in dev but not in IIS, it is often due to a problem with the WCF configuration:
Is the configuration in place (since you can add service reference it probably is)
Is the protocol you are using available. The configuration you are using must match what is turned on. For example are you using nettcpip binding without WAS.