问题描述
大家好。我通过httpWebRequest向WCF服务发送Get请求。服务端响应请求后接收的参数中的时间字符串就变了。请问下这是怎么回事。请求是通过httpWebRequest发送Get请求,请求是日期字符串“2014-09-19T00:00:00+08:00”接收后的日期字符串“2014-09-19T00:00:0008:00”就是中间的+号变成空格了。这个问题感觉好奇怪,研究了一天也没解决,请各位大虾指教,谢谢!以下是我配置的wcf服务端协议<servicebehaviorConfiguration="metadataBehavior"name="WcfServiceLibrary.LogisticsCostService"><endpointaddress=""binding="webHttpBinding"bindingName="WebBinding"contract="WcfServiceLibrary.ILogisticsCostService"behaviorConfiguration="webBehaviour"/><host><baseAddresses><addbaseAddress="http://localhost:8036/LogisticsCostService"/></baseAddresses></host></service>请求参数:{"StandardParameterId":"Id001","SalesPlatformName":"eBay","PurchaseCost":11.066,"SellerAccount":"espaceship","Station":"DE","IsHighValue":false,"SendType":"None","IsRegister":false,"ProductCode":"BP278","ShippingService":"DE_StandardversandAusDemAusland","DispatchTimeMax":2.0,"FromWarehouse":"HF-SZ","ToCountry":"Germany","ToProvince":"","DestPostCode":"","Length":0.18,"Width":0.043,"Height":0.042,"Volume":0.0003,"Weight":0.058,"PackageType":"P","OrderDate":"2014-09-19T00:00:00+08:00"}接收后的参数{"StandardParameterId":"Id001","SalesPlatformName":"eBay","PurchaseCost":11.066,"SellerAccount":"espaceship","Station":"DE","IsHighValue":false,"SendType":"None","IsRegister":false,"ProductCode":"BP278","ShippingService":"DE_StandardversandAusDemAusland","DispatchTimeMax":2.0,"FromWarehouse":"HF-SZ","ToCountry":"Germany","ToProvince":"","DestPostCode":"","Length":0.18,"Width":0.043,"Height":0.042,"Volume":0.0003,"Weight":0.058,"PackageType":"P","OrderDate":"2014-09-19T00:00:0008:00"}
解决方案
解决方案二:
请求参数:{"StandardParameterId":"Id001","SalesPlatformName":"eBay","PurchaseCost":11.066,"SellerAccount":"espaceship","Station":"DE","IsHighValue":false,"SendType":"None","IsRegister":false,"ProductCode":"BP278","ShippingService":"DE_StandardversandAusDemAusland","DispatchTimeMax":2.0,"FromWarehouse":"HF-SZ","ToCountry":"Germany","ToProvince":"","DestPostCode":"","Length":0.18,"Width":0.043,"Height":0.042,"Volume":0.0003,"Weight":0.058,"PackageType":"P","OrderDate":"2014-09-19T00:00:00+08:00"}接收后的参数{"StandardParameterId":"Id001","SalesPlatformName":"eBay","PurchaseCost":11.066,"SellerAccount":"espaceship","Station":"DE","IsHighValue":false,"SendType":"None","IsRegister":false,"ProductCode":"BP278","ShippingService":"DE_StandardversandAusDemAusland","DispatchTimeMax":2.0,"FromWarehouse":"HF-SZ","ToCountry":"Germany","ToProvince":"","DestPostCode":"","Length":0.18,"Width":0.043,"Height":0.042,"Volume":0.0003,"Weight":0.058,"PackageType":"P","OrderDate":"2014-09-19T00:00:0008:00"}
解决方案三:
+号变成空格不知道是浏览器还是什么其它原因,但事实是会变成空格,一般解决方法就是在服务端将空格替换为+号,不过这有很大的局限性
解决方案四:
再服务器端替换的话局限性是很大的。而且这个wcf方法用C#写函数调用是可以调用的,但是给他用JAVA的同事调用,他们发的是httpget请求就由于少了+号调用不了。有没有可能是设置的问题呢,服务器端哪里是不是要改下设置?像下面这样调用是可以的。SRLogisticsCostService.LogisticsCostServiceClientservice=newSRLogisticsCostService.LogisticsCostServiceClient("BasicHttpBinding_ILogisticsCostService","http://192.168.52.100:8094/LogisticsCostService.svc");service.CalcSingleStandard(parameterJson,true);
解决方案五:
service接口定义发来看看
解决方案六:
如果通过url来调用,datetime的参数哎url中的表现和从c#代码中调用是不同的。