我正在尝试使用 jQuery 从 wcf Web 服务获取数据。我的jQuery代码如下:
jQuery.ajax({
type: "POST",
url: serviceWebPath,
data: data,
contentType: "text/xml; charset=utf-8",
dataType: "json",
success: function (data) { alert (data); },
error: _errorHandler
});
我有一份服务合同:
[OperationContract]
String GetContainerByName(String _label);
[OperationContract]
String GetContainerByToken(Guid _Token);
[OperationContract]
void SetContainer(Guid securityToken, String _Content);
我有一个 xsd 文件,我可以在 http://.svc/mex 访问它,其中包括
<wsdl:operation name="GetContainerByToken">
<soap:operation soapAction="http://tempuri.org/IProxyShareContextContract/GetContainerByToken" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
我传递给 jQuery 的数据是:
var data = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetContainerByToken><label>' + clientTokenSecuritySManager + '</label></GetContainerByToken></soap:Body></soap:Envelope>';
我需要访问 GetContainerByToken 方法。但我不断收到此错误:
"The 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,
e.g. Message, Transport, None)."