【问题标题】:How to consume non rest wcf service using Jquery?如何使用 Jquery 使用非休息 wcf 服务?
【发布时间】:2016-11-05 09:15:29
【问题描述】:

有什么方法可以使用 Jquery 来使用非休息 WCF 服务?我有使用 basicHttpBinding 公开的 wcf 服务。我想知道我们是否可以直接使用此服务而无需使用 svcutil.exe 创建代理

谢谢, 贾加迪什

【问题讨论】:

标签: jquery wcf


【解决方案1】:

您可以使用jQuery ajax 使用该服务。 请参阅此示例,从我使用的服务中复制:

// Here you define your message. You can use SOAP or VS to create a message and copy here
var soapMessage = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">.....</s:Envelope>';
$.ajax({
    // Method must be POST
    type:"POST",
    // Here you can also specify the encoding if necessary:
    contentType: "text/xml",
    url:"http://address/Service.svc/Operation",
    dataType: "xml",
    data: soapMessage,
    // Here you must define the contract and operation:
    headers: { "SOAPAction": "http://tempuri.org/Contract/Operation" },
    success: function(data){
        ...
    },
    error: function(request, error){
        ...
    },
});

如果您使用的是旧版本的 jQuery,则无法支持 headers,您应该改用 beforSend

【讨论】:

    猜你喜欢
    • 2011-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多