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
}
}

猜你喜欢

转载自youjinglili2008.iteye.com/blog/1704597
今日推荐