How can I use SimpleType in a WSDL data contract? - wcf

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

Related

How to consume wcf in .net core without adding service reference?

I want to consume a WCF service in my .NET Core application without adding service reference?
I am able to consume WCF by installing WCF connected service and adding service reference but I don't want to add any service reference.
Please refer to the follow link. It has some minors issues, but is easy to fix.
Calling Web Method Without a Service Reference
if you are using wcf service then you can expose it as a restful service. then you can simply consume it. actully i have been use it for many years and its been really useful.
here you can read more about that: REST / SOAP endpoints for a WCF service
you can create a service proxy using svcutil.exe and use the proxy class as a reference.
here is a sample:
SvcUtil.exe http://www.temperatureservice.com:8080/TemperatureService.svc /ser:DataContractSerializer /s /language:cs /out:TemperatureServiceProxy.cs /n:*,WCF.Client.Proxies.Proxy
It will generate TemperatureServiceProxy.cs file, include this file in your project and create a service client by referencing this file.

Can't display a WSDL for a WCF service hosted in an ASP.NET MVC application

When I launch the application and go to the service page I see...
You have created a service.
To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
svcutil.exe http://localhost:26109/DashboardServices.svc?wsdl
You can also access the service description as a single file:
http://localhost:26109/DashboardServices.svc?singleWsdl
But when I click on those links I don't see the WSDL. Instead I just get the same text.
I assume this has something to do with MVC routing, but I don't know how to fix it.
This behavior happens when you forget to put [ServiceContract] on the interface.

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.

How to get the original service from a wsdl file

i have a wsdl file, now i need to get the original wcf service. and after that i want to use(consume) that service in my web project.
please tell me is this possible? and how?
The WSDL contains only the definitions of the service contracts and data contracts. Don't expect to reconstruct the implementation of the original service from a WSDL file. In order to generate a client proxy which will allow you to call the service given this WSDL you could use the svcutil.exe utility.

Windows Communication Foundation Service Library Project

Do you know if there is any way to access the wsdl file when you create a WCF service library? It seems you can get it when you create a WCF application but not the service library...
Any ideas would be appreciated.
Thanks
The only way to access the WSDL is once you host and run the service. Otherwise, you cannot access it. So, create a host (or application as you are calling it) with a mex binding, then run the service and you should be able to access the WSDL.
Once you do this, you can save the WSDL as a file or something for later reference.
You cannot access the WSDL automatically. Of course if you compile the static WSDL into the service library, as a resource, you could then access it directly.
but what is it that you are trying to accomplish?
The "Service Description" is available inside a service. It is not the WSDL itself, but rather, the in-memory model of a service description. It includes the namespaces, the element names and types - everything in a WSDL, and more.
You can get at it with System.Web.Services.Description.ServiceDescription. Typically this is done within a ServiceHost, a ServiceHostFactory, or an IEndpointBehavior.