1

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.

Community
  • 1
  • 1
aherocalledFrog
  • 831
  • 9
  • 13
  • 1
    The easiest way would be to have IIS deliver a *static* WSDL, i.e. a text file that you customize the way you want it. The drawback is that you must remember to keep the static WSDL in sync when you change anything in the service. A second option is to look into the extension points for WSDL generation, [here's a starting point](https://msdn.microsoft.com/en-us/library/aa717040.aspx). – nodots Apr 26 '15 at 10:19
  • Forgot to add, the static WSDL file is referenced in the web.config like this: `` – nodots Apr 26 '15 at 10:24
  • Thanks, I'll look into it, but it sounds like making tons more work for something that feels like it should be really easy, since the wsdl is automatically generated in the first place. – aherocalledFrog Apr 27 '15 at 14:24
  • It might be worthwile to reconsider what actual problem you want to solve by removing the ports from a WSDL - which is an unusual case. Maybe this is an [XY problem](http://meta.stackexchange.com/a/66378)? – nodots Apr 27 '15 at 15:03
  • @nodots 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. This isn't an XY problem because I'm not coming to you with a solution and hiding the problem. We can discuss it further in chat if you prefer – aherocalledFrog Apr 27 '15 at 15:52
  • OK, just asking. If you're willing to share then please do, I'm curious why you need to show/hide ports. Regarding your question though I fear that I've contributed all I could, unfortunately. – nodots Apr 27 '15 at 16:10
  • @nodots http://stackoverflow.com/questions/29420645/c-sharp-iis-hosted-wcf-service-doesnt-generate-client-endpoints – aherocalledFrog Apr 27 '15 at 16:20
  • 1
    Thanks for the context which shows me that I misunderstood this question (it *is* XYish IMHO ;). I even have a somewhat educated guess: In the question you linked, I spotted ``. IIRC this is a REST-based binding, while WSDL is SOAP. Check this question if it helps: http://stackoverflow.com/q/3040165/626761 – nodots Apr 27 '15 at 16:48
  • @nodots That's the info I needed. Thanks for help clarifying the issue. I've only recently started working with WCF, and you got me pointed in the right direction. Would you mind adding an answer to that other question based on the above comment so that I can give you the credit you deserve? – aherocalledFrog Apr 27 '15 at 18:35

2 Answers2

1

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.

aherocalledFrog
  • 831
  • 9
  • 13
0

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.

Plamen G
  • 4,729
  • 4
  • 33
  • 44
  • I don't think this answers the question. The question is how to remove the `` entries from the WSDL, not how to rename the service. – nodots Apr 26 '15 at 10:22
  • It still depends on the implementation in his case. It will be way better if he modifies the annotations in order to achieve what he wants, otherwise he will have to update the static WSDL each time. – Plamen G Apr 26 '15 at 10:43
  • @aherocalledFrog Here, I updated it with. Sorry I misunderstood. – Plamen G Apr 27 '15 at 16:14
  • @PlamentPetrov Thanks for the edit, and the help! I have functional service endpoints in the Web.Config file, and IIS handles the addressing. The linked article doesn't mention any .config file, and creates endpoints in code. Does the WSDL not read the Web.Config file? Does IIS generate the WSDL, or does the service? – aherocalledFrog Apr 27 '15 at 16:19
  • @aherocalledFrog - IIS is a server that handles the communication. It serves requests but does not handle the web-service and WSDL internals. I think the WSDL is a product of code-first approach in this case. – Plamen G Apr 27 '15 at 16:23