wcf中的POST方法休息服务

编程入门 行业动态 更新时间:2024-10-28 08:25:53
本文介绍了wcf中的POST方法休息服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我得到相同的错误:

protected void Button1_Click(object sender, EventArgs e) { BasicHttpBinding binding = new BasicHttpBinding(); binding.ReaderQuotas.MaxStringContentLength = 2000000; binding.MaxBufferSize = 2147483647; binding.MaxReceivedMessageSize = 2147483647; binding.ReaderQuotas.MaxNameTableCharCount = 2147483647; binding.Security.Transport.ClientCredentialTypeHttpClientCredentialType.Windows; binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; binding.CloseTimeout = new TimeSpan(4, 0, 0); binding.OpenTimeout=new TimeSpan(4, 0, 0); binding.ReceiveTimeout=new TimeSpan(2, 0, 0); binding.SendTimeout = new TimeSpan(5, 0, 0); EndpointAddress endpoint = new EndpointAddress(new Uri("localhost:35798/RestServiceImpl.svc")); RestPostService.RestServiceImplClient obj = new RestPostService.RestServiceImplClient(binding, endpoint); RestPostService.EmailDetails obj1 = new RestPostService.EmailDetails(); obj.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; RestPostService.EmailDetails obj2=obj.SendMail(obj1); } **web.config** <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <bindings> <webHttpBinding> <binding name="webHttpBinding" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"/> </webHttpBinding> </bindings> <services> <service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour"> <endpoint address ="localhost:35798/RestServiceImpl" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="webHttp"/> </service> </services> <behaviors> <serviceBehaviors> <behavior name="webHttp"> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="true"/> <!-- 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 --> <serviceDebug includeExceptionDetailInFaults="true"/> <dataContractSerializer maxItemsInObjectGraph="6553600"/> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="web"> <webHttp/> </behavior> </endpointBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration>

为了使代码正常工作,我应该做什么更改。 错误:服务器没有提供有意义的回复;这可能是由于合同不匹配,过早的会话关闭或内部服务器错误。

What changes should i made in order to make the code working. Error: The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.

请帮助解决问题。 p>

Please help in the indiacted issue.

推荐答案

您在代码中使用错误的WCF绑定。配置XML使用 WebHttpBinding 显示WCF服务。重构您的客户端创建代码为:

You are using the wrong WCF binding in you code. The config XML shows the WCF service using the WebHttpBinding. Refactor your client creation code to something like:

WebHttpBinding binding = new WebHttpBinding(); // The rest of the configuration

不知道是否所有属性设置将对此绑定有效,但编译器将知道:)

Don't know if all the properties you are setting will be valid for this binding but the compiler will know :)

更多推荐

wcf中的POST方法休息服务

本文发布于:2023-10-11 04:46:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1480724.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法   wcf   POST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!