[英]Passing DateTime as a parameter between android client and WCF Service using Json
[英]WCF Service (JSON) and Android client - message security
我有WCF服務,該服務獲取並返回JSON數據。 和調用該服務的Android移動應用。
編輯:
這是服務器端和客戶端的附加信息。
該服務如下:
服務接口 :
<ServiceContract()>
Public Interface ITest
<OperationContract()>
<WebInvoke(Method:="POST", RequestFormat:=WebMessageFormat.Json, ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.WrappedRequest)>
Function Test(header As RequestHeader, body As TestRequestResponse) As Boolean
End Interface
服務編號
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)>
<ServiceBehavior(ConcurrencyMode:=ConcurrencyMode.Multiple, InstanceContextMode:=InstanceContextMode.Single)>
Public Class TestService
Implements ITest
Public Function Test(header As RequestHeader, body As TestRequestResponse) As Boolean Implements ITest.Test
Return True
End Function
End Class
Web配置
<system.serviceModel>
<services>
<service behaviorConfiguration="RMWS.TestBehavior" name="RMWS.TestService">
<endpoint address="Test" binding="webHttpBinding" behaviorConfiguration="WebBehavior" bindingConfiguration="WebBinding" contract="RMWS.ITest" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="WebBinding"/>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="RMWS.TestBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
客戶電話
當前使用javascript進行的客戶端調用僅用於測試。 將來,客戶端將是android應用,但總體思路是相同的。
$.ajax({
type: "POST",
url: "http://localhost/RMWS/TestService.svc/Test/Test",
contentType: "application/json",
dataType: "json",
data: JSON.stringify(somedata),
success: function (data)
{
...
},
error: function (httpRequest, textStatus, errorThrown)
{
alert(textStatus + ": " + errorThrown);
}
});
編輯2:
我知道使用SSL可以輕松完成。 但是在我公司中,這對於性能和流量而言太昂貴了,因此他們不想使用SSL,而是進行其他一些加密。 如果可能的話,只有請求可以被編碼,因為響應不包含任何敏感信息。
編輯3:
除了約瑟夫的回答,還有其他意見嗎?
如果您想繼續使用JSON,則SSL是最好的選擇,您可以對JSON進行混淆處理,但是它將不再是JSON,將變得愚蠢,並且仍然對真正感興趣的人可用。
最好的選擇是將二進制文件發送到設備,您可以使用pgp對其進行加密,但是接下來的問題是將私鑰存儲在本身不是很安全的android應用中。
SSL是最安全的選擇。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.