[英]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.