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 137 changed one line
<property name="schema" value="/WEB-INF/hr.xsd"/>
<property name="schema" value="/WEB-INF/xsd/hr.xsd"/>
At line 256 added 4 lines
!! MessageDispatcher
Spring-WS의 서버측은 XML메시지를 endpoint로 전달하는 클래스로 디자인되었다.
다음은 Spring WS에서의 request를 처리 절차이다.
At line 261 added 140 lines
!! MessageDispatcherServlet
기본적으로 web.xml 파일에 정의할때 사용된다.
!! WSDL 노출
[{Java2HtmlPlugin
<bean id="orders" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
<constructor-arg value="/WEB-INF/wsdl/Orders.wsdl"/>
</bean>
}]
[{Java2HtmlPlugin
http://localhost:8080/spring-ws/orders.wsdl
}]
!! XSD에서 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/Orders.xsd"/>
<property name="portTypeName" value="Orders"/>
<property name="locationUri" value="http://localhost:8080/ordersService/"/>
</bean>
</property>
</bean>
}]
DynamicWsdl11Definition 는 WSDL을 생성하기 위해 Wsdl11DefinitionBuilder 를 사용한다. 위 예제에서는 XsdBasedSoap11Wsdl4jDefinitionBuilder를 사용했다. 동적으로 WSDL을 생성하기 위해서는 xsd에 request나 response로 끝나는 element가 있어야 한다. 이를테면 다음의 예를 보자.
[{Java2HtmlPlugin
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="qualified"
targetNamespace="http://openframework.or.kr/hr/schemas" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:hr="http://openframework.or.kr/hr/schemas">
<xs:element name="HolidayRequest">
<xs:complexType>
<xs:all>
<xs:element name="Holiday" type="hr:HolidayType"/>
<xs:element name="Employee" type="hr:EmployeeType"/>
</xs:all>
</xs:complexType>
</xs:element>
....
</xs:schema>
}]
위 소스의 경우 HolidayRequest라는 element가 있다. 이런 경우 자동으로 생성되는 WSDL에는 HolidayRequest 요소와 함께 Holiday라는 operation이 생성된다.
[{Java2HtmlPlugin
<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:schema="http://openframework.or.kr/hr/schemas" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://openframework.or.kr/hr/definitions" targetNamespace="http://openframework.or.kr/hr/definitions">
<wsdl:types>
....
</wsdl:types>
<wsdl:message name="HolidayRequest">
....
</wsdl:message>
<wsdl:portType name="HumanResource">
<wsdl:operation name="Holiday">
<wsdl:input message="tns:HolidayRequest" name="HolidayRequest">
</wsdl:input>
</wsdl:operation>
</wsdl:portType>
....
</wsdl:binding>
</wsdl:definitions>
}]
!! DispatcherServlet에 Spring-WS 묶기
!! Endpoints
[{Java2HtmlPlugin
public interface PayloadEndpoint {
/**
* Invokes an operation.
*/
Source invoke(Source request) throws Exception;
}
}]
Endpoint는 Spring-WS의 서버측 지원에 대한 핵심이다.
!! AbstractDomPayloadEndpoint
[{Java2HtmlPlugin
package samples;
public class SampleEndpoint extends AbstractDomPayloadEndpoint {
private String responseText;
public SampleEndpoint(String responseText) {
this.responseText = responseText;
}
protected Element invokeInternal(
Element requestElement,
Document document) throws Exception {
String requestText = requestElement.getTextContent();
System.out.println("Request text: " + requestText);
Element responseElement = document.createElementNS("http://samples", "response");
responseElement.setTextContent(responseText);
return responseElement;
}
}
}]
[{Java2HtmlPlugin
<bean id="sampleEndpoint" class="samples.SampleEndpoint">
<constructor-arg value="Hello World!"/>
</bean>
}]
위 소스를 사용했을때 응답 메시지는 다음과 같다.
[{Java2HtmlPlugin
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<request xmlns="http://samples">
Hello
</request>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
}]
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