Spring Boot + Apache CXF:为什么找不到 wsdl?
Spring Boot + Apache CXF: why can't find wsdl?
同学们,我还在尝试"to make friends all"Spring-Boot,Tomcat和web服务实现class:
@javax.jws.WebService(
serviceName = "ServiceForApp",
portName = "ServiceEndPoind",
targetNamespace = "http://new.webservice.namespace",
endpointInterface = "com.comp.appserv.WebServiceInterface",
wsdlLocation = "resources/WebService.wsdl"
)
public class ServiceEndPoindImpl implements WebServiceInterface {logic};
我有申请class:
package com.comp.config;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import com.comp.appserv.ServiceEndPoindImpl;
import javax.xml.ws.Endpoint;
@SpringBootApplication
public class Application {
public static final String SERVLET_MAPPING_URL_PATH = "/soap/*";
public static final String SERVICE_NAME_URL_PATH = "/app";
@Autowired
private ApplicationContext applicationContext;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public ServletRegistrationBean dispatcherServlet() {
return new ServletRegistrationBean(new CXFServlet(), SERVLET_MAPPING_URL_PATH);
}
@Bean(name = Bus.DEFAULT_BUS_ID)
// <bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus">
public SpringBus springBus() {
return new SpringBus();
}
@Bean
// <jaxws:endpoint id="app" implementor="com.dlizarra.app.ws.AppImpl" address="/app">
public Endpoint app() {
Bus bus = (Bus) applicationContext.getBean(Bus.DEFAULT_BUS_ID);
Object implementor = new ServiceEndPoindImpl();
EndpointImpl endpoint = new EndpointImpl(bus, implementor);
endpoint.publish(SERVICE_NAME_URL_PATH);
return endpoint;
}
}
我的目标是获取带有嵌入式 Tomcat 和 Web 服务部署的单个 jar 文件。
目前我的问题是在 mvn spring-boot:run
之后我收到异常
Caused by: java.io.FileNotFoundException: C:\Users\Maya\git\web-services\resources\WebService.wsdl (The system cannot find the file specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
The full stacktrace is here: http://pastebin.com/Ez3S5CWu
你能帮我解答下几个问题吗:
为什么 Spring 尝试通过此 link C:\Users\Maya\git\web-services\resources\WebService.wsdl
查找 wsdl,而不是从 @javax.jws.WebService
注释的路径中查找?我应该在哪里设置这个路径?
创建带有嵌入式 Tomcat 的单个 jar 的方法是否正确?
Spring 是使用注释中的路径;但由于它是相对路径,因此当前目录(您的应用程序启动 rom 的位置)用于构建完整路径。
尝试
wsdlLocation = "classpath:resources/WebService.wsdl"
通过类路径搜索。
至于问题 2,只要没有什么可以阻止它,它是否是正确的入手方式。您的 IT 基础架构可能出于某些原因否决它。
同学们,我还在尝试"to make friends all"Spring-Boot,Tomcat和web服务实现class:
@javax.jws.WebService(
serviceName = "ServiceForApp",
portName = "ServiceEndPoind",
targetNamespace = "http://new.webservice.namespace",
endpointInterface = "com.comp.appserv.WebServiceInterface",
wsdlLocation = "resources/WebService.wsdl"
)
public class ServiceEndPoindImpl implements WebServiceInterface {logic};
我有申请class:
package com.comp.config;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import com.comp.appserv.ServiceEndPoindImpl;
import javax.xml.ws.Endpoint;
@SpringBootApplication
public class Application {
public static final String SERVLET_MAPPING_URL_PATH = "/soap/*";
public static final String SERVICE_NAME_URL_PATH = "/app";
@Autowired
private ApplicationContext applicationContext;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public ServletRegistrationBean dispatcherServlet() {
return new ServletRegistrationBean(new CXFServlet(), SERVLET_MAPPING_URL_PATH);
}
@Bean(name = Bus.DEFAULT_BUS_ID)
// <bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus">
public SpringBus springBus() {
return new SpringBus();
}
@Bean
// <jaxws:endpoint id="app" implementor="com.dlizarra.app.ws.AppImpl" address="/app">
public Endpoint app() {
Bus bus = (Bus) applicationContext.getBean(Bus.DEFAULT_BUS_ID);
Object implementor = new ServiceEndPoindImpl();
EndpointImpl endpoint = new EndpointImpl(bus, implementor);
endpoint.publish(SERVICE_NAME_URL_PATH);
return endpoint;
}
}
我的目标是获取带有嵌入式 Tomcat 和 Web 服务部署的单个 jar 文件。
目前我的问题是在 mvn spring-boot:run
之后我收到异常
Caused by: java.io.FileNotFoundException: C:\Users\Maya\git\web-services\resources\WebService.wsdl (The system cannot find the file specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
The full stacktrace is here: http://pastebin.com/Ez3S5CWu
你能帮我解答下几个问题吗:
为什么 Spring 尝试通过此 link
C:\Users\Maya\git\web-services\resources\WebService.wsdl
查找 wsdl,而不是从@javax.jws.WebService
注释的路径中查找?我应该在哪里设置这个路径?创建带有嵌入式 Tomcat 的单个 jar 的方法是否正确?
Spring 是使用注释中的路径;但由于它是相对路径,因此当前目录(您的应用程序启动 rom 的位置)用于构建完整路径。
尝试
wsdlLocation = "classpath:resources/WebService.wsdl"
通过类路径搜索。
至于问题 2,只要没有什么可以阻止它,它是否是正确的入手方式。您的 IT 基础架构可能出于某些原因否决它。