Incorrect WCF Service Reference / Empty Reference.cs file - wcf

I have created a WCF service using Service Library template. Using the Service.dll generated, I have hosted the service in a console application.
However, when I add a Service Reference in my web project, on viewing the Service details in Object browser, it points to incorrect assembly in the object browser as shown in the screen shot below.
One possible issue could be that, while renaming the namespaces in my web project, I ended up renaming the namespace of Service project also. But even after fixing all the namespaces, I still have this issue.
Any ideas on what can be done to resolve it?
While adding a Service Reference, it displays the correct members/interfaces as shown in the screenshot below. Only when I view the Service Reference in the object browser, I don't see those interfaces exposed by the service.
Project dependencies of service project
Not sure why the web project is a dependency of the Service library project? It should not be as I have not added any reference to it in the Service project.

I came across this question here after researching on this issue.
I also found out that the reference.cs file was empty in my case also. After unchecking Reuse types in referenced assemblies from 'Configure Service Reference' dialog, I was able to generate the Service reference client code successfully. My Service reference is now pointing to the correct Interface/members. In case of any queries, feel free to comment or contact me directly.

Related

How can I use SimpleType in a WSDL data contract?

I use a wsdl file to generate web service with the help of svcutil but it generates class instead of simple int or string parameter for the service contract.
What I did:
I created a WCF Service Application
I created a Console Application then added the service reference to the project
I used svcutil.exeto generate service from thy wsdl and xsd files in console project
Why does it do that and how I can rewrite the wsdl to solve this problem, please?
Most likely you used /messageContract switch in svcutil.
If you added service via service reference, then right click on service->configure service reference and uncheck Always generate message contracts

HOw to manage newly added methods into WCF service

I have created wcf service and added its refernece into web application project.
Have added as below way: 1. generated proxy and config file using - svcutil command and added proxy file into web application project and merged configuraiton file.
Now, I have added some new methodsinto the wcf service , do i have to use - SVCUTIL command on each time or it should work automatically.... for now, i need to generate proxy file each time.. please suggest some best way.
NOTE: service instance available into ASP.NET web applicaiton (client) but unable to get when use client as - MVC applicatoion. please suggest.
Thanks
In the Web Application, open the Service References folder.
Right click on the Service you want to update.
Select Update.
Thanks for the response.
I found the answer, when add service reference (for MVC application) >>> click at 'Advance' button >>> uncheck the "reuse object....." option and then add it.
Then, service client reference is available and it works.
Just for KS, sharing you another design issue due to Add Service Reference option at below link:
What should keep into this design approach
Thank You

consuming standard SOAP Web Service using vb.net

I have consumed several wsdl services successfully, but am stuck now with this web service.
Am implementing Hotelston webservice which state :Hotelston.com API is a standard SOAP Web Service (WS) available at URL
http://www.hotelston.com/ws/HotelService?wsdl
I cant access the direct code of the webservice after i added the it as a reference in my application.
Please see the following MSDN articles for the exact details on how I added and used these web service references but still cant access it from the direct code.
How to: Add and Remove Web References
How to: Call a Web Service
For full API documentation of wsdl file through the link.
If you show all files in the project and expand the service reference out, Reference.cs is empty. This is likely because there are namespace errors in HotelService.wsdl ("ax23", specifically) that is causing the t4 template to fail to generate the service code. Bottom line, it's their fault, not yours.

Is it possible to use "add service reference" option to add a self-hosted service in WCF?

I am creating a WCF service. At first I had one WCF service library project and one console project which was referencing the this library. And it worked fine when I used "add service reference" in my client project, as long as the service library had a valid App.Config file.
However, now I want to combine the service library and the console host into one console project. After all, the previous console project was pretty simple. But here comes the problem: when I choose "add service reference" and give the endpoint I defined in the App.config file of the new console project, it can't find any service reference. I take it because the service will not be hostedd by wcfsvchost.exe when the add service reference function was on(and I think it makes sense). But I can't think of a way to make it work. So how am I supposed to add a service reference, if my service is one single console-hosted project?
The easiest way for you is to run WCF service, generate a service reference and then combine it into single application. All you will need to do is just change address in your app.config. But be careful with this, as you should change address for client part and not server part of app.config.
This approach, however, will be difficult to maintain in future, when you will decide to change your service data contract and regenerate service reference. You might want to consider the following: wrap service reference into assembly and use assembly instead. This way you will be able to regenerate you service reference whenever needed.

WCF Service reference from Silverlight Class Library

I have a Silverlight application communicating with the server side through WCF services. Initially I had everything in the main Silverlight application, but now I wanted to factor our some classes to a separate Silverlight Class Library project. This however gave me some odd issues...
I wanted to factor the classes that does the WCF communication out to a separate project. So I:
Created a new project; Silverlight class library
Moved the classes from my Silverlight application to my Silverlight class library
Removed the Service reference in the application as I no longer call it from the app.
Added a Service reference from the class library project.
Now - compiling is fine and I get intellisense for the service stuff in the Class Library, so it seems to be fine. I also updated the service and got the updates in the Class Library.
But when running the application it fails when doing a service call giving the following error:
InvalidOperationException was unhandled by user code
Could not find default endpoint element that references contract 'MyServiceReference.IMyService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
Seems like it can't find the service, but why? I assume there should be no problem to have service references from a Silverlight Class Library as it allows me to add one?
IT can't find any service configuration - where do you have the config for the WCF service? By default, the client app (the EXE) will have a app.config that contains the service endpoints to connect to.
Also by default, class libraries (DLL's) don't have their own configuration but rely on their hosting app to provide the configuration for them.
So all in all - you're probably missing the config for the client endpoint. Most likely, it has been created as an app.config in the class library project, but that's not being used, really - you'll have to move the <system.serviceModel> section up to the main app's config (I'm not fluent in Silverlight, but you'll know where to put it).
Marc