Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. An unhandled exception of type 'System.Net.WebException' occurred in System.dll
  2.  
  3. Additional information: The remote server returned an error: (400) Bad Request.
  4.  
  5. <?xml version="1.0"?>
  6. <configuration>
  7. <system.web>
  8. <compilation debug="true" targetFramework="4.5" />
  9. <httpRuntime targetFramework="4.5"/>
  10. </system.web>
  11. <system.serviceModel>
  12. <behaviors>
  13. <serviceBehaviors>
  14. <behavior>
  15. <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
  16. <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
  17. <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
  18. <serviceDebug includeExceptionDetailInFaults="false"/>
  19. </behavior>
  20. </serviceBehaviors>
  21. </behaviors>
  22. <services>
  23. <service name="WcfService1.Service1">
  24. <endpoint address="Soap" binding="basicHttpBinding" contract="WcfService1.IService1" />
  25. <endpoint address="Http" kind="webHttpEndpoint" contract="WcfService1.IService1" />
  26. <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  27. </service>
  28. </services>
  29. <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  30. </system.serviceModel>
  31. <system.webServer>
  32. <modules runAllManagedModulesForAllRequests="true"/>
  33. <httpErrors errorMode="Detailed"/>
  34. </system.webServer>
  35. </configuration>
  36.  
  37. [ServiceContract]
  38. public interface IService1
  39. {
  40. [OperationContract]
  41. [WebInvoke]
  42. string GetData(string channel);
  43. }
  44.  
  45. private static string HttpPost(string _postData)
  46. {
  47. using (WebClient webClient = new WebClient())
  48. {
  49. webClient.BaseAddress = "http://localhost:62147/Service1.svc/Soap/";
  50. webClient.Headers.Add("Content-Type", "text/xml; charset=utf-8");
  51. webClient.Headers.Add("SOAPAction", "http://tempuri.org/IService1/GetData");
  52.  
  53. byte[] response = webClient.UploadData("GetData", Encoding.UTF8.GetBytes(_postData));
  54.  
  55. return Encoding.UTF8.GetString(response);
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement