xfire ,spring 集合webservice开发

applicationContext-webservice.xml

<import resource="classpath:org/codehaus/xfire/spring/xfire.xml" />
<!-- 使用XFire导出器 -->
<bean id="baseXFireExporter" class="org.codehaus.xfire.spring.remoting.XFireExporter"
lazy-init="false" abstract="true">
<property name="serviceFactory" ref="xfire.serviceFactory" />
<property name="xfire" ref="xfire" />
</bean>
<!-- webservice服务 为主要提供crm系统间以及sns等交互 -->
<bean id="crmServerService" parent="baseXFireExporter">
<!-- 服务名称 -->
<property name="name" value="crmService" />
<!-- 服务的实现类 -->
<property name="serviceBean" ref="crmServer"/>
<!-- 服务的接口类 -->
<property name="serviceClass" value="com.qqw.crm.webservice.crmservice.CrmServer" />
</bean>
解释:crmService是属于URL地址的一部分。serviceBean是属于需要发布为web服务的实现类。serviceClass是个接口
web.xml

<servlet>
<servlet-name>XFireServlet</servlet-name>
<servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>

<filter>
<filter-name>struts2</filter-name>
<filterclass>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!-- 应用程序上下文参数,指定spring配置文件位置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:org/codehaus/xfire/spring/xfire.xml,
classpath:applicationContext.xml
</param-value>
</context-param>


private static final String URL="http://localhost:8080/Apollocrm/services/crmService?wsdl";

public static void main(String[] args) {
try {
// JSONObject obj=new JSONObject();
// T02080500CRM0001ReqVO vo=new T02080500CRM0001ReqVO();
// vo.setOp_id("8");
// vo.setOp_name("16:5修改");
// vo.setOp_type("1");
// obj=JSONObject.fromObject(vo);
String str="{\"orderCode\":\"GS201200000000015446\",\"orderReason\":\"\",\"orderStatus\":\"5\",\"ordertype\":\"1\"}";
//logger.info("backDloancheckToSNSsend msg:"+str);
Client client = new Client(new URL(URL));
Object[] objs=client.invoke( "UpdateOrderStatusToCRM" , new Object[] {str});
System.out.println(String.valueOf(objs[0]));
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值