views:

102

answers:

1

The WSDL generated by WCF is describing all my bindings, and I want it to describe only the wsHttpBinding.

I want it because a PHP client can't parse the WSDL if it contains unknown bindings.

There is a way to do that?

+3  A: 

Have a service and an endpoint that exposes nothing but the wsHttpBinding and connect to that endpoint using your PHP client - that ought to work. There's really nothing else you can do, I think - if a service exposes more than one endpoint with various bindings, all those bindings and endpoints will end up in the WSDL.

So just have a separate service entry:

<services>    
    <service name="MyService">
        <endpoint name="WsHttpEndpoint"
            address="......."
            binding="wsHttpBinding"
            contract="IMyService" />
    </service>
</services>

and have the PHP client connect here - since there's only a single wsHttpBinding endpoint, that should work.

So you can't really remove any bindings from the metadata - but you can prevent some metadata from being included.

The other option would be to have a separate WSDL for your service, that will work with PHP. You can even define a static external metadata WSDL using the serviceMetadata behavior:

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="test">
          <serviceMetadata 
             externalMetadataLocation="http://YourServer/Service/WSDL/MyService.wsdl"/&gt;
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
marc_s
That's a really good idea... I'll try
Jader Dias
"A child element named 'service' with same key already exists at the same configuration scope
Jader Dias
I tried putting the same name, and different names. With different names the problem it is it doesn't work, probably because the service name also defines which class it should use.
Jader Dias
I don't know if it is possible to have two instances of the same service running side by side in the same process. I have confirmed that the service name is also the name of the class unless you change it with `[ServiceBehavior (Name = "The name of the service")]`. Which does not help in my case.
Jader Dias
Are you hosting your WCF services in IIS ? If so, create a separate virtual directory and put your "one service binding only" stuff there.
marc_s
Nope, I am running a self hosted windows service. I guess I'll have to make a separate installation.
Jader Dias
That's one way to do it, yes - the other would be to create a separate, specific WSDL for those PHP guys (remove all the non-wsHttpBinding stuff from it) and then just send them the WSDL as a file.
marc_s
are you suggesting a handcrafted wsdl? sounds like a good idea
Jader Dias