ofbiz的webservice接口提供(2)-数据类型的局限性

ofbiz4 对于webservice的支持实在是不咋地,在官方的文档中,SOAP只是支持基础类型的数据的传入传出,这些基础的数据类型我们可以参照 org.ofbiz.service.ModelParam的java2wsdlType方法。大家可以看到这个方法的类只是支持简单的基础数据类型。如 下:

 

  1. protected String java2wsdlType() throws WSDLException {  
  2.     if (ObjectType.instanceOf(java.lang.Character.classthis.type)) {  
  3.         return "string";  
  4.     } else if (ObjectType.instanceOf(java.lang.String.classthis.type)) {  
  5.         return "string";  
  6.     } else if (ObjectType.instanceOf(java.lang.Byte.classthis.type)) {  
  7.         return "byte";  
  8.     } else if (ObjectType.instanceOf(java.lang.Boolean.classthis.type)) {  
  9.         return "boolean";  
  10.     } else if (ObjectType.instanceOf(java.lang.Integer.classthis.type)) {  
  11.         return "int";  
  12.     } else if (ObjectType.instanceOf(java.lang.Double.classthis.type)) {  
  13.         return "double";  
  14.     } else if (ObjectType.instanceOf(java.lang.Float.classthis.type)) {  
  15.         return "float";  
  16.     } else if (ObjectType.instanceOf(java.lang.Short.classthis.type)) {  
  17.         return "short";  
  18.     } else if (ObjectType.instanceOf(java.math.BigDecimal.classthis.type)) {  
  19.         return "decimal";  
  20.     } else if (ObjectType.instanceOf(java.math.BigInteger.classthis.type)) {  
  21.         return "integer";  
  22.     } else if (ObjectType.instanceOf(java.util.Calendar.classthis.type)) {  
  23.         return "dateTime";  
  24.     } else if (ObjectType.instanceOf(java.util.Date.classthis.type)) {  
  25.         return "dateTime";  
  26.     } else if (ObjectType.instanceOf(java.lang.Long.classthis.type)) {  
  27.         return "unsignedInt";  
  28.     } else if (ObjectType.instanceOf(java.sql.Timestamp.classthis.type)) {  
  29.         return "string";  
  30.     }  
  31.   
  32.     // TODO add array support (maybe even convert List objects); add GenericValue/Map support  
  33.     throw new WSDLException(WSDLException.OTHER_ERROR, "Service cannot be described with WSDL (" + this.name + " / " + this.type + ")");  
  34. }  

 

