简体   繁体   中英

Java Web Service Client which access the .Net Webservice

I'm trying to access online.Net Webservice through Java Webservice client.

But unfortunately, am getting an error " Connection timed out: connect "

Below is my code:

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;

public class WebServiceMain {

    public static void main(String[] args) {

         try {
                 String endpoint = "http://wsf.cdyne.com/SpellChecker/check.asmx";
                 Service service = new Service();
                 Call call = (Call)service.createCall();
                 call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true)); 
                     call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://ws.cdyne.com/CheckTextBodyV2");
                     call.setTargetEndpointAddress( new java.net.URL(endpoint) );
                     call.setPortName(new QName("http://ws.cdyne.com/", "check"));
                 call.setOperationName(new QName("http://ws.cdyne.com/", "CheckTextBodyV2"));

                 System.out.println(call.invoke(new Object[] {"helo is my name"}));
               } catch (Exception e) {
                 System.err.println(e.toString());
               }
    }
}

Connection timeout comes because of network issues.try to acess URL in browser.also try to append?wsdl at the end of URL,you should see the wsdl.if this doesn't work troubleshoot network settings.

Connection timed out: connect

This means that your client application cannot even talk to the Web Service. This is not a programmatic issue.

Check and see whether you can access the end-point through your web browser. If not, then that service is not available. So it doesn't work.

If your browser can access it, and if you are connecting to Internet through a proxy, then you need to specify the proxy details to Java Client. To do that, you can use -Dhttp.proxyHost=10.2.240.11 and -Dhttp.proxyPort=8080 (replace with your values) system properties when you start up your client application.

Download the soapui software and get installed it. then load the wsdl file and create the project.

Then test your web service via soap ui. you can edit the connection timeout value of the soap ui. chane it for big vlue and test.still your getiong time out ping to the ip addres of the service

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