Java 弹簧靴&x2B;apachecxf:为什么可以';找不到wsdl?
同学们,我仍在尝试“交朋友”Spring Boot、Tomcat和web服务实现课程:Java 弹簧靴&x2B;apachecxf:为什么可以';找不到wsdl?,java,web-services,tomcat,spring-boot,cxf,Java,Web Services,Tomcat,Spring Boot,Cxf,同学们,我仍在尝试“交朋友”Spring Boot、Tomcat和web服务实现课程: @javax.jws.WebService( serviceName = "ServiceForApp", portName = "ServiceEndPoind", targetNamespace = "http://new.webservice.namespace",
@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};
我有一门应用课程:
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;
}
}
你能帮我回答以下问题吗:
C:\Users\Maya\git\web服务\resources\WebService.wsdl
,而不是从@javax.jws.WebService
注释的路径来查找wsdl?我应该在哪里设置此路径至于问题2,只要没有什么可以阻止它,那么这是一个正确的方法吗。由于某些原因,您的IT基础架构可能会否决它
java.io.FileNotFoundException:无法使用线程上下文类加载器或当前类加载器加载资源[classpath:resources/IsBankService.wsdl],但我通过向wsdl文件添加完整路径修复了它。谢谢,哎呀。使用完整路径时,问题再次出现=(ypu能否就以下原因引起的给出更多建议:
绝对路径的问题是,当应用程序在开发环境之外构建和运行时,它可能无法工作。因此,我会将wsdl打包到jar中(如果您使用maven,请将其设置在/src/main/resources下)并通过类路径访问它。确保它位于生成的jar中(解压缩它以确保构建过程已将其设置在那里。)smarquis。我打开jar并在jar的根目录中找到wsdl(不在资源文件夹中)。
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
wsdlLocation = "classpath:resources/WebService.wsdl"