Java 和 C# 中的对象
我运行一个 WCF 服务,该服务有一个以对象 - Person - 作为参数的方法。
Person 包含
public String name {get; set;}
public String city {get; set;}
我正在从 Android (Java) 调用 wcf 服务。在 Java 中,如何创建一个 C# 识别为 Person 的对象? (所以我可以将它作为参数发送给服务)
I run a WCF service, who has a method taking an object - Person - as parameter.
Person contains
public String name {get; set;}
public String city {get; set;}
I'm calling the wcf service from Android (Java). How can I, in Java, create an object which C# recognizes as Person? (So I can send it as a parameter to the service)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,Android 的 Java 版本不允许使用 JAX-WS (这会使事情变得容易多了)。
相反,您必须 进行多次低级调用才能调用您的网络服务。
您可能需要考虑将 .NET 中的服务公开为具有 JSON 编码的 RESTful 服务。这将使事情变得更加容易,因为 Android 库对 JSON 序列化具有本机支持,并且向 RESTful url 发出 HTTP GET 请求比 HTTP POST 请求简单得多(这不是一个大问题,但您需要担心的事情更少) 。
Basically, the version of Java for Android doesn't allow for using JAX-WS (which would make things so much easier).
Instead, you have to make a number of low-level calls in order to call your web-service.
What you might want to consider is exposing the service in .NET as a RESTful service with JSON encoding. This would make things considerably easier, as the Android library has native support for JSON serialization, and making HTTP GET requests to RESTful urls is much simpler than HTTP POST requests (it's not a huge deal, but just less stuff you have to worry about).