2013-02-26 43 views
0

WSDL位置的文件我用提供的WSDL位置路徑文件中的wsimport任務的gradle產生了初步的MyService:/ d:/someLocationWherePlacedMyWSDl.interface.v2.wsdl如何更改內部供水

public class MyService 
    extends Service 
{ 

    private final static URL MyService_WSDL_LOCATION; 
    private final static Logger logger = Logger.getLogger(com.google.services.MyService.class.getName()); 

    static { 
     URL url = null; 
     try { 
      URL baseUrl; 
      baseUrl = com.google.services.MyService.class.getResource("."); 
      url = new URL(baseUrl, "file:/D:/someLocationWherePlacedMyWSDl.interface.v2.wsdl"); 
     } catch (MalformedURLException e) { 
      logger.warning("Failed to create URL for the wsdl Location: 'file:/D:/someLocationWherePlacedMyWSDl.interface.v2.wsdl', retrying as a local file"); 
      logger.warning(e.getMessage()); 
     } 
     MyService_WSDL_LOCATION = url; 
    } 
} 

我怎樣才能更改?它發生是因爲該文件是在一個環境中生成的,然後該工件(戰爭)被移動到另一個服務器。

有什麼想法?


是的,我明白了。本地一切都完美。但是這個文件位於war文件內部,當Jenkins試圖獲得這個文件/var/distributives/myservice/tomcat-base/wsdl/someLocationWherePlacedMyWSDl.interface.v2.wsdl時,我得到異常(沒有這樣的文件或目錄)。它看起來像無法看到戰爭文件內的文件。任何想法如何處理?

回答

0

使用您的服務類的構造函數MyService來傳遞wsdlLocation

String WSDL_LOCATION = "http://server:port/localtionWSDL.interface.v2.wsdl"; 

try { 
    final URL url = new URL(WSDL_LOCATION); 
    final QName serviceName = new QName("http://mynamespace/", "MyService"); 
    final MyService service = new MyService(url, serviceName); 
    port = service.getMyServicePort(); 

    // Call some operation of WebService 

} catch (final Exception e) { 
    // Handle the exception 
} 
0

我用相對路徑解決了這個問題。這裏是解決方案
@Value("classpath:com//google//resources//wsdl//myservice.interface.v2.wsdl") public void setWsdlLocation(final Resource wsdlLocation) { m_wsdlLocation = wsdlLocation; }