With a reference to my previous question, I would like to know how would I extract information of a WCF service from a client application to know what methods/types are exposed if the service exposes only one endpoint that uses webHttpBinding?
Just to summarize, in my previous question, I came to know that an endpoint using webHttpBinding does not get exposed in the generated WSDL because it would be a JSON endpoint and is just not compatible.
WebHttpBinding is a REST-based binding - REST does not expose metadata like WSDL/XSD contrary to SOAP.
There's no way to extract the metadata from a REST endpoint at this time. There are some efforts under way to establish a similar construct for REST called WADL (Web Application Description Language) - but that's nowhere near standardized yet.
For now, with REST endpoints, you have to either figure it out yourself, or you need to have some documentation provided by the service provider on e.g. a static HTML page or something.
.NET 4 does provide some level of an automatically generated help page - see this blog post or the MSDN docs for more info. But it's still nowhere near as formalized and machine-interpretable as WSDL/XSD.
I wonder why the REST samples tell you to expose a MEX endpoint at all. It is not needed and here is how to cleanly remove it:
Remove MEX endpoint from the service section of the config file.
Remove service metadata enabled line in the service behaviour section of the config file.
Edit the Visual Studio project (assuming it's a WCF service library) and remove the line:
<StartArguments>/client:"WcfTestClient.exe"</StartArguments>
If you have other non-rest services you will want to leave the last 2 parts present. You must remove the WCF Client when disabling MEX otherwise it will complain during debugging if it cannot enumerate any services in the project (regardless whether they have any useful metadata or not).
Related
I have created a web service using C# WCF, which is hosted via IIS. Are there any settings to hide/remove the ports and make the service tag look like this? Are the settings on the IIS server, or in the web service web.config file?
Basically, how can I choose to make it (or not make it) looks like this?
<wsdl:service name="GameService" />
Clarification: I would like to know is if there is a setting, in IIS or web.config, that would allow to either hide completely, or show all of, the configured ports.
Additional Questions: Does the WSDL not read the Web.Config file? Does IIS generate the WSDL, or does the service?
Further Clarification: This is an attempt to solve this question, which has gone unanswered. This question is an attempt to simplify and rephrase so that I actually receive possible solutions.
Answer: SOAP-based endpoint bindings are listed in the WSDL, REST-based are not.
Endpoint bindings come in two different types: SOAP and REST. You're service can include both in the web.config file as long as they have different addresses, but only SOAP endpoints will be listed in the WSDL. There are no additional settings or configurations needed, the service will pick up this information automatically as long as it's of the supported type.
webHttpBinding is a REST-based endpoint binding. It will work fine for JSON/JavaScript clients consuming the service, but will not be listed in the WSDL.
basicHttpBinding is a SOAP-based endpoint binding. It will work well for C# clients. If you use Visual Studio to add the Service Reference, it will automatically add these endpoints to your app.config file, something it can do because that information is listed in the WSDL.
Thanks to #nodots for getting me pointed in the right direction.
According to the MSDN:
A ServiceDescription instance maps to a wsdl:service element. A ServiceDescription instance contains a collection of ServiceEndpoint instances that each map to individual wsdl:port elements.
So, you should be adding/removing ServiceEndpoint in order to affect the ports section in the generated WSDL.
Here is the description of ServiceEndpoints and there is also an example so you can see how to add/remove them. I'm not sure that you can have a functional service without at least one port.
Hope this helps.
I am a little confused by web services and how they're used. I have created a WCF web service that has an operation contract taking 3 parameters. Then I interrogate our database and return an object matching the data contract. All seems to be good. But how does a third party use our web service? What do I need to provide to them in order for them to use it? Do I need to put a link on my web site? What should that link look like? Thanks!
For third party, you need to share:
Path of Hosted service: it is needed to add service reference.
Information about Service Contract methods: documentation of what exposed operation contracts actually do.
DataContract dll: Only if you are reusing DataContracts.
Some information some times needed to add endpoint if you have to customize default endpoint for client (something like service timeout, packet size etc).
Hope it helps.
What is the importance of this setting httpGetEnabled="false" or httpGetEnabled="true" what will happen if we set httpGetEnabled="false"
suppose if I want any .Net 2.0 client can consume my wcf service which has been developed by .Net 4.0 then how should i develop the wcf service. once i read that if any client need to consume my wcf service then we need to set httpGetEnabled="true" as a result they can consume ny wcf service through wsdl. things was not ver clear so if possible please in more details how wcf service expose through wsdl.
In wcf mex is also there to expose meta data. So I like to know what is the difference between mex & wsdl?
What mex offer more than wsdl? people said mex is configurable but wsdl is not...What does it mean? need details.
If we search Google to see how wsdl envelope looks like then we get ample of link but I found none for how mex envelope look like searching Google. so please help me to visualize how mex meta data structure look like.
If we remove mex endpoint from service config then how other client can consume my service?
other client can consume my service then through wsdl if yes then how ?
what url I need to enter to have the wsdl of any wcf service ? if `httpGetEnabled="false then wsdl will be possible or not.
Here I asked couple of quetion on mex & wsdl. I am new so bit confused about mex & wsdl usage in wcf.
another question is that what is the usage of soap in wcf & relation.
Invoking the service is totally different than exposing metadata. Basically, a service doesn't have to expose metadata (mex or wsdl) to be called by clients.
Metadata are just exposed to allow easier proxy class generation. This allow developpers to 'Add a service referencee' in VS. WCF provides another way to generate a proxy class : using wsdl.exe with a physical wsdl file.
You can also redistribute your service contract through assemblies and use ChannelFactory.
Exposing metadata is useful on dev, because it allows developpers to re-generate proxy class easily after each modification on the contract (Update Service Reference). On Stage/Prod, it depends on your context : it is generally disabled to "hide" service contract.
About wsdl versus mex, there is another recent answer for this.
If we remove mex endpoint from service config then how other client can consume my service? other client can consume my service then through wsdl if yes then how ?
Your clients can invoke your service only if the have a generated proxy class or your service definition. As I said, they can generate this class using metadata when they want or use a physical wsdl file that you have previously sent.
what url I need to enter to have the wsdl of any wcf service ? if `httpGetEnabled="false then wsdl will be possible or not.
HttpGetEnable allow you to expose metadata through HTTP GET method, usually the service’s address with the suffix of ‘?wsdl'. Simply browse the service url and wcf will generate an help page for you.
So this is in relation to my question here.
So I have an existing wcf service running already, hosted on IIS. I created a Router Service that will do some XPath filtering on the header. So if the header is match then go to service1.
Now, I hosted my Router Service on IIS and I can access it like http://iis.com/myrouter/router.svc/ and give me this wsdl stuff. Now when I try to request a service method on service1 like this http://iis.com/myrouter/router.svc/general/getMyMethod?blah=blahblah. It gives me a 404 error. I used fiddler by the way.
On my request through fiddler I added my custom header like "service_version:1". I used a namespace by the way on my <namespaceTable> but I don't know how to append it on my request. Anyway, my main concern is how can I make my Router Service work on IIS?
Update: I am using System.ServiceModel.Routing.RoutingService by the way. So what I am trying to accomplish is Routing Services.
Your help is greatly appreciated.
You are likely facing this. A SOAP service can't be accessed that way because it relies on the SOAP package. Here is another article that should lead you down the right direction. However, the direction it leads you down is that testing a SOAP service by hand is not to be desired and probably a futile effort.
However, one note is that it leads you to use the WCF Test Client - that's the best direction to go my friend and it's very easy to use. Provide the URL and it will do the rest.
Invoke soap wcf service in Fiddler like in Wcf test client
Accessing the RESTful Endpoint
If you're trying to test the RESTful endpoint then the issue is likely surrounding the routing that is configured. Please refer to this link for assistance - make sure you're setting up your service the same because the attributes they use build the routing properly. Remember that you're not going to reference the RESTful endpoint with the same address as the SOAP endpoint.
http://geekswithblogs.net/michelotti/archive/2010/08/21/restful-wcf-services-with-no-svc-file-and-no-config.aspx
You can also check out this link.
Hosting WCF soap and rest endpoints side by side
You are given a WSDL and a sample soap message, is there a good tutorial or sample code in using that WSDL to consume a web service? Does the WSDL follow a certain format in order for which it can be consumed properly? I recall a web service in Java that I changed certain tags and attributes in order for this to work, is there a general convention for the formatting used in WSDLs?
I think this might be harder than #1. You are given a WSDL and a sample soap message. Is there a way to use that given WSDL and not the WSDL generated by C# web service when exposing a web service? Is there a way to somehow "override" the WSDL of the web service to the given web service? Are there any conflicts in formatting and compatibility of the WSDL that ought to be considered?
The quickest and most painless approach is simply to use svcutil to generate the code representing the WSDL. At that point the code produced can be used as a client to query an existing service or you can define a class implemeting the service contact. Once you have the .NET classes the SOAP message example will just serve as documentation.
the default usage would be want you most likely want
svcutil myRemoteService.wsdl
which will generate a a file named [servicename].CS file and an output.config containing the necessary WCF client bindings.
Not sure what you mean by overriding the WSDL as it is the published contract that the service honors. So if you want to change method signatures or behavior it will no longer work as the change will no longer conform to the WSDL.