Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用ksoap2在GlassFish服务器上使用Web服务的Android应用程序_Java_Android_Web Services_Glassfish - Fatal编程技术网

Java 使用ksoap2在GlassFish服务器上使用Web服务的Android应用程序

Java 使用ksoap2在GlassFish服务器上使用Web服务的Android应用程序,java,android,web-services,glassfish,Java,Android,Web Services,Glassfish,我有一个android应用程序,它使用一个位于我笔记本电脑GlassFish服务器上的Web服务。当我的笔记本电脑和我的设备都连接到WiFi时,它会按预期工作。但是,当我的设备连接到移动3g网络时,当我尝试访问Web服务时,它会抛出一个超时错误: W/System.err3835:java.net.ConnectException:未能连接到>/[RouterIPAddress]端口8080:连接失败:ETIMEDOUT连接超时 我已将路由器配置为将HTTP转发到笔记本电脑的IP和端口8080

我有一个android应用程序,它使用一个位于我笔记本电脑GlassFish服务器上的Web服务。当我的笔记本电脑和我的设备都连接到WiFi时,它会按预期工作。但是,当我的设备连接到移动3g网络时,当我尝试访问Web服务时,它会抛出一个超时错误:

W/System.err3835:java.net.ConnectException:未能连接到>/[RouterIPAddress]端口8080:连接失败:ETIMEDOUT连接超时

我已将路由器配置为将HTTP转发到笔记本电脑的IP和端口8080

这是我调用Web服务的代码:

public class WebService {
//Namespace of the Webservice - can be found in WSDL
private static String NAMESPACE = "http://service.marcusjacobsson.com/";
//Webservice URL - WSDL File location    
private static String URL = "http://[myRoutersIPAddress]:8080/WebServiceProject/HelloWebService?wsdl";
//SOAP Action URI again Namespace + Web method name
private static String SOAP_ACTION = "http://service.marcusjacobsson.com/";

public static String[] invokeHelloWorldWS(String webMethName) {
    String[] resultArray = null;
    // Create request
    SoapObject request = new SoapObject(NAMESPACE, webMethName);       
    // Create envelope
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    // Set output SOAP object
    envelope.setOutputSoapObject(request);
    // Create HTTP call object
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {
        // Invoke web service
        androidHttpTransport.call(SOAP_ACTION+webMethName, envelope);
        // Get the response
        SoapObject response = (SoapObject) envelope.bodyIn;

        if(response!=null){
            int count = response.getPropertyCount();
            resultArray = new String[count];
            for(int i=0;i<count;i++){
                resultArray[i]=response.getProperty(i).toString();
            }
        }
        return resultArray;

    } catch (Exception e) {
        //Print error
        e.printStackTrace();
    } 
    //Return resTxt to calling object
    return resultArray;
}   

}
是什么原因导致应用程序无法通过移动互联网连接到我的笔记本电脑,但当两台设备都在同一个wifi上运行时,它可以工作?需要对IP地址进行一些配置


提前感谢您提供有关如何调试此问题的任何答案或提示。

您的3G提供商是否允许服务器?经过一些研究,我的提供商似乎出于安全原因阻止了设备之间的直接通信,我必须支付额外费用才能实现这一点。新供应商的时间: