簡體   English   中英

Spring Boot + Apache CXF:為什么找不到wsdl?

[英]Spring Boot + Apache CXF: why can't find wsdl?

同事,我仍在嘗試“結識所有人” Spring-Boot,Tomcat和Web服務實現類:

@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;
    }
}

我的目標是獲得帶有嵌入式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

您能否為我提供下一個問題的答案:

  1. 為什么Spring嘗試通過此鏈接C:\\Users\\Maya\\git\\web-services\\resources\\WebService.wsdl來找到wsdl,而不是從@javax.jws.WebService批注的路徑中找到? 我應該在哪里設置此路徑?

  2. 用嵌入式Tomcat創建單個jar是否正確?

春天使用從標注的路徑; 但由於它是相對路徑,因此使用當前目錄(您的應用程序從rom啟動)。

嘗試

wsdlLocation = "classpath:resources/WebService.wsdl"

在類路徑中搜索。

至於問題2,只要沒有阻止它的方法,從頭開始是正確的方法嗎? 您的IT基礎結構可能由於某些原因而否決了它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM