Windows Communication Foundation Service Library Project - wcf

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.

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

Generate Class Library proxy for WCF

I'm trying to write an application which gets the WCF address and generated a DLL from it.
Then I can pass it to another team (dev team) and they can use the DLL to call WCF methods without knowing anything about WCF Address and config.
Dev team knows about method names/contracts, they just don't want to add reference to WCF services they use and prefer to have a dll and just call the method from DLL.
I have heard about svcutil which generates a class and a config file. How can I write an application that executes svcutil and compiles the generated files in a dll, all programmatically.
Thanks.
Create, Host(Self Hosting, IIS hosting) and Consume WCF servcie
you need to self host service and this self host dll you can give to your other team.,..
check for the selfhosting of the wcf service.,.. also check above article which may help you to achieve your task

Can I add a Service Reference with netTcpBinding in WCF?

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.

wcf Extract wsdl from WCF Service with Flattened WSDL

I have a wcf web service and I need to provide the client with the wsdl files.
Previously I used svcutil on the .dll and everything was fine.
However, recently I implemented the factory to Flaten the wsdl file (re: http://wcfextras.codeplex.com/).
My questions is this: Is there anyway of either using svcutil on the .svc to extract the Flattened .WSDL files or maybe somehow hit up the web service when it is running in the local webdev server to retrieve the .WSDL files?
As far as I'm aware, if I was to navigate to my local web dev server (http://localhost:2916/Service.svc?wsdl) and if i was to view source and saved that as .wsdl that this is wrong and would not provide all the relevant information.
note: See below for how the Factory is used in the .svc file....
<% #ServiceHost Factory="CompanyName.ServiceModel.Extensions.Description.FlatWsdlServiceHostFactory" language=c# Service="CompanyName.WebServices.Service"%>
Thanks,
Steven
Yes, you should still be able to use svcutil to extract the WSDL from your service, even if you have an extension installed that will flatten the WSDL.
To download the metadata document(s) from your running service, use this command:
svcutil /t:metadata http://service/metadataEndpoint
You need to point your URL to the metadata endpoint defined in your config, e.g. the endpoint that's defined to use "mexHttpBinding" or "mexTcpBinding" and the "IMetadataExchange" contract.
If you don't have any metadata exchange endpoints defined, you won't be able to retrieve that information, obviously.

How to connect to a WCF Service with IronPython

Has anyone done this? I've tried generating a c# proxy class and connecting through it, but I cannot figure out how to get IronPython to use the generated app.config file that defines the endpoint. It tries to connect, but I just get an error about no default endpoint. I would ideally like to make the connection using only IronPython code and not use the proxy class, if possible. The binding for the service I am trying to connect to is a NetTcpBinding if that makes any difference.
See my blog post. There are IronPython WCF service and client examples.
To use app.config, you probably must copy it to ipy.exe and rename it to ipy.exe.config but I have not tried it so I don't know whether it works or not.
Is your WCF service interface available in a shared assembly? If so, you could look at using the ChannelFactory to create your client proxy dynamically (instead of using the generated C# proxy). With that method you can supply all the details of the endpoint when you create the ChannelFactory and you won't require any configuration in your .config file.