【发布时间】:2013-10-28 17:56:15
【问题描述】:
我需要使用 web 服务 (.Net asmx),其中很少有方法接受 .Net 对象作为参数。例如,一种方法具有以下签名:
public Item SaveData(string itemName, string guid, Location storeAddress, Price price)
前 2 个参数是简单的对象(字符串),因此发送到 WS 没有什么特别的。我的问题是最后两个参数。该位置在 .Net 上定义为:
public class Location
{
double longitude, latitude;
public Location()
{
}
public Location(double longitude, double latitude)
{
this.Longitude = longitude;
this.Latitude = latitude;
}
public Location(String longitude, String latitude)
{
this.Longitude = double.Parse(longitude);
this.Latitude = double.Parse(latitude);
}
public double Longitude
{
get { return longitude; }
set { longitude = value; }
}
public double Latitude
{
get { return latitude; }
set { latitude = value; }
}
}
价格类似于 //不是所有代码
public class Price {
//private vars
public Price(float price, float discount, string currency){
//vars assignment
}
//more methods and properties
}
现在在 Java (android) 上,我使用 HttpClient 和 HttpParams 来发送帖子数据。
我的问题是: 1.我如何构建JSON以将所需的参数发送到服务器? 2.有什么工具可以帮助我构建请求吗?我正在寻找能够阅读 wsdl 并构建示例请求的东西。
谢谢。
【问题讨论】:
-
你需要storm 来检查你的wsdl
-
风暴对我没有帮助。它不知道构建 JSON 请求。我不需要 XML。
-
如果分析xml,构建json字符串就足够解释了。
标签: android web-services