Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.14 KB | None | 0 0
  1. Запрос HTTP не разрешен для схемы аутентификации клиента "Anonymous". От сервера получен заголовок аутентификации "Basic realm="1C:Enterprise 8.3"".
  2.  
  3. <bindings>
  4. <basicHttpBinding>
  5. <binding name="BasicAuth">
  6. <security mode="TransportCredentialOnly">
  7. <transport clientCredentialType="Basic" />
  8. </security>
  9. </binding>
  10. </basicHttpBinding>
  11. </bindings>
  12.  
  13. <configuration>
  14. <configSections>
  15. <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  16. <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  17. </configSections>
  18. <connectionStrings>
  19. <remove name="LocalSqlServer" />
  20. <add name="ScanStoreEntities" connectionString="" providerName="System.Data.EntityClient" />
  21. <add name="MembershipConnection" connectionString="" providerName="System.Data.SqlClient" />
  22. </connectionStrings>
  23. <appSettings>
  24. <add key="webpages:Version" value="2.0.0.0" />
  25. <add key="webpages:Enabled" value="false" />
  26. <add key="PreserveLoginUrl" value="true" />
  27. <add key="ClientValidationEnabled" value="true" />
  28. <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  29. <add key="StorePath" value="" />
  30. <add key="IronManPath" value="" />
  31. </appSettings>
  32. <system.web>
  33. <customErrors mode="Off" />
  34. <compilation debug="true" targetFramework="4.5">
  35. <assemblies>
  36. <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  37. </assemblies>
  38. </compilation>
  39. <httpRuntime maxQueryStringLength="1048575" maxRequestLength="1048575" executionTimeout="3600" targetFramework="4.5" />
  40. <authorization>
  41. <allow users="?" />
  42. </authorization>
  43. <authentication mode="Forms">
  44. <forms loginUrl="~/Account/Login" timeout="2880" name="PKB_AUTH" />
  45. </authentication>
  46. <profile>
  47. <providers>
  48. <clear />
  49. <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
  50. </providers>
  51. </profile>
  52. <roleManager enabled="true">
  53. <providers>
  54. <clear />
  55. <add connectionStringName="MembershipConnection" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
  56. <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" />
  57. </providers>
  58. </roleManager>
  59. <pages controlRenderingCompatibilityVersion="4.0">
  60. <namespaces>
  61. <add namespace="System.Web.Helpers" />
  62. <add namespace="System.Web.Mvc" />
  63. <add namespace="System.Web.Mvc.Ajax" />
  64. <add namespace="System.Web.Mvc.Html" />
  65. <add namespace="System.Web.Optimization" />
  66. <add namespace="System.Web.Routing" />
  67. <add namespace="System.Web.WebPages" />
  68. </namespaces>
  69. </pages>
  70. <membership>
  71. <providers>
  72. <clear />
  73. <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MembershipConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="8" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" passwordFormat="Hashed" />
  74. </providers>
  75. </membership>
  76. </system.web>
  77. <system.webServer>
  78. <validation validateIntegratedModeConfiguration="false" />
  79. <modules runAllManagedModulesForAllRequests="true" />
  80. <handlers>
  81. <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
  82. <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
  83. <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  84. <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFrameworkv4.0.30319aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
  85. <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%Microsoft.NETFramework64v4.0.30319aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
  86. <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
  87. </handlers>
  88. <urlCompression doStaticCompression="true" doDynamicCompression="true" />
  89. <security>
  90. <requestFiltering>
  91. <requestLimits maxUrl="10999" maxQueryString="2097151" maxAllowedContentLength="1073741824" />
  92. </requestFiltering>
  93. </security>
  94. </system.webServer>
  95. <runtime>
  96. <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  97. <dependentAssembly>
  98. <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
  99. <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  100. </dependentAssembly>
  101. <dependentAssembly>
  102. <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" />
  103. <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  104. </dependentAssembly>
  105. <dependentAssembly>
  106. <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
  107. <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
  108. </dependentAssembly>
  109. <dependentAssembly>
  110. <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
  111. <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  112. </dependentAssembly>
  113. <dependentAssembly>
  114. <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
  115. <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
  116. </dependentAssembly>
  117. <dependentAssembly>
  118. <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
  119. <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
  120. </dependentAssembly>
  121. <dependentAssembly>
  122. <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
  123. <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
  124. </dependentAssembly>
  125. </assemblyBinding>
  126. </runtime>
  127. <entityFramework>
  128. <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
  129. <parameters>
  130. <parameter value="v11.0" />
  131. </parameters>
  132. </defaultConnectionFactory>
  133. <providers>
  134. <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
  135. </providers>
  136. </entityFramework>
  137. <system.serviceModel>
  138. <bindings>
  139. <basicHttpBinding>
  140. <binding name="HKDSoapBinding" />
  141.  
  142. </basicHttpBinding>
  143. <customBinding>
  144. <binding name="HKDSoap12Binding">
  145. <security mode="TransportCredentialOnly">
  146. <transport clientCredentialType="Basic" />
  147. </security>
  148. <textMessageEncoding messageVersion="Soap12" />
  149.  
  150. <httpTransport />
  151. </binding>
  152.  
  153. </customBinding>
  154. </bindings>
  155. <client>
  156. <endpoint address="http://172.16.0.3/Test_BIT/ws/hkd.1cws" binding="basicHttpBinding"
  157. bindingConfiguration="HKDSoapBinding" contract="ServiceReference1C.HKDPortType"
  158. name="HKDSoap" />
  159. <endpoint address="http://172.16.0.3/Test_BIT/ws/hkd.1cws" binding="customBinding"
  160. bindingConfiguration="HKDSoap12Binding" contract="ServiceReference1C.HKDPortType"
  161. name="HKDSoap12" />
  162. </client>
  163. </system.serviceModel>
  164. </configuration>
  165.  
  166. BasicHttpBinding myBinding = new BasicHttpBinding();
  167.  
  168.            myBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
  169.  
  170.            myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
  171.  
  172.  
  173.  
  174.  
  175.  
  176.            EndpointAddress ea = new EndpointAddress("http://172.16.0.3/Test_BIT/ws/hkd.1cws");
  177.  
  178.  
  179.            restcoachPortTypeClient Service = new restcoachPortTypeClient(myBinding, ea);
  180. Service.ClientCredentials.UserName.UserName = Login;
  181. Service.ClientCredentials.UserName.Password = Password;
  182.  
  183. using (new OperationContextScope((IClientChannel)client))
  184. {
  185. HttpRequestMessageProperty requestProperty = new HttpRequestMessageProperty();
  186. string credentials = string.Format("{0}:{1}", _username, _password);
  187. requestProperty.Headers["Authorization"] = string.Format("Basic {0}", Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes(credentials)));
  188. OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestProperty;
  189. data = client.GetData1();
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement