简体   繁体   中英

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.

But if I using java code to call this URL, and here is the code snippet

// Soap Call web service

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();

And I got following exception:

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:?]

Is it something I did wrong? Because this part of the code I didn't change like a month.. and last time it works is the end of last month

Confirmed it is firewall issue, once they whitelist that everything fix

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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