这个方法就是帮助我们生成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支持的基础数据类型又不支持这个基础类型,那么这个时候我们可能不得不更改这个文件来支持我们的这个数据类型了。

  更改方法很简单就是加上如下的代码,并重新编辑整个项目:

 

  1. else if (ObjectType.instanceOf(java.sql.Date.classthis.type)) {  
  2.     return "dateTime";  
  3. else if (ObjectType.instanceOf(java.sql.Time.classthis.type)) {  
  4.     return "string";  
  5. }  

 

由此可见我们ofbiz的soap支持的webservice的参数类型真是不完善。更加不会支持那些序列化的复杂数据类型了。ofbiz4 对于webservice的支持实在是不咋地,在官方的文档中,SOAP只是支持基础类型的数据的传入传出,这些基础的数据类型我们可以参照 org.ofbiz.service.ModelParam的java2wsdlType方法。大家可以看到这个方法的类只是支持简单的基础数据类型。如 下:

 

  1. protected String java2wsdlType() throws WSDLException {  
  2.     if (ObjectType.instanceOf(java.lang.Character.classthis.type)) {  
  3.         return "string";  
  4.     } else if (ObjectType.instanceOf(java.lang.String.classthis.type)) {  
  5.         return "string";  
  6.     } else if (ObjectType.instanceOf(java.lang.Byte.classthis.type)) {  
  7.         return "byte";  
  8.     } else if (ObjectType.instanceOf(java.lang.Boolean.classthis.type)) {  
  9.         return "boolean";  
  10.     } else if (ObjectType.instanceOf(java.lang.Integer.classthis.type)) {  
  11.         return "int";  
  12.     } else if (ObjectType.instanceOf(java.lang.Double.classthis.type)) {  
  13.         return "double";  
  14.     } else if (ObjectType.instanceOf(java.lang.Float.classthis.type)) {  
  15.         return "float";  
  16.     } else if (ObjectType.instanceOf(java.lang.Short.classthis.type)) {  
  17.         return "short";  
  18.     } else if (ObjectType.instanceOf(java.math.BigDecimal.classthis.type)) {  
  19.         return "decimal";  
  20.     } else if (ObjectType.instanceOf(java.math.BigInteger.classthis.type)) {  
  21.         return "integer";  
  22.     } else if (ObjectType.instanceOf(java.util.Calendar.classthis.type)) {  
  23.         return "dateTime";  
  24.     } else if (ObjectType.instanceOf(java.util.Date.classthis.type)) {  
  25.         return "dateTime";  
  26.     } else if (ObjectType.instanceOf(java.lang.Long.classthis.type)) {  
  27.         return "unsignedInt";  
  28.     } else if (ObjectType.instanceOf(java.sql.Timestamp.classthis.type)) {  
  29.         return "string";  
  30.     }  
  31.   
  32.     // TODO add array support (maybe even convert List objects); add GenericValue/Map support  
  33.     throw new WSDLException(WSDLException.OTHER_ERROR, "Service cannot be described with WSDL (" + this.name + " / " + this.type + ")");  
  34. }  

 

这个方法就是帮助我们生成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支持的基础数据类型又不支持这个基础类型,那么这个时候我们可能不得不更改这个文件来支持我们的这个数据类型了。

  更改方法很简单就是加上如下的代码,并重新编辑整个项目:

 

  1. else if (ObjectType.instanceOf(java.sql.Date.classthis.type)) {  
  2.     return "dateTime";  
  3. else if (ObjectType.instanceOf(java.sql.Time.classthis.type)) {  
  4.     return "string";  
  5. }  

 

由此可见我们ofbiz的soap支持的webservice的参数类型真是不完善。更加不会支持那些序列化的复杂数据类型了。

ofbiz4 对于webservice的支持实在是不咋地,在官方的文档中,SOAP只是支持基础类型的数据的传入传出,这些基础的数据类型我们可以参照 org.ofbiz.service.ModelParam的java2wsdlType方法。大家可以看到这个方法的类只是支持简单的基础数据类型。如 下:

 

  1. protected String java2wsdlType() throws WSDLException {  
  2.     if (ObjectType.instanceOf(java.lang.Character.classthis.type)) {  
  3.         return "string";  
  4.     } else if (ObjectType.instanceOf(java.lang.String.classthis.type)) {  
  5.         return "string";  
  6.     } else if (ObjectType.instanceOf(java.lang.Byte.classthis.type)) {  
  7.         return "byte";  
  8.     } else if (ObjectType.instanceOf(java.lang.Boolean.classthis.type)) {  
  9.         return "boolean";  
  10.     } else if (ObjectType.instanceOf(java.lang.Integer.classthis.type)) {  
  11.         return "int";  
  12.     } else if (ObjectType.instanceOf(java.lang.Double.classthis.type)) {  
  13.         return "double";  
  14.     } else if (ObjectType.instanceOf(java.lang.Float.classthis.type)) {  
  15.         return "float";  
  16.     } else if (ObjectType.instanceOf(java.lang.Short.classthis.type)) {  
  17.         return "short";  
  18.     } else if (ObjectType.instanceOf(java.math.BigDecimal.classthis.type)) {  
  19.         return "decimal";  
  20.     } else if (ObjectType.instanceOf(java.math.BigInteger.classthis.type)) {  
  21.         return "integer";  
  22.     } else if (ObjectType.instanceOf(java.util.Calendar.classthis.type)) {  
  23.         return "dateTime";  
  24.     } else if (ObjectType.instanceOf(java.util.Date.classthis.type)) {  
  25.         return "dateTime";  
  26.     } else if (ObjectType.instanceOf(java.lang.Long.classthis.type)) {  
  27.         return "unsignedInt";  
  28.     } else if (ObjectType.instanceOf(java.sql.Timestamp.classthis.type)) {  
  29.         return "string";  
  30.     }  
  31.   
  32.     // TODO add array support (maybe even convert List objects); add GenericValue/Map support  
  33.     throw new WSDLException(WSDLException.OTHER_ERROR, "Service cannot be described with WSDL (" + this.name + " / " + this.type + ")");  
  34. }  

 

这个方法就是帮助我们生成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支持的基础数据类型又不支持这个基础类型,那么这个时候我们可能不得不更改这个文件来支持我们的这个数据类型了。

  更改方法很简单就是加上如下的代码,并重新编辑整个项目:

 

  1. else if (ObjectType.instanceOf(java.sql.Date.classthis.type)) {  
  2.     return "dateTime";  
  3. else if (ObjectType.instanceOf(java.sql.Time.classthis.type)) {  
  4.     return "string";  
  5. }  

 

由此可见我们ofbiz的soap支持的webservice的参数类型真是不完善。更加不会支持那些序列化的复杂数据类型了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值