ofbiz4 对于webservice的支持实在是不咋地,在官方的文档中,SOAP只是支持基础类型的数据的传入传出,这些基础的数据类型我们可以参照 org.ofbiz.service.ModelParam的java2wsdlType方法。大家可以看到这个方法的类只是支持简单的基础数据类型。如 下:
·········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,248)"> ??? } else if (ObjectType.instanceOf(java.lang.Byte.class,108); border-left-width:3px; list-style-type:decimal-leading-zero; list-style-position:outside!important"> ??????? return "byte";?
- ??? } else if (ObjectType.instanceOf(java.lang.Boolean.class,108); border-left-width:3px; list-style-type:decimal-leading-zero; list-style-position:outside!important"> ??????? return "boolean";?
- ??? } else if (ObjectType.instanceOf(java.lang.Integer.class,108); border-left-width:3px; list-style-type:decimal-leading-zero; list-style-position:outside!important"> ??????? return "int";?
- ??? } else if (ObjectType.instanceOf(java.lang.Double.class,108); border-left-width:3px; list-style-type:decimal-leading-zero; list-style-position:outside!important"> ??????? return "double";?
- ??? } else if (ObjectType.instanceOf(java.lang.Float.class,108); border-left-width:3px; list-style-type:decimal-leading-zero; list-style-position:outside!important"> ??????? return "float";?
- ??? } else if (ObjectType.instanceOf(java.lang.Short.class,108); border-left-width:3px; list-style-type:decimal-leading-zero; list-style-position:outside!important"> ??????? return "short";?
- ??? } else if (ObjectType.instanceOf(java.math.BigDecimal.class,108); border-left-width:3px; list-style-type:decimal-leading-zero; list-style-position:outside!important"> ??????? return "decimal";?
- ??? } else if (ObjectType.instanceOf(java.math.BigInteger.class,108); border-left-width:3px; list-style-type:decimal-leading-zero; list-style-position:outside!important"> ??????? return "integer";?
- ??? } else if (ObjectType.instanceOf(java.util.Calendar.class,108); border-left-width:3px; list-style-type:decimal-leading-zero; list-style-position:outside!important"> ??????? return "dateTime";?
- ??? } else if (ObjectType.instanceOf(java.util.Date.class,248)"> ??? } else if (ObjectType.instanceOf(java.lang.Long.class,108); border-left-width:3px; list-style-type:decimal-leading-zero; list-style-position:outside!important"> ??????? return "unsignedInt";?
- ??? } else if (ObjectType.instanceOf(java.sql.Timestamp.class,248)"> ??? }?
- ?
- ??? ?
- ??? 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支持的基础数据类型又不支持这个基础类型,那么这个时候我们可能不得不更改这个文件来支持我们的这个数据类型了。
? 更改方法很简单就是加上如下的代码,并重新编辑整个项目:
} else if (ObjectType.instanceOf(java.sql.Date.class,this.type)) {?
- ??? return "dateTime";?
- } else if (ObjectType.instanceOf(java.sql.Time.class,248)"> ??? return "string";?
- }?
由此可见我们ofbiz的soap支持的webservice的参数类型真是不完善。更加不会支持那些序列化的复杂数据类型了。ofbiz4 对于webservice的支持实在是不咋地,在官方的文档中,108); border-left-width:3px; list-style-type:decimal-leading-zero; list-style-position:outside!important"> }?
由此可见我们ofbiz的soap支持的webservice的参数类型真是不完善。更加不会支持那些序列化的复杂数据类型了。
ofbiz4 对于webservice的支持实在是不咋地,在官方的文档中,108); border-left-width:3px; list-style-type:decimal-leading-zero; list-style-position:outside!important"> }?
由此可见我们ofbiz的soap支持的webservice的参数类型真是不完善。更加不会支持那些序列化的复杂数据类型了。
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|