ofbiz的service:这个是ofbiz赖以骄傲的设计方式。她可以将所有内部实体对象的CRUD都使用service的方式提供,不同系统之间可以通过互相调用service来完成业务操作。这种松耦合的方式是很多框架梦寐以求的效果。 @H_502_5@
在ofbiz4的文档中提到,如果想将ofbiz的某个服务开放成webservice只是需要轻轻的将我们定义service文件中的service属性中的export设定为true。@H_502_5@
例如:我的一个ofbiz项目的servicedef目录下的services.xml文件中定义了一个服务@H_502_5@
@H_502_5@
- <service
- name="findSeniorService"
- engine="java"
- location="com.hc360.cem.ws.CEMSeniorMemberService"
- invoke="findSeniorService"
- export="true"
- validate="false"
- auth="false">
- <description>CRM call CEM findSeniorService soap</description>
- <attribute name="userid" type="String" mode="INOUT" optional="true"/>
- <attribute name="salt" type="String" mode="IN" optional="true"/>
- <attribute name="aaa" type="String" mode="OUT" optional="true"/>
- <attribute name="bbb" type="String" mode="OUT" optional="true"/>
- <attribute name="ccc" type="String" mode="OUT" optional="true"/>
- </service>
上边图片的意思就是将:com.hc360.cem.ws.CEMSeniorMemberService类中的findSeniorService作为soap接口提供出去。输入参数有userid、salt,输出参数有userid、aaa、bbb、ccc。@H_502_5@
而我实际类如下:@H_502_5@
@H_502_5@
- import java.util.Map;
- import javolution.util.FastMap;
- import org.ofbiz.base.util.Debug;
- import org.ofbiz.service.dispatchContext;
- public class CEMSeniorMemberService {
- /**
- * 开放一个service供测试使用
- * wsdl的访问方式:http://yourip:port/project/control/SOAPService/findSeniorService?wsdl
- * 但是ofbiz给我们生成的wsdl使用任何的客户端生成工具都无法正确生成,但是这个webservice接口是可以使用的
- * @author kongqz
- * @date 2009-03-11
- *
- * */
- public static Map<String,Object> findSeniorService(dispatchContext ctx,Map<String,? extends Object> context) {
- //存放结果的map
- Map<String,Object> result = FastMap.newInstance();
- // GenericDelegator delegator = ctx.getDelegator();
- String userid = (String) context.get("userid");
- String salt = (String) context.get("salt");
- Debug.logInfo("salt is ["+salt+"],userid is ["+userid+"] ","findSeniorService");
- result.put("aaa","test_aaaaa");
- result.put("bbb","test_bbbbb");
- result.put("ccc","test_ccccc");
- result.put("userid",userid);
- return result;
- }
- }