Add new attachment

Only authorized users are allowed to upload new attachments.

This page (revision-6) was last changed on 28-Oct-2007 19:56 by DongGukLee  

This page was created on 28-Oct-2007 14:19 by DongGukLee

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Difference between version and

At line 39 changed one line
이 파일은 EndPoints, WebServiceMessageReceivers 를 정의한다.
이 파일은 EndPoints, WebServiceMessageReceivers 를 정의한다. 여기서 파일명은 openframework-ws-servlet.xml 이라고 가정한다.
At line 44 changed 2 lines
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
At line 52 added 99 lines
!! Endpoint 구현하기
XML 메시지를 다루기 위해 Endpoint를 구현해야 한다. 여기서 XML을 다루기 위해 사용할수 있는 방식은 JDOM, DOM, dom4j, XOM, SAX, 그리고 StAX 가 있다.
[{Java2HtmlPlugin
package openframework.ws;
import java.text.SimpleDateFormat;
import java.util.Date;
import openframework.service.HumanResourceService;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.Namespace;
import org.jdom.xpath.XPath;
import org.springframework.ws.server.endpoint.AbstractJDomPayloadEndpoint;
public class HolidayEndpoint extends AbstractJDomPayloadEndpoint {
private XPath startDateExpression;
private XPath endDateExpression;
private XPath nameExpression;
private HumanResourceService humanResourceService;
public HolidayEndpoint(HumanResourceService humanResourceService) throws JDOMException {
this.humanResourceService = humanResourceService;
Namespace namespace = Namespace.getNamespace("hr", "http://openframework.or.kr/hr/schemas");
startDateExpression = XPath.newInstance("//hr:StartDate");
startDateExpression.addNamespace(namespace);
endDateExpression = XPath.newInstance("//hr:EndDate");
endDateExpression.addNamespace(namespace);
nameExpression = XPath.newInstance("concat(//hr:FirstName,' ',//hr:LastName)");
nameExpression.addNamespace(namespace);
}
protected Element invokeInternal(Element holidayRequest) throws Exception {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date startDate = dateFormat.parse(startDateExpression.valueOf(holidayRequest));
Date endDate = dateFormat.parse(endDateExpression.valueOf(holidayRequest));
String name = nameExpression.valueOf(holidayRequest);
humanResourceService.bookHoliday(startDate, endDate, name);
return null;
}
}
}]
openframework-ws-servlet.xml 파일에 다음 설정을 추가한다.
[{Java2HtmlPlugin
<beans xmlns="http://www.springframework.org/schema/beans">
<bean id="holidayEndpoint" class="openframework.ws.HolidayEndpoint">
<constructor-arg ref="hrService"/>
</bean>
<bean id="hrService" class="openframework.service.StubHumanResourceService"/>
</beans>
}]
!! 메시지를 Endpoint로 보내기
[{Java2HtmlPlugin
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
<property name="mappings">
<props>
<prop key="{http://openframework.or.kr/hr/schemas}HolidayRequest">holidayEndpoint</prop>
</props>
</property>
<property name="interceptors">
<bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
</property>
</bean>
}]
!! WSDL 배포하기
[{Java2HtmlPlugin
<bean id="holiday" class="org.springframework.ws.wsdl.wsdl11.DynamicWsdl11Definition">
<property name="builder">
<bean class="org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder">
<property name="schema" value="/WEB-INF/xsd/hr.xsd"/>
<property name="portTypeName" value="HumanResource"/>
<property name="locationUri" value="http://localhost:8888/holidayService/"/>
<property name="targetNamespace" value="http://openframework.or.kr/hr/definitions"/>
</bean>
</property>
</bean>
}]
여기서 bean의 id값인 holiday는 wsdl을 가져올때 사용되는 값이다. 간단하게는 http://[[서버주소]/[[context명]/[[bean의 id].wsdl 이라는 URL을 사용하면 WSDL을 가져올수 있다. 위와 같은 경우 다음과 같은 URL을 가지게 된다.
[http://localhost:8888/spring-ws/holiday.wsdl]
Version Date Modified Size Author Changes ... Change note
6 28-Oct-2007 19:56 4.93 kB DongGukLee to previous
5 28-Oct-2007 19:26 12.412 kB DongGukLee to previous | to last
4 28-Oct-2007 16:53 8.382 kB DongGukLee to previous | to last
3 28-Oct-2007 14:47 4.922 kB DongGukLee to previous | to last
2 28-Oct-2007 14:46 4.922 kB DongGukLee to previous | to last
1 28-Oct-2007 14:19 1.444 kB DongGukLee to last
« This page (revision-6) was last changed on 28-Oct-2007 19:56 by DongGukLee