gpt4 book ai didi

java - 从websphere迁移到tomcat后无法访问wsdl文件

转载 作者:行者123 更新时间:2023-11-28 22:52:57 25 4
gpt4 key购买 nike

我一直在将应用程序从 websphere 服务器迁移到 tomcat。但是现在我发现访问wsdl文件有问题。该文件位于正确的文件夹中,但即使它在 websphere 中工作,我也无法在代码中访问它。迁移到tomcat后需要改什么?

Java 类:

    //
// Generated By:JAX-WS RI IBM 2.1.1 in JDK 6 (JAXB RI IBM JAXB 2.1.3 in JDK 1.6)
//

package iseries.wsbeans.bit05;

import java.net.MalformedURLException;
import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;

@WebServiceClient(name = "BIT05", targetNamespace = "http://bit05.wsbeans.iseries", wsdlLocation = "WEB-INF/wsdl/BIT05.wsdl")
public class BIT05
extends Service
{

private final static URL BIT05_WSDL_LOCATION;

static {
URL url = null;

try {
url = new URL("file:./WEB-INF/wsdl/BIT05.wsdl");
} catch (MalformedURLException e) {
e.printStackTrace();
}

BIT05_WSDL_LOCATION = url;
}

public BIT05(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}

public BIT05() {
super(BIT05_WSDL_LOCATION, new QName("http://bit05.wsbeans.iseries", "BIT05"));
}

日志:

javax.xml.ws.WebServiceException: Failed to access the WSDL at: file:./WEB-INF/wsdl/BIT05.wsdl. It failed with: 
Got .\WEB-INF\wsdl\BIT05.wsdl (The system cannot find the path specified) while opening stream from file:./WEB-INF/wsdl/BIT05.wsdl.
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(Unknown Source)

有什么想法吗?

谢谢

最佳答案

代替:

url = new URL("file:./WEB-INF/wsdl/BIT05.wsdl");

尝试:

url = BIT05.class.getClassLoader().getResource("wsdl/BIT05.wsdl");

如果文件在类路径中,最好使用类加载器或 ServletContext 而不是直接使用文件系统。

关于java - 从websphere迁移到tomcat后无法访问wsdl文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34766187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com