Guest User

Untitled

a guest
Apr 21st, 2018
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <system.serviceModel>
  2. <services>
  3. <service behaviorConfiguration="ServiceBehavior" name="TestAPI">
  4. <endpoint address="" behaviorConfiguration="RESTFriendly" binding="webHttpBinding" contract="ITestAPI" />
  5. <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  6. </service>
  7. </services>
  8. <behaviors>
  9. <endpointBehaviors>
  10. <behavior name="RESTFriendly">
  11. <webHttp />
  12. </behavior>
  13. </endpointBehaviors>
  14. <serviceBehaviors>
  15. <behavior name="ServiceBehavior">
  16. <serviceMetadata httpGetEnabled="true" />
  17. <serviceDebug includeExceptionDetailInFaults="true" />
  18. </behavior>
  19. </serviceBehaviors>
  20. </behaviors>
  21.  
  22. <appSettings>
  23. <add key="WEBSERVICE" value="URL"/>
  24.  
  25. WebChannelFactory<ITestAPI> cf = new WebChannelFactory<IAPI>(baseAddress);
  26. WebHttpBinding wb =cf.Endpoint.Binding as WebHttpBinding;
  27. wb.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
  28. wb.Security.Mode = WebHttpSecurityMode.Transport;
  29. cf.Credentials.UserName.UserName = "usermane";
  30. cf.Credentials.UserName.Password = "password";
  31.  
  32. ITestAPI channel = cf.CreateChannel();
  33. string msg = channel.TestMethod();
RAW Paste Data