我正在尝试评估 Spring Integration,特别是对通过服务激活器将基于 POJO 的简单服务公开到基于 SOAP 的 Web 服务感兴趣。目前我被困在生成动态 wsdl 时遇到问题。WSDL 未加载,浏览器显示 404 错误。我尝试在本地访问以下网址
http://localhost:8080/ws-inbound-gateway/echoService
http://localhost:8080/ws-inbound-gateway/echoService/echoService.wsdl
下面是配置
入站网关-config.xml
<int:channel id="inbound" />
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="com.manish.schema.generated" />
</bean>
<int-ws:inbound-gateway id="empServiceGateway"
request-channel="inbound" marshaller="marshaller"
unmarshaller="marshaller" />
<int:service-activator input-channel="inbound"
requires-reply="true" ref="employeeServiceActivator" method="getEmployeeDetails">
</int:service-activator>
<bean id="employeeServiceActivator"
class="org.springframework.integration.samples.ws.EmployeeServiceResponder" />
<bean id="employeeService" class="com.manish.service.EmployeeService" />
EmployeeService 只是一个 pojo 类,而 EmployeeServiceResponder 是一个服务激活器,它调用服务类上的方法。
用于动态 wsdl 生成
spring-ws-config.xml
<import resource="classpath:/META-INF/spring/integration/inbound-gateway-config.xml" />
<sws:dynamic-wsdl id="echoService" portTypeName="empServiceGateway" locationUri="/echoService" targetNamespace="http://manish.niyati.com/echo">
<sws:xsd location="/WEB-INF/echo.xsd"/>
</sws:dynamic-wsdl>
<bean
class="org.springframework.ws.server.endpoint.mapping.UriEndpointMapping">
<property name="defaultEndpoint" ref="empServiceGateway"></property>
</bean>
web.xml
<servlet>
<servlet-name>spring-ws</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/spring-ws-config.xml</param-value>
</init-param>
<init-param>
<param-name>transformWsdlLocations</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-ws</servlet-name>
<url-pattern>/echoService</url-pattern>
</servlet-mapping>
请让我知道还缺少什么,以便通过 SI 将此服务作为 Web 服务访问。
此外,当我尝试使用 WebService 模板访问服务时,我得到了 SOAPFAULT
02:18:59.436 INFO [main][org.springframework.ws.soap.saaj.SaajSoapMessageFactory] Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
02:18:59.437 DEBUG [main][org.springframework.ws.soap.saaj.SaajSoapMessageFactory] Using MessageFactory class [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl]
02:18:59.484 DEBUG [main][org.springframework.ws.client.core.WebServiceTemplate] Opening [org.springframework.ws.transport.http.HttpUrlConnection@249fa95c] to [http://localhost:8080/ws-inbound-gateway/echoService]
02:18:59.519 TRACE [main][org.springframework.ws.soap.saaj.support.SaajUtils] SOAPElement [com.sun.xml.internal.messaging.saaj.soap.ver1_1.Envelope1_1Impl] implements SAAJ 1.3
02:18:59.535 TRACE [main][org.springframework.ws.soap.saaj.support.SaajUtils] SOAPElement [com.sun.xml.internal.messaging.saaj.soap.ver1_1.Body1_1Impl] implements SAAJ 1.3
02:18:59.562 TRACE [main][org.springframework.ws.client.MessageTracing.sent] Sent request [<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><ed:employeeRequest xmlns:ed="http://manish.niyati.com/echo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ed:empid>100</ed:empid> </ed:employeeRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>]
02:18:59.604 TRACE [main][org.springframework.ws.client.MessageTracing.received] Received response [<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring xml:lang="en">**java.lang.NullPointerException**</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>] for request [<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><ed:employeeRequest xmlns:ed="http://manish.niyati.com/echo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ed:empid>100</ed:empid> </ed:employeeRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>]
02:18:59.605 DEBUG [main][org.springframework.ws.client.core.WebServiceTemplate] Received Fault message for request [SaajSoapMessage {http://manish.niyati.com/echo}employeeRequest]
02:18:59.607 TRACE [main][org.springframework.ws.soap.saaj.support.SaajUtils] SOAPElement [com.sun.xml.internal.messaging.saaj.soap.ver1_1.Fault1_1Impl] implements SAAJ 1.3
提前致谢-MS