I'm having issues setting up Microsoft Translator SOAP Service with my c# application without it relying on its generated app.config file.
The app.config file contains the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_LanguageService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://api.microsofttranslator.com/V2/soap.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_LanguageService"
contract="Soap.LanguageService" name="BasicHttpBinding_LanguageService" />
</client>
</system.serviceModel>
</configuration>
In reference to this Stack answer, I used the following method:
internal static Soap.LanguageServiceClient CreateWebServiceInstance()
{
BasicHttpBinding binding = new BasicHttpBinding();
binding.Name = "BasicHttpBinding_LanguageService";
binding.TextEncoding = System.Text.Encoding.UTF8;
return new Soap.LanguageServiceClient(binding, new EndpointAddress("http://api.microsofttranslator.com/V2/soap.svc"));
}
However, even though I call CreateWebServiceInstance()
before I execute the translator service, I get this unhandled exception:
Could not find default endpoint element that references contract 'Soap.LanguageService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
I'm not familiar with BasicHttpBinding
, so I'm not sure where to start...