簡體   English   中英

javax.xml.ws.Service無法讀取wsdlDocumentationLocation,該文件聲明為URL('file:Authentication.wsdl')

[英]javax.xml.ws.Service could not read wsdlDocumentationLocation which is declare as URL('file:Authentication.wsdl')

由JDeveloper 11g R2開發並部署在WebLogic Server 10.3.6上的My Java servlet需要與由層級公司開發的特定WebService通信。

使用wsdlDocumentLocation作為URL( 'file:Authentication.wsdl' )創建javax.xml.ws.Service

在禁用了防火牆的服務器上,一切正常。

但是在客戶服務器上,出現以下錯誤:

file:Authentication.wsdl 
Jan 22, 2016 9:27:32 AM weblogic.wsee.jaxws.spi.WLSProvider createServiceDelegate WARNING: Could not read WSDL Definition from URL wsdlDocumentLocation: 2 counts of InaccessibleWSDLException. 
Jan 22, 2016 9:27:32 AM weblogic.wsee.jaxws.spi.WLSServiceDelegate addWsdlDefinitionFeature SEVERE: Failed to create WsdlDefinitionFeature for wsdl location: file:Authentication.wsdl, error: com.sun.xml.ws.wsdl.parser.InaccessibleWSDLException, message: 2 counts of InaccessibleWSDLException.

我懷疑客戶服務器上的防火牆阻止對文件Authentication.wsdl的訪問?

我不確定,但據我所知,使用帶file:的URL file:指向某個網絡協議訪問的本地文件? 我對嗎?

如果是這樣,您能否解釋一下我應該在防火牆(Linux)中設置哪種類型的規則以允許訪問此本地文件?

file:Authentication.wsdl是否表示http:// localhost:Authentication.wsdl或類似http://localhost/myServletContext/Authentication.wsdl的文件

我不知道該怎么做才能解決此問題。

我做了進一步的測試,並顯示有關URL對象的信息。 對於新的URL('file:/tmp/Authentication.wsdl'),getPort()返回-1,getHost()不返回任何內容,而getPath()返回/tmp/Authentication.wsdl。

我的Authentication.wsdl位於我的war文件中使用的jar文件中。

“ file:Authentication.wsdl”不是網絡協議。 它只是指同一系統上的舊文件名。

由於您的Authentication.wsdl實際上不是文件,因此失敗。 它是.jar文件中的一個條目,我假設它位於類路徑中(就像.war文件的WEB-INF / lib結構中的所有.jar文件一樣)。 因此, file: URL在生產環境中將永遠無法使用。 沒有人以未存檔的形式分發Java應用程序(出於許多充分的理由)。

類路徑中的條目稱為資源。 訪問此類數據的正確方法是使用Class.getResource方法,該方法掃描類路徑以查找所請求的條目:

URL wsdlLocation = MyServlet.class.getResource("Authentication.wsdl");

但是請注意,這將在您的類相同的包中查找Authentication.wsdl。 如果您的Authentication.wsdl位於存檔的根目錄中,則可以更改字符串參數以找到它,但不應這樣做。 將資源放置在存檔的根目錄中非常類似於將文件放置在C:驅動器的根目錄中。 它具有與類路徑中的許多其他庫沖突的風險。 這就是為什么默認情況下Class.getResource假定您的文件位於與Class對象的包結構匹配的目錄中的原因。

這意味着,如果您的Servlet類位於com.example.myapp包中,則Authentication.wsdl應位於.jar文件中,即com/example/myapp/Authentication.wsdl

暫無
暫無

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

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