繁体   English   中英

Java code to call a wsdl URL got connection timeout, but using SOAP UI to call the same wsdl URL doesn't have issue

[英]Java code to call a wsdl URL got connection timeout, but using SOAP UI to call the same wsdl URL doesn't have issue

I have a wsdl URL call https://example.com/servicetokenprovider.asmx , and if I using SOAP UI to call this url, everything go smooth.

但是如果我使用 java 代码来调用这个 URL,这里是代码片段

// Soap 调用 web 服务

URL url = new URL(soapCallURL);
ServiceTokenProviderSoapStub stubToken = (ServiceTokenProviderSoapStub) new ServiceTokenProviderLocator()
        .getServiceTokenProviderSoap(url);
// Initiate variables headers
HeaderAccountMapping headerMapping = new HeaderAccountMapping();

try {
    
    File f = new File(session_property);
    Path path = Paths.get(session_property);
    if (!Files.isDirectory(path.getParent()))
        Files.createDirectories(path.getParent());
    if(!f.exists())
        f.createNewFile();
    // create property file
    Properties props = new Properties();
    FileOutputStream fos = new FileOutputStream(session_property);
    stubToken.setTimeout(8000);
    // Get the session value and User ID
    headerMapping.setSessionKeyValue(
            stubToken.getSessionIdentifier(sessionApplication, sessionUserName, sessionPassword).getSessionKey());
    headerMapping.setUserIdValue(
            Integer.toString(stubToken.getSessionIdentifier(sessionApplication, sessionUserName, sessionPassword).getUserID()));


    // set the session value and User ID
    props.setProperty("sessionKey", headerMapping.getSessionKeyValue());
    props.setProperty("userID", headerMapping.getUserIdValue());

    // writing properites into properties file from Java
    props.store(fos, "Properties file generated from Java program");

    fos.close();

我得到了以下异常:

ERROR 2021-06-05 13:24:19,884 [[Collabria].GetSessionValueUserID.stage1.02] WebServiceClient.GetSessionToken: [Ljava.lang.StackTraceElement;@1c4d3f2d
org.apache.axis.AxisFault: ; nested exception is: 
    java.net.ConnectException: Connection timed out: connect
    at org.apache.axis.AxisFault.makeFault(AxisFault.java:101) ~[axis.jar:?]
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154) ~[axis.jar:?]
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) ~[axis.jar:?]
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) ~[axis.jar:?]
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) ~[axis.jar:?]
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) ~[axis.jar:?]
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784) ~[axis.jar:?]
    at org.apache.axis.client.Call.invoke(Call.java:2767) ~[axis.jar:?]
    at org.apache.axis.client.Call.invoke(Call.java:2443) ~[axis.jar:?]
    at org.apache.axis.client.Call.invoke(Call.java:2366) ~[axis.jar:?]
    at org.apache.axis.client.Call.invoke(Call.java:1812) ~[axis.jar:?]

是不是我做错了什么? 因为这部分代码我没有像一个月一样改变..最后一次工作是上个月底

确认这是防火墙问题,一旦他们将所有问题都列入白名单

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM