I am trying to read endpoint from servicereferences.clientconfig file in my code like this:
public BaseRepository()
{
_proxy = new MyServiceClient("BasicHttpBinding_IMyService");
this.binding = (BasicHttpBinding)_proxy.Endpoint.Binding;
this.endpoint = _proxy.Endpoint.Address;
}
Here “BasicHttpBinding_IMyService” is the name of my endpoint as defined in Servicereferences.ClientConfig.
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://xxx/myservice.svc?wsdl"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
contract="IMyserviceContract" name="BasicHttpBinding_IMyService" />
</client>
</system.serviceModel>
It works fine when I run it on local but doesn’t work when I deploy it on server.
Am I missing something?
I thing your server is an Https SSL Secured server.
If so you should solve it by a small modification in your code.
In your binding there is an EndpointAdrress and as I remember there is a Protocol property on it it can be “http” or “https”.
If its https, binding has SecurityMode option it should be set as Transport which SSL uses.
For other scenarios you should open tracing by in you web.config
Then call your service and open your c:\log\Traces.svclog with SvcTraceViewer.exe
Inspect red logs.
Hope helps!