ofbiz的webservice接口提供(2)-数据类型的局限性
2013-04-14 13:03
267 查看
ofbiz4对于webservice的支持实在是不咋地,在官方的文档中,SOAP只是支持基础类型的数据的传入传出,这些基础的数据类型我们可以参照org.ofbiz.service.ModelParam的java2wsdlType方法。大家可以看到这个方法的类只是支持简单的基础数据类型。如下:
[java:showcolumns]
view plaincopy
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
protected
String java2wsdlType() throws
WSDLException {
if
(ObjectType.instanceOf(java.lang.Character.class,
this.type))
{
return
"string";
}
else
if
(ObjectType.instanceOf(java.lang.String.class,
this.type))
{
return
"string";
}
else
if
(ObjectType.instanceOf(java.lang.Byte.class,
this.type))
{
return
"byte";
}
else
if
(ObjectType.instanceOf(java.lang.Boolean.class,
this.type))
{
return
"boolean";
}
else
if
(ObjectType.instanceOf(java.lang.Integer.class,
this.type))
{
return
"int";
}
else
if
(ObjectType.instanceOf(java.lang.Double.class,
this.type))
{
return
"double";
}
else
if
(ObjectType.instanceOf(java.lang.Float.class,
this.type))
{
return
"float";
}
else
if
(ObjectType.instanceOf(java.lang.Short.class,
this.type))
{
return
"short";
}
else
if
(ObjectType.instanceOf(java.math.BigDecimal.class,
this.type))
{
return
"decimal";
}
else
if
(ObjectType.instanceOf(java.math.BigInteger.class,
this.type))
{
return
"integer";
}
else
if
(ObjectType.instanceOf(java.util.Calendar.class,
this.type))
{
return
"dateTime";
}
else
if
(ObjectType.instanceOf(java.util.Date.class,
this.type))
{
return
"dateTime";
}
else
if
(ObjectType.instanceOf(java.lang.Long.class,
this.type))
{
return
"unsignedInt";
}
else
if
(ObjectType.instanceOf(java.sql.Timestamp.class,
this.type))
{
return
"string";
}
//
TODO add array support (maybe even convert List objects); add GenericValue/Map support
throw
new
WSDLException(WSDLException.OTHER_ERROR, "Service
cannot be described with WSDL (" +
this.name
+ " / "
+ this.type
+ ")");
}
这个方法就是帮助我们生成wsdl文件,或者说wsdl = dctx.getWSDL(serviceName, locationUri)调用了上边的方法,用eclipse很容易就找到了ofbiz/framework/service/src/org/ofbiz/service/ModelParam.java里面的:
protected String java2wsdlType() throws WSDLException
这个方法是来吧serivce中参数类型转换成web service的参数类型的,
如果你定义的输出的数据类型超出这些数据类型,那么当你请求wsdl链接的时候就等着报错吧。
不过如果你有兴趣针对支持的基础数据类型做修正,那么你可以修改这个地方的代码。
这里补充一个基础知识,ofbiz中实体中的字段类型,对应的java中的数据类型的定义是通过一个xml文件定义的,在framework/entity/fieldtype下,这下面有很多个文件,是不同的数据库对应的配置文件,
我们看无论是mysql或者是derby,实体中的date对应的java类型是java.sql.Date。
由上边的基础知识引发的常见问题如:当我们的数据类型是java.sql.Date,而我们ofbiz支持的基础数据类型又不支持这个基础类型,那么这个时候我们可能不得不更改这个文件来支持我们的这个数据类型了。
更改方法很简单就是加上如下的代码,并重新编辑整个项目:
[java]
view plaincopy
}
else
if
(ObjectType.instanceOf(java.sql.Date.class,
this.type))
{
return
"dateTime";
}
else
if
(ObjectType.instanceOf(java.sql.Time.class,
this.type))
{
return
"string";
}
由此可见我们ofbiz的soap支持的webservice的参数类型真是不完善。更加不会支持那些序列化的复杂数据类型了。
[java:showcolumns]
view plaincopy
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
protected
String java2wsdlType() throws
WSDLException {
if
(ObjectType.instanceOf(java.lang.Character.class,
this.type))
{
return
"string";
}
else
if
(ObjectType.instanceOf(java.lang.String.class,
this.type))
{
return
"string";
}
else
if
(ObjectType.instanceOf(java.lang.Byte.class,
this.type))
{
return
"byte";
}
else
if
(ObjectType.instanceOf(java.lang.Boolean.class,
this.type))
{
return
"boolean";
}
else
if
(ObjectType.instanceOf(java.lang.Integer.class,
this.type))
{
return
"int";
}
else
if
(ObjectType.instanceOf(java.lang.Double.class,
this.type))
{
return
"double";
}
else
if
(ObjectType.instanceOf(java.lang.Float.class,
this.type))
{
return
"float";
}
else
if
(ObjectType.instanceOf(java.lang.Short.class,
this.type))
{
return
"short";
}
else
if
(ObjectType.instanceOf(java.math.BigDecimal.class,
this.type))
{
return
"decimal";
}
else
if
(ObjectType.instanceOf(java.math.BigInteger.class,
this.type))
{
return
"integer";
}
else
if
(ObjectType.instanceOf(java.util.Calendar.class,
this.type))
{
return
"dateTime";
}
else
if
(ObjectType.instanceOf(java.util.Date.class,
this.type))
{
return
"dateTime";
}
else
if
(ObjectType.instanceOf(java.lang.Long.class,
this.type))
{
return
"unsignedInt";
}
else
if
(ObjectType.instanceOf(java.sql.Timestamp.class,
this.type))
{
return
"string";
}
//
TODO add array support (maybe even convert List objects); add GenericValue/Map support
throw
new
WSDLException(WSDLException.OTHER_ERROR, "Service
cannot be described with WSDL (" +
this.name
+ " / "
+ this.type
+ ")");
}
这个方法就是帮助我们生成wsdl文件,或者说wsdl = dctx.getWSDL(serviceName, locationUri)调用了上边的方法,用eclipse很容易就找到了ofbiz/framework/service/src/org/ofbiz/service/ModelParam.java里面的:
protected String java2wsdlType() throws WSDLException
这个方法是来吧serivce中参数类型转换成web service的参数类型的,
如果你定义的输出的数据类型超出这些数据类型,那么当你请求wsdl链接的时候就等着报错吧。
不过如果你有兴趣针对支持的基础数据类型做修正,那么你可以修改这个地方的代码。
这里补充一个基础知识,ofbiz中实体中的字段类型,对应的java中的数据类型的定义是通过一个xml文件定义的,在framework/entity/fieldtype下,这下面有很多个文件,是不同的数据库对应的配置文件,
我们看无论是mysql或者是derby,实体中的date对应的java类型是java.sql.Date。
由上边的基础知识引发的常见问题如:当我们的数据类型是java.sql.Date,而我们ofbiz支持的基础数据类型又不支持这个基础类型,那么这个时候我们可能不得不更改这个文件来支持我们的这个数据类型了。
更改方法很简单就是加上如下的代码,并重新编辑整个项目:
[java]
view plaincopy
}
else
if
(ObjectType.instanceOf(java.sql.Date.class,
this.type))
{
return
"dateTime";
}
else
if
(ObjectType.instanceOf(java.sql.Time.class,
this.type))
{
return
"string";
}
由此可见我们ofbiz的soap支持的webservice的参数类型真是不完善。更加不会支持那些序列化的复杂数据类型了。
相关文章推荐
- ofbiz的webservice接口提供(2)-数据类型的局限性
- ofbiz的webservice接口提供(2)-数据类型的局限性
- 转 ofbiz的webservice接口提供(2)-数据类型的局限性
- ofbiz的webservice接口提供(2)-数据类型的局限性
- ofbiz的webservice接口提供(2)-数据类型的局限性
- 转 ofbiz的webservice接口提供(2)-数据类型的局限性
- ofbiz的webservice接口提供(2)-数据类型的局限性
- ofbiz的webservice接口提供(2)-数据类型的局限性
- ofbiz的webservice接口提供(2)-数据类型的局限性
- ofbiz的webservice接口提供(4)-支持复杂数据类型方法
- ofbiz的webservice接口提供(4)-支持复杂数据类型方法
- ofbiz的webservice接口提供(4)-支持复杂数据类型方法
- ofbiz的webservice接口提供(4)-支持复杂数据类型方法
- 转 ofbiz的webservice接口提供(4)-支持复杂数据类型方法
- ofbiz的webservice接口提供(4)-支持复杂数据类型方法
- ofbiz的webservice接口提供(4)-支持复杂数据类型方法
- ofbiz的webservice接口提供(4)-支持复杂数据类型方法
- 转 ofbiz的webservice接口提供(1)-WSDL的生成
- webservice实际应用之调用外部系统提供的服务端地址,写java的webservice客户端程序并通过接口给外部系统传数据
- ofbiz的webservice接口提供(1)-WSDL的生成