1
嗨,我有下一個WCF服務。Jquery(ajax請求)到WCF。 WCF沒有初始化數據參數
[OperationContract]
[WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
//[WebInvoke(UriTemplate = "GetStores?dataViewID={dataViewID}&filter={filter}&extent={extent}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,)]
string GetStores(int dataViewID, string filter, MapExtent extent);
[DataContract]
public class MapExtent
{
[DataMember]
public double XMax { get; set; }
[DataMember]
public double XMin { get; set; }
[DataMember]
public double YMax { get; set; }
[DataMember]
public double YMin { get; set; }
}
jQuery的部分是未來
//var mapextend = { XMax: 1.0, XMin: 1.0, YMax: 10.5, YMin: 4.5 };
var paramData = {"dataViewID":12, "filter":"", extent : {"XMax": 1.0, "XMin": 1.0, "YMax": 10.5, "YMin": 4.5} };
$.ajax({
url: serviceurl + 'GetStores',
type: 'GET',
contentType: 'application/json',
data: paramData,
success: function (result) {
alert(result);
},
error: function (xhr) {
alert(xhr);
}
});
配置看上去像是
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webBinding"></binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="jsonBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service behaviorConfiguration="ServiceBehavior" name="MyService">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" contract="IMyService" behaviorConfiguration="jsonBehavior" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
當Ajax調用該服務調用,但所有的參數沒有得到任何價值。我做錯了什麼?
我柴草有關數據類型: 「JSON」 –