WebService--jax-spring集儿子成

2020-03-09 博彩公司官网 阅读

  假设运用javax.jws情节编写webservice,则不得不经度过将以次打成jar包的方法运转,假设要想经度过web容器终止颁布匹,则需寻求运用其他webservice框架。下面伸见jaxws与spring集儿子成配备经过。

  1,带入jar包,jaxws相干,spring相干:在我的测试以次中运用到的相干jar包如次,根据己己己的需寻求对spring的jar终止增减。

  

  

  2,创立webservice接口(白色片断为己定义情节,根据还愿情景更改):

  import javax.jws.WebMethod;

  import javax.jws.WebParam;

  import javax.jws.WebService;

  import javax.jws.soap.SOAPBinding;

  @WebService(name="CopSecWebService", targetNamespace="http://ws.copsec.com/")

  @SOAPBinding(style=SOAPBinding.Style.RPC)

  public interface CopsecWsServiceItf {

  @WebMethod

  public String getUser(

  @WebParam(name="userid", partName="userid")

  String userid);

  }

  3,完成webservice接口(该文件运用spring注松配备):

  import javax.jws.WebService;

  import org.springframework.stereotype.Component;

  @WebService(endpointInterface="com.copsec.ws.CopsecWsServiceItf",

  serviceName="CopSecWebService",

  portName="CopSecWebServicePort",

  targetNamespace="http://ws.copsec.com/")

  //该对象提交由spring办

  @Component("copsecWsServiceImpl")

  public class CopsecWsServiceImpl implements CopsecWsServiceItf{

  public String getUser(String id) {

  return "say hi "+id;

  }

  }

  4,编纂application.xml文件

  1)在标注签傍边添加以对应的运用,对应的schema运用。我的项目中的配备如次:

  

  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ws="http://jax-ws.dev.java.net/spring/core"

  xmlns:wss="http://jax-ws.dev.java.net/spring/servlet" xmlns:p="http://www.springframework.org/schema/p"

  xmlns:context="http://www.springframework.org/schema/context"

  xsi:schemaLocation="http://www.springframework.org/schema/beans

  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd

  http://jax-ws.dev.java.net/spring/core

  http://jax-ws.dev.java.net/spring/core.xsd

标签: