javax.xml.ws.Service 无法读取声明为 URL('file:Authentication.wsdl') 的 wsdlDocumentationLocation
javax.xml.ws.Service could not read wsdlDocumentationLocation which is declare as URL('file:Authentication.wsdl')
我的 Java servlet,使用 JDeveloper 11g R2 开发并部署在 WebLogic Server 10.3.6 上,需要与 tiers 公司开发的特定 WebService 通信。
javax.xml.ws.Service
是用 wsdlDocumentLocation
作为 URL ('file:Authentication.wsdl'
) 创建的。
在我禁用防火墙的服务器上一切正常。
但是在客户服务器上,我收到以下错误:
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
?
我不确定,但据我了解,使用 URL 和 file:
指向某个网络协议访问的本地文件?我说得对吗?
如果这是真的,你能解释一下我应该在我的防火墙 (Linux) 中设置什么类型的规则来允许访问这个本地文件吗?
file:Authentication.wsdl
是否意味着http://localhost:Authentication.wsdl or something like http://localhost/myServletContext/Authentication.wsdl?
我不知道我需要做什么来解决这个问题。
我做了进一步的测试并显示了关于 URL 对象的信息。对于新的 URL('file:/tmp/Authentication.wsdl')、getPort() returns -1、getHost() returns 什么都没有和 getPath() returns /tmp/Authentication。 wsdl.
我的 Authentication.wsdl 在我的 war 文件中使用的 jar 文件中。
“file:Authentication.wsdl”不是网络协议。它只是指同一系统上的普通旧文件名。
它失败了,因为你的 Authentication.wsdl 实际上不是一个文件。它是 .jar 文件中的一个条目,我假设它在 class 路径上(因为 .war 文件的 WEB-INF/lib 结构中的所有 .jar 文件都是)。因此,file:
URL 将 永远不会 在生产环境中工作。没有人以未存档的形式分发 Java 应用程序(有很多充分的理由)。
class路径中的条目称为资源。访问此类数据的正确方法是使用 Class.getResource 方法,该方法扫描 class 路径以查找请求的条目:
URL wsdlLocation = MyServlet.class.getResource("Authentication.wsdl");
但是请注意,这将在 与您的 class 相同的包 中查找 Authentication.wsdl。如果您的 Authentication.wsdl 在存档的根目录中,您 可以 更改字符串参数来找到它——但您不应该这样做。将资源放在存档的根目录中与将文件放在 C: 驱动器的根目录中非常相似;它有与 class 路径中的众多其他库发生冲突的风险。这就是为什么 Class.getResource 默认情况下假定您的文件位于与 Class 对象的包结构相匹配的目录中。
意思是,如果您的 servlet class 在 com.example.myapp
包中,Authentication.wsdl 应该作为 com/example/myapp/Authentication.wsdl
.
在 .jar 文件中
我的 Java servlet,使用 JDeveloper 11g R2 开发并部署在 WebLogic Server 10.3.6 上,需要与 tiers 公司开发的特定 WebService 通信。
javax.xml.ws.Service
是用 wsdlDocumentLocation
作为 URL ('file:Authentication.wsdl'
) 创建的。
在我禁用防火墙的服务器上一切正常。
但是在客户服务器上,我收到以下错误:
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
?
我不确定,但据我了解,使用 URL 和 file:
指向某个网络协议访问的本地文件?我说得对吗?
如果这是真的,你能解释一下我应该在我的防火墙 (Linux) 中设置什么类型的规则来允许访问这个本地文件吗?
file:Authentication.wsdl
是否意味着http://localhost:Authentication.wsdl or something like http://localhost/myServletContext/Authentication.wsdl?
我不知道我需要做什么来解决这个问题。
我做了进一步的测试并显示了关于 URL 对象的信息。对于新的 URL('file:/tmp/Authentication.wsdl')、getPort() returns -1、getHost() returns 什么都没有和 getPath() returns /tmp/Authentication。 wsdl.
我的 Authentication.wsdl 在我的 war 文件中使用的 jar 文件中。
“file:Authentication.wsdl”不是网络协议。它只是指同一系统上的普通旧文件名。
它失败了,因为你的 Authentication.wsdl 实际上不是一个文件。它是 .jar 文件中的一个条目,我假设它在 class 路径上(因为 .war 文件的 WEB-INF/lib 结构中的所有 .jar 文件都是)。因此,file:
URL 将 永远不会 在生产环境中工作。没有人以未存档的形式分发 Java 应用程序(有很多充分的理由)。
class路径中的条目称为资源。访问此类数据的正确方法是使用 Class.getResource 方法,该方法扫描 class 路径以查找请求的条目:
URL wsdlLocation = MyServlet.class.getResource("Authentication.wsdl");
但是请注意,这将在 与您的 class 相同的包 中查找 Authentication.wsdl。如果您的 Authentication.wsdl 在存档的根目录中,您 可以 更改字符串参数来找到它——但您不应该这样做。将资源放在存档的根目录中与将文件放在 C: 驱动器的根目录中非常相似;它有与 class 路径中的众多其他库发生冲突的风险。这就是为什么 Class.getResource 默认情况下假定您的文件位于与 Class 对象的包结构相匹配的目录中。
意思是,如果您的 servlet class 在 com.example.myapp
包中,Authentication.wsdl 应该作为 com/example/myapp/Authentication.wsdl
.