Spring WS - WSDL Statis
Di bab sebelumnya Spring -WS - Aplikasi Pertama , kita telah menghasilkan WSDL secara otomatis menggunakan Konfigurasi Spring WS. Dalam kasus ini, kami akan menampilkan cara mengekspos WSDL yang ada menggunakan Spring WS.
Langkah | Deskripsi |
---|---|
1 | Buat proyek dengan nama leaveService di bawah paket com.tutorialspoint seperti yang dijelaskan di Spring WS - bab Aplikasi Pertama. |
2 | Buat meninggalkan.wsdl WSDL di bawah sub-folder / WEB-INF / wsdl. |
3 | Perbarui spring-ws-servlet.xml di bawah sub-folder / WEB-INF. Kami menggunakan tag static-wsdl di sini daripada dynamic-wsdl. |
4 | Langkah terakhir adalah membuat konten dari semua file sumber dan konfigurasi dan mengekspor aplikasi seperti yang dijelaskan di bawah ini. |
/WEB-INF/spring-ws-servlet.xml
<wsdl:definitions xmlns:wsdl = "http://schemas.xmlsoap.org/wsdl/"
xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:schema = "http://tutorialspoint.com/hr/schemas"
xmlns:tns = "http://tutorialspoint.com/hr/definitions"
targetNamespace = "http://tutorialspoint.com/hr/definitions">
<wsdl:types>
<xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema">
<xsd:import namespace = "http://tutorialspoint.com/hr/schemas"
schemaLocation = "hr.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name = "LeaveRequest">
<wsdl:part element = "schema:LeaveRequest" name = "LeaveRequest"/>
</wsdl:message>
<wsdl:portType name = "HumanResource">
<wsdl:operation name = "Leave">
<wsdl:input message = "tns:LeaveRequest" name = "LeaveRequest"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name = "HumanResourceBinding" type = "tns:HumanResource">
<soap:binding style = "document"
transport = "http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name = "Leave">
<soap:operation soapAction = "http://mycompany.com/RequestLeave"/>
<wsdl:input name = "LeaveRequest">
<soap:body use = "literal"/>
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name = "HumanResourceService">
<wsdl:port binding = "tns:HumanResourceBinding" name = "HumanResourcePort">
<soap:address location = "http://localhost:8080/leaveService/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
/WEB-INF/spring-ws-servlet.xml
<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:sws = "http://www.springframework.org/schema/web-services"
xsi:schemaLocation = "http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/web-services
http://www.springframework.org/schema/web-services/web-services-2.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package = "com.tutorialspoint.hr"/>
<sws:annotation-driven/>
<sws:static-wsdl id = "leave" location = "/WEB-INF/wsdl/leave.wsdl"/>
</beans>
Jalankan Proyek
Setelah kita selesai membuat file sumber dan konfigurasi, kita harus mengekspor aplikasi. Klik kanan pada aplikasi, gunakan opsi Export → WAR File dan simpan file leaveService.war Anda di folder webapps Tomcat.
Sekarang, jalankan server Tomcat dan pastikan kita dapat mengakses halaman web lain dari folder webapps menggunakan browser standar. Coba akses URL - http: // localhost: 8080 / leaveService / leave.wsdl, jika semuanya baik-baik saja dengan Spring Web Application, kita akan melihat layar berikut.