views:

30

answers:

1

Hi,

I have started learning WCF. I wrote a simple service to query a SQL relation through LINQ.

[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = aspNetCompatibilityRequirementsMode.Allowed)]
public class Order_WCFService 
   {

    [OperationContract]    
    public List<Order> getOrders()
    {
        List<Order> orderList= null;

        try
        {
            orderList= DAL.GetList<Order>();
            return orderList;
        }
        catch (Exception)
        {
            throw;
        }
    }     
}

This is located in ASP.NET-MVC project.

I have a simple silverlight application. It's in the same solution, but in a different project.

I would like to consume my service by a silverlight application.

I attempt to "Add Service Reference..." and in the left hand column I have a list of all available ASMX and WCF services. When I click on any of the services, it attempts to download service information, but fails after 10-20 seconds: "An error occured (details) while attempting to find services at..."

What am I doing wrong here?

Thank you

I'm 100% certain that services are functional because I can invoke them through AJAX.

+2  A: 

Maybe a stupid question but was the service running when you attempted to add the service reference (if you are using the Visual Studio's built-in web server, was it started and the ASP.NET MVC project containing the service running)? Also you may try giving the full address of the WSDL in the Add Service Reference dialog instead of selecting it from a list after verifying that this WSDL is accessible in your browser.

Darin Dimitrov
My thoughts exactly +1
Alex
Thanks for reply. As soon as I click on "Add service reference..." VS IDE starts up a web server which I can see in the bottom right corner of my screen. When I navigate to http://localhost:3697/Order_WCFService.svc I get a message saying that I have created a service.
vikp
By full address do you mean: localhost:3697/Order_WCFService.svc ?
vikp
Right, so it seems that the web service is started. Now try navigating to the WSDL: `http://localhost:3697/Order_WCFService.svc?WSDL` and make sure that it responds with proper XML and if it is OK try using this same address in the Add Service Reference dialog.
Darin Dimitrov
?WSDL returns XML file.
vikp
Using that address results in the following error: "There was an error downloading metadata from the address. Please verify that you have entered a valid address."
vikp
Ok, so everything seems fine. Are there some details about the error?
Darin Dimitrov
The HTML document does not contain Web service discovery information.Metadata contains a reference that cannot be resolved: 'http://localhost:3697/Order_WCFService.svc'.The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transit...
vikp
You may also try using the command line tool: `c:\Program Files\Microsoft SDKs\Silverlight\v3.0\Tools\SlSvcUtil.exe http://localhost:3697/Order_WCFService.svc?WSDL` which will give you more details about the error. Also make sure that you have enabled metadata information in your service web.config file: `<serviceMetadata httpGetEnabled="true"/>`
Darin Dimitrov
Ran the utility. Do you expect ?WSDL to return only XML? If yes, than this is probably the reason because on top of XML I get HTML from master pages which I use throughout the project.
vikp
?WSDL should return only XML.
Darin Dimitrov