jQuery技术:无法处理带有“操作”的消息

当我从JQuery调用WCF SOAP服务时,有人能告诉我如何解决这个错误吗?

错误:

a:ActionNotSupportedThe message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, eg Message, Transport, None). 

如果我使用Fiddler重建请求并添加SOAPAction http标头部分,我得到相同的错误,除了我给它的值。

这是我的web.config:

                                  

这是我的App_Code / CatalogService.cs:

 [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)] public class CatalogService : ICatalogService { public string HelloWorld(string name){ return String.Format("Hello {0}", name);}} 

这是我的App_Code / CatalogIService.cs:

 [ServiceContract(Namespace = "https://miami.edu/")] public interface ICatalogService { [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml)] string HelloWorld(string name);} 

这是我的jQuery客户端代码:

  $.ajax({ type: 'POST', url: 'https://localhost/csw/service.svc/soap', data: request, contentType: 'text/xml; charset=utf-8', dataType: 'text', success: function (result) { console.log(result); $("#result").text(result); //result.responseXML //result.responseText }, error: function (message) { console.log(message); alert("error has occured" + message); }}); 

这是我的SOAP请求:

    CarlosK    

    你缺少HelloWorld方法的OperationContract属性。 比起Fiddler调用应该使用SOAPAction

    你的jQuery问题。 我只是在动作书中检查jQuery中的$ .ajax函数,我认为你需要定义函数来创建SOAPAction头并将该函数分配给$ .ajax中的beforeSend。

    编辑:

    基于这个问题和您之前的问题:为什么要使用SOAP? 您似乎正在开发服务和客户。 您是否有使用SOAP的特定要求或仅仅是一些练习? 从jQuery中使用RESTful服务要容易得多。 RESTful服务可以返回POX(普通旧XML)或JSON。

    需要了解更多jQuery教程分享无法处理带有“操作”的消息,都可以关注jQuery技术分享栏目—计算机技术网(www.ctvol.com)!

      以上就是jQuery教程分享无法处理带有“操作”的消息相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/jquerytutorial/981451.html

      (0)
      上一篇 2021年12月12日
      下一篇 2021年12月12日

      精彩推荐