So i have the below data in app.config of the project that has a serrvice reference:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="P4U" />
<binding name="P4U1">
<security mode="TransportWithMessageCredential" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://*.svc"
binding="basicHttpBinding" bindingConfiguration="P4U" contract=*.ServiceContract"
name="P4U" />
<endpoint address="https://*.svc"
binding="basicHttpBinding" bindingConfiguration="P4U1" contract="*.ServiceContract"
name="P4U1" />
</client>
</system.serviceModel>
I cant use this data in config. Instead, i have to create them in code. I used BasicHttpBinding and it works fine for http calls but i can get it to work for https. I tried basichttps and wshttpbinding. The username and password is send in header. Any idea what to do? I tried with TransportWithMessageCredential with basichttp and basichttps.
Below detail is from the client document:
For each request a SOAP header is required, like in the sample: …
<soap:Header>
<Authentication xmlns="http://*">
<User>customer specific, to be provided</User>
<Password>customer specific, to be provided</Password>
</Authentication>
</soap:Header>
Below code is that i have right now. It is the constructor:
private Binding serviceBinding ;
public ShippingService(string url, AuthenticationHeader webAuthenticationHeader, LogHelper logger)
{
authenticationHeader = webAuthenticationHeader;
this.Logger = logger;
var uri = new Uri(url);
if(uri.Scheme== "https")
{
this.serviceBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
}
else
{
this.serviceBinding = new BasicHttpBinding();
}
this.endpointAddress = new EndpointAddress(url);
}
And in the service call method i have the below line:
ServiceContractClient clientService = new ServiceContractClient (serviceBinding, endpointAddress);
The first exception i got was one below when i was using wshttpbinding:
Content Type application/soap+xml; charset=utf-8 was not supported by service https://*ervice.svc. The client and service bindings may be mismatched. For HTTP's.
I changed back to basic and since then i have been only getting the below exception:
The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.