SpringWS服务不通过SOAP UI响应请求吗?
同意,我是春天的初学者,我需要帮助。我创建了Web服务并且可以在SOAP UI中接收wsdl描述,但问题是服务不响应请求。 这是我的网站服务配置:
package com.mayacomp.app;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.ws.config.annotation.EnableWs;
import org.springframework.ws.config.annotation.WsConfigurerAdapter;
import org.springframework.ws.transport.http.MessageDispatcherServlet;
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
import org.springframework.xml.xsd.SimpleXsdSchema;
import org.springframework.xml.xsd.XsdSchema;
@EnableWs
@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean dispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
return new ServletRegistrationBean(servlet, "/services/*");
}
@Bean(name = "APPService")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema APPServiceSchema) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("ApplicationWS");
wsdl11Definition.setLocationUri("/APPService/");
wsdl11Definition.setTargetNamespace("http://mayaapp.com/application");
wsdl11Definition.setSchema(APPServiceSchema);
return wsdl11Definition;
}
@Bean
public XsdSchema APPServiceSchema() {
return new SimpleXsdSchema(new ClassPathResource("META-INF/schemas/application.xsd"));
}
}
我的端点类:
package com.mayacomp.endpoint;
import java.util.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
import com.mayacomp.app.InternalHistRequest;
import com.mayacomp.app.InternalHistResponse;
import com.mayacomp.app.InternalCreditHistFlagsType;
import com.mayacomp.app.InternalCreditHistIndicatorsType;
import com.mayacomp.app.ResponseHeaderType;
import com.mayacomp.service.APPService;
@Endpoint
public class WsEndpoint {
private static final Logger LOG = Logger.getLogger(WsEndpoint.class.getName());
private static final String TARGET_NAMESPACE = "http://mayaapp.com/application";
@Autowired
public APPService APPService_i;
@PayloadRoot(localPart = "InternalHistRequest", namespace = TARGET_NAMESPACE)
public @ResponsePayload InternalHistResponse getInternalCredHist(@RequestPayload InternalHistRequest request) {
LOG.info("Test");
InternalHistResponse _return = new InternalHistResponse();
_return.setClientID(new java.math.BigInteger("42823928316076042522945935239155481381"));
try
{
ResponseHeaderType _returnResponseHeader = new ResponseHeaderType();
_returnResponseHeader.setRequestUid("RequestUid-207722529");
_returnResponseHeader.setRequestTimestamp(javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar("2015-05-06T10:28:37.616+03:00"));
_returnResponseHeader.setResponseUid("ResponseUid2066314058");
_returnResponseHeader.setResponseTimestamp(javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar("2015-05-06T10:28:37.616+03:00"));
_returnResponseHeader.setResponseCode(1883325675);
_returnResponseHeader.setResponseDescription("ResponseDescription-1084371447");
_return.setResponseHeader(_returnResponseHeader);
/* call Spring injected service implementation to retrieve credit history data */
InternalCreditHistFlagsType _returnInternalCreditHistFlags = APPService_i.getInternalCreditHistFlagsType(request);
_return.setInternalCreditHistFlags(_returnInternalCreditHistFlags);
/* call Spring injected service implementation to retrieve credit history data */
InternalCreditHistIndicatorsType _returnInternalCreditHisIndicators = APPService_i.getInternalCredHist(request);
_return.setInternalCreditHisIndicators(_returnInternalCreditHisIndicators);
return _return;
}
catch (java.lang.Exception ex) {
ex.printStackTrace();
throw new RuntimeException(ex);
}
}
public void setAPPService(APPService APPService_p)
{
this.APPService_i = APPService_p;
}
}
我的pom文件(可能是依赖项)
http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.mayacomp.pco AppService服务
<version>0.0.1-SNAPSHOT</version>
<name>APPService Spring-WS Application</name>
<url>http://www.springframework.org/spring-ws</url>
<inceptionYear>2015</inceptionYear>
<packaging>jar</packaging>
<build>
<finalName>PCOService</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
<configuration>
<clearOutputDir>false</clearOutputDir>
<outputDirectory>src/main/java</outputDirectory>
<schemaDirectory>src/main/resources/META-INF/schemas</schemaDirectory>
<includeSchema>**/*.xsd</includeSchema>
<bindingDirectory>src/main/java/com/mayacomp/app</bindingDirectory>
<enableIntrospection>false</enableIntrospection>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.3</version>
</dependency>
<!-- Spring dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.7.RELEASE</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>1.2.5.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
<version>1.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
<version>1.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-ws</artifactId>
<version>1.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-ws</artifactId>
<version>1.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
</dependencies>
正如我所说,我在
之后可以使用wsdlmvn -U spring-boot:run
通过网址 http://localhost:8080/services/APPService/APPService.wsdl但操作无效。请帮忙。
更新 Spring启动日志跟踪:
DEBUG: [авг-03 13:08:33,082] boot.logging.ClasspathLoggingApplicationListener - Application started with classpath: [file:/C:/Users/Maya/workspace/APPService/src/main/resources/, file:/C:/Users/Maya/workspace/APPService/target/classes/, file:/C:/Users/Maya/.m2/repository/com/fasterxml/classmate/1.0.0/classmate-1.0.0.jar, file:/C:/Users/Maya/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/boot/spring-boot-starter/1.2.5.RELEASE/spring-boot-starter-1.2.5.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/yaml/snakeyaml/1.14/snakeyaml-1.14.jar, file:/C:/Users/Maya/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/spring-beans/4.1.7.RELEASE/spring-beans-4.1.7.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/slf4j/slf4j-api/1.7.12/slf4j-api-1.7.12.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/spring-jms/4.1.7.RELEASE/spring-jms-4.1.7.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/ws/spring-ws-support/2.2.1.RELEASE/spring-ws-support-2.2.1.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.4.0/jackson-annotations-2.4.0.jar, file:/C:/Users/Maya/.m2/repository/org/slf4j/jul-to-slf4j/1.7.12/jul-to-slf4j-1.7.12.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.2.5.RELEASE/spring-boot-starter-web-1.2.5.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.12/jcl-over-slf4j-1.7.12.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/ws/spring-xml/2.2.1.RELEASE/spring-xml-2.2.1.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/spring-aop/4.0.9.RELEASE/spring-aop-4.0.9.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.4.6/jackson-databind-2.4.6.jar, file:/C:/Users/Maya/.m2/repository/org/jboss/logging/jboss-logging/3.1.3.GA/jboss-logging-3.1.3.GA.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/boot/spring-boot-starter-log4j/1.2.5.RELEASE/spring-boot-starter-log4j-1.2.5.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/wsdl4j/wsdl4j/1.6.3/wsdl4j-1.6.3.jar, file:/C:/Users/Maya/.m2/repository/org/hibernate/hibernate-validator/5.1.3.Final/hibernate-validator-5.1.3.Final.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/spring-context/4.1.7.RELEASE/spring-context-4.1.7.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/ws/spring-ws-core/2.2.1.RELEASE/spring-ws-core-2.2.1.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/spring-webmvc/4.0.9.RELEASE/spring-webmvc-4.0.9.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.2.5.RELEASE/spring-boot-autoconfigure-1.2.5.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.0.23/tomcat-embed-websocket-8.0.23.jar, file:/C:/Users/Maya/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.0.23/tomcat-embed-el-8.0.23.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.2.5.RELEASE/spring-boot-starter-tomcat-1.2.5.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/spring-web/4.1.7.RELEASE/spring-web-4.1.7.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/apache/tomcat/embed/tomcat-embed-logging-juli/8.0.23/tomcat-embed-logging-juli-8.0.23.jar, file:/C:/Users/Maya/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/spring-messaging/4.1.7.RELEASE/spring-messaging-4.1.7.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/spring-oxm/4.0.9.RELEASE/spring-oxm-4.0.9.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/boot/spring-boot-starter-ws/1.2.5.RELEASE/spring-boot-starter-ws-1.2.5.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/spring-tx/4.1.7.RELEASE/spring-tx-4.1.7.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/slf4j/slf4j-log4j12/1.7.12/slf4j-log4j12-1.7.12.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/spring-expression/4.1.7.RELEASE/spring-expression-4.1.7.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/boot/spring-boot/1.2.5.RELEASE/spring-boot-1.2.5.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.4.6/jackson-core-2.4.6.jar, file:/C:/Users/Maya/.m2/repository/org/springframework/spring-core/4.1.7.RELEASE/spring-core-4.1.7.RELEASE.jar, file:/C:/Users/Maya/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.0.23/tomcat-embed-core-8.0.23.jar]
DEBUG: [авг-03 13:08:33,572] springframework.boot.SpringApplication - Loading source class com.mayacomp.app.WsApplication
DEBUG: [авг-03 13:08:33,627] context.config.ConfigFileApplicationListener - Skipped config file 'file:./config/application.xml' resource not found
DEBUG: [авг-03 13:08:33,627] context.config.ConfigFileApplicationListener - Skipped config file 'file:./config/application.yml' resource not found
DEBUG: [авг-03 13:08:33,628] context.config.ConfigFileApplicationListener - Skipped config file 'file:./config/application.properties' resource not found
DEBUG: [авг-03 13:08:33,628] context.config.ConfigFileApplicationListener - Skipped config file 'file:./config/application.yaml' resource not found
DEBUG: [авг-03 13:08:33,629] context.config.ConfigFileApplicationListener - Skipped config file 'file:./application.xml' resource not found
DEBUG: [авг-03 13:08:33,629] context.config.ConfigFileApplicationListener - Skipped config file 'file:./application.yml' resource not found
DEBUG: [авг-03 13:08:33,630] context.config.ConfigFileApplicationListener - Skipped config file 'file:./application.properties' resource not found
DEBUG: [авг-03 13:08:33,630] context.config.ConfigFileApplicationListener - Skipped config file 'file:./application.yaml' resource not found
DEBUG: [авг-03 13:08:33,631] context.config.ConfigFileApplicationListener - Skipped config file 'classpath:/config/application.xml' resource not found
DEBUG: [авг-03 13:08:33,631] context.config.ConfigFileApplicationListener - Skipped config file 'classpath:/config/application.yml' resource not found
DEBUG: [авг-03 13:08:33,632] context.config.ConfigFileApplicationListener - Skipped config file 'classpath:/config/application.properties' resource not found
DEBUG: [авг-03 13:08:33,632] context.config.ConfigFileApplicationListener - Skipped config file 'classpath:/config/application.yaml' resource not found
DEBUG: [авг-03 13:08:33,633] context.config.ConfigFileApplicationListener - Skipped config file 'classpath:/application.xml' resource not found
DEBUG: [авг-03 13:08:33,633] context.config.ConfigFileApplicationListener - Skipped config file 'classpath:/application.yml' resource not found
DEBUG: [авг-03 13:08:33,634] context.config.ConfigFileApplicationListener - Skipped config file 'classpath:/application.properties' resource not found
DEBUG: [авг-03 13:08:33,634] context.config.ConfigFileApplicationListener - Skipped config file 'classpath:/application.yaml' resource not found
INFO : [авг-03 13:08:33,642] context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@731b45a8: startup date [Mon Aug 03 13:08:33 MSK 2015]; root of context hierarchy
DEBUG: [aug-03 13:08:33,649] context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Bean factory for org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@731b45a8: org.springframework.beans.factory.support.DefaultListableBeanFactory@5ff5d9af: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,wsApplication]; root of factory hierarchy
DEBUG: [aug-03 13:08:35,233] context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@2fffdd6a]
DEBUG: [aug-03 13:08:35,233] context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Using ApplicationEventMulticaster [org.springframework.context.event.SimpleApplicationEventMulticaster@4cc2be65]
DEBUG: [aug-03 13:08:35,658] embedded.tomcat.TomcatEmbeddedServletContainerFactory - Code archive: C:\Users\Maya\.m2\repository\org\springframework\boot\spring-boot\1.2.5.RELEASE\spring-boot-1.2.5.RELEASE.jar
DEBUG: [aug-03 13:08:35,659] embedded.tomcat.TomcatEmbeddedServletContainerFactory - Code archive: C:\Users\Maya\.m2\repository\org\springframework\boot\spring-boot\1.2.5.RELEASE\spring-boot-1.2.5.RELEASE.jar
DEBUG: [aug-03 13:08:35,660] embedded.tomcat.TomcatEmbeddedServletContainerFactory - Document root: C:\Users\Maya\workspace\APPService\src\main\webapp
INFO : [aug-03 13:08:35,705] embedded.tomcat.TomcatEmbeddedServletContainer - Tomcat initialized with port(s): 8080 (http)
DEBUG: [aug-03 13:08:36,156] context.embedded.ServletContextInitializerBeans - Added existing Servlet initializer bean 'dispatcherServlet'; order=2147483647, resource=class path resource [com/mayacomp/app/WebServiceConfig.class]
DEBUG: [aug-03 13:08:36,271] context.embedded.ServletContextInitializerBeans - Created Filter initializer for bean 'characterEncodingFilter'; order=-2147483648, resource=class path resource [org/springframework/boot/autoconfigure/web/HttpEncodingAutoConfiguration.class]
DEBUG: [aug-03 13:08:36,272] context.embedded.ServletContextInitializerBeans - Created Filter initializer for bean 'hiddenHttpMethodFilter'; order=-2147483638, resource=class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.class]
DEBUG: [aug-03 13:08:36,827] context.embedded.ServletContextInitializerBeans - Created EventListener initializer for bean 'requestContextListener'; order=2147483647, resource=class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]
INFO : [aug-03 13:08:36,830] context.embedded.ServletRegistrationBean - Mapping servlet: 'messageDispatcherServlet' to [/services/*]
INFO : [aug-03 13:08:36,837] context.embedded.FilterRegistrationBean - Mapping filter: 'characterEncodingFilter' to: [/*]
INFO : [aug-03 13:08:36,838] context.embedded.FilterRegistrationBean - Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
DEBUG: [aug-03 13:08:36,987] context.web.OrderedHiddenHttpMethodFilter - Initializing filter 'hiddenHttpMethodFilter'
DEBUG: [aug-03 13:08:36,989] context.web.OrderedHiddenHttpMethodFilter - Filter 'hiddenHttpMethodFilter' configured successfully
DEBUG: [aug-03 13:08:36,990] context.web.OrderedCharacterEncodingFilter - Initializing filter 'characterEncodingFilter'
DEBUG: [aug-03 13:08:36,990] context.web.OrderedCharacterEncodingFilter - Filter 'characterEncodingFilter' configured successfully
DEBUG: [aug-03 13:08:37,676] context.embedded.AnnotationConfigEmbeddedWebApplicationContext - Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor@5579e98a]
DEBUG: [aug-03 13:08:37,682] autoconfigure.logging.AutoConfigurationReportLoggingInitializer -
=========================
AUTO-CONFIGURATION REPORT
=========================
Positive matches:
-----------------
bla bla
Negative matches:
bla bla
INFO : [aug-03 13:08:37,877] embedded.tomcat.TomcatEmbeddedServletContainer - Tomcat started on port(s): 8080 (http)
答案 0 :(得分:1)
请删除pom中的双重条目:
在您的WebServiceConfig中,请添加:
servlet.setTransformWsdlLocations(true);
您必须在构建期间自动生成基于XML架构的域类。因此,请将其添加到您的POM中,并根据您的要求修改schemaDir和outputDir:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${project.basedir}/src/main/resources/</schemaDirectory>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
我看到你的主应用程序在com.mayacomp.app包中,你用@SpringBootApplication注释了这个类。因此,让您的WS组件位于com.mayacomp.app包下是很重要的,否则组件扫描无法找到它们。请注意,您的targetNamespace在依赖组件和Xml-Request的SoapEnvelop元素中是相同的。 您可以尝试使用端点/服务和test.xml之类的测试文件,例如curl:
curl --header "content-type: text/xml" -d @test.xml http://localhost:8080/services/