【노트】WebService CXF와 SSM 통합, 실명 인증 시뮬레이션
9139 단어 WebService
1. 인터페이스 개발
【web.xml】
<servlet>
<servlet-name>CXFServletservlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServletservlet-class>
servlet>
<servlet-mapping>
<servlet-name>CXFServletservlet-name>
<url-pattern>/webservice/*url-pattern>
servlet-mapping>
【spring-webservice.xml】
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<context:component-scan base-package="com.jul_11th.*" />
<jaxws:endpoint implementor="#myWebServiceImpl" address="/MyWebService"/>
beans>
【서비스 인터페이스】
package com.jul_11th.webservice;
import javax.jws.WebService;
@WebService
public interface MyWebService {
/**
*
*/
boolean Authentication(String realName,String id);
}
[서비스 인터페이스 구현 클래스]
package com.jul_11th.webservice;
import javax.annotation.Resource;
import javax.jws.WebService;
import org.springframework.stereotype.Component;
import com.jul_11th.service.IUserService;
@Component("myWebServiceImpl")
@WebService
public class MyWebServiceImpl implements MyWebService {
@Resource(name = "userService")
private IUserService userService;
public boolean Authentication(String realName, String id) {
return userService.Authentication(realName, id);
}
}
2. 서비스 요청, 크로스 플랫폼 인터페이스 호출
【Client】
package com.jul_11th.client;
//import org.apache.cxf.frontend.ClientProxy;
import com.jul_11th.webservice.MyWebService;
import com.jul_11th.webservice.MyWebServiceImplService;
public class Client {
public static void main(String[] args) {
MyWebServiceImplService service = new MyWebServiceImplService();
MyWebService hw = service.getMyWebServiceImplPort();
//org.apache.cxf.endpoint.Client client=ClientProxy.getClient(hw);
//client.getOutInterceptors().add(new AddHeaderInterceptor("admin","admin"));
System.out.println(hw.authentication(" ", "410423199400000000"));
}
}
【콘솔 출력】
07, 2017 10:18:24 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
: Creating Service {http://webservice.jul_11th.com/}MyWebServiceImplService from WSDL: http://localhost:8080/SSM/webservice/MyWebService?wsdl
true
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
중학교 2학년 때 Rails로 웹 서비스를 해봤어요.Twittter↓↓ 이거 빠르다.이렇게 되면 나는 기본적으로 웹 서비스를 이해하고 웹 서비스를 제공할 수 있다. 내가 추천한 책은 이 책이다.초보자를 대상으로 간단하게 입문할 수 있다.그러나 이 정도로는 오리지널 웹...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.