user1782380
user1782380

Reputation: 49

How do I change wcf port name and binding?

I am new to WCF. I'm trying to create a webservice from a client provided wsdl; I'm having trouble changing some wcf generated wsdl entries to match the provided wsdl.

Here is my wsdl port name :

<wsdl:service name="MyService">
<wsdl:port name="BasicHttpBinding_IService" binding="i0:BasicHttpBinding_IService">
<soap:address location="http://localhost:53336/MyServiceApi.svc"/>
</wsdl:port>
</wsdl:service>

But I need change to

<wsdl:service name="MyServiceSoap">
<wsdl:port name="MyServiceSoap" binding="m:MyServiceSoap">
<soap:address location="http://localhost:53336/MyServiceApi.svc"/>
</wsdl:port>
</wsdl:service>

How do I that? Can someone please show me a simple solution?

Upvotes: 1

Views: 5239

Answers (2)

Lota Lota
Lota Lota

Reputation: 47

I added this attribute to my service implementation and that solved my problem:

[ServiceBehavior(Name = "MyServiceName")]
public class MyServiceClass : IServiceContract
{
  // implementation code
}

Resulting WSDL:

<wsdl:service name="MyServiceName">
  <wsdl:port name="MyServiceClass" binding="tns:MyServiceClass">
    <soap:address location="http://localhost:52233/MyService.svc"/>
  </wsdl:port>
</wsdl:service>

Upvotes: -2

user1782380
user1782380

Reputation: 49

I found a solution to setting port name.

like this:

<services>
  <service name="MyServiceSoap">
    <endpoint name="MyServiceSoap" address="" binding="basicHttpBinding" contract="IService" bindingNamespace="MyServiceSoap" bindingName="MyServiceSoap" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>

then the wsdl port name will be that I want.

Upvotes: 3

Related Questions