2015년 10월 15일 목요일

Web Service - CXF, Srping

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

@XmlType(name = "SomeInfo", namespace = "http://reverse.package.path.as.domain/")
@XmlAccessorType(XmlAccessType.FIELD)
public class SomeInfo{
private String SOME_ID;

public String getSOME_ID() {
return SOME_ID;
}
public void setPJT_NO(String _SOME_ID) {
SOME_ID = _SOME_ID;
}
}



import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlElement;
@WebService
public interface Some{
@WebMethod(operationName = "operSomthing")
@WebResult(name = "result")
public RETURN sendSomeInfos(@WebParam(name = "someInfos") @XmlElement(required = true, nillable = false) SomeInfo[] someInfos);
}


import javax.jws.WebService;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

@WebService(serviceName = "Some", endpointInterface = "package.path.Some")
@Service("package.path.SomeService")
public class SomeService implements Some {
....
}




<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
        http://cxf.apache.org/core http://cxf.apache.org/schemas/core.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-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<cxf:bus> <cxf:features> <cxf:logging /> </cxf:features> </cxf:bus>
<!--
<bean id="inInterceptor" class="com.secc.cmm.wsLogging.interceptor.InInterceptor">
<property name="onlyFaultLogging" value="true"/>
</bean>
<bean id="outInterceptor" class="com.secc.cmm.wsLogging.interceptor.OutInterceptor">
<property name="onlyFaultLogging" value="true"/>
</bean>
<cxf:bus>
<cxf:inInterceptors><ref bean="inInterceptor" /></cxf:inInterceptors>
<cxf:outInterceptors><ref bean="outInterceptor" /></cxf:outInterceptors>
<cxf:inFaultInterceptors><ref bean="inInterceptor" /></cxf:inFaultInterceptors>
<cxf:outFaultInterceptors><ref bean="outInterceptor" /></cxf:outFaultInterceptors>
</cxf:bus>
-->


<jaxws:endpoint implementor="#package.path.SomeService" address="/Some" />



</beans>