Witam,
Chciałem wykorzystać api TERYT do pobierania słowników, ale nie wiem jak mam poprawnie wyglądać implementacja w C# z wykorzystaniem klasy ChannelFactory.
Przykład dostajemy, ale nie wiem jak ma wyglądać "ServiceReferenceWCF.ITerytWs1", oraz nie wiem jak dodać plik konfiguracyjny do projektu, żeby załapało (czy może przypadkiem trzeba go dodać w App.config?).
Poniżej przykładowy klient + plik konfiguracyjny.
try {
var proxy = new ChannelFactory<ServiceReferenceWCF.ITerytWs1>("custom");
proxy.Credentials.UserName.UserName = login;
proxy.Credentials.UserName.Password = haslo;
var result = proxy.CreateChannel();
var test = result.CzyZalogowany(); }
catch (Exception ex) { }
Dostajemy również przykład pliku konfigurayjnego, dla klienta:
<client> <endpoint address="https://uslugaterytws1.stat.gov.pl/TerytWs1.svc" binding="customBinding" bindingConfiguration="custom" contract="ServiceReference1.ITerytWs1" name="custom" />
</client> <bindings> <customBinding> <binding name="custom">
<security defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport" requireDerivedKeys="true" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<localClientSettings detectReplays="false" /> <localServiceSettings detectReplays="false" /> </security>
<textMessageEncoding messageVersion="Soap11WSAddressing10" />
<httpsTransport maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"/> </binding> </customBinding> </bindings>