我开发了一个Android应用程序
这是我的代码:
public class RetailerActivity extends Activity {
private static final String SOAP_ACTION = "http://ws.testprops.com/customerData";
private static final String METHOD_NAME = "customerData";
private static final String NAMESPACE = "http://ws.testprops.com";
private static final String URL = "http://87.76.29.180:8080/TestPrompts/services/Fetch?wsdl";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE ht = new HttpTransportSE(URL);
try {
ht.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
SoapPrimitive s = response;
String str = s.toString();
String resultArr[] = str.split("&");//Result string will split & store in an array
TextView tv = new TextView(this);
for(int i = 0; i<resultArr.length;i++){
tv.append(resultArr[i]+"\n\n");
}
setContentView(tv);
} catch (Exception e) {
e.printStackTrace();
}
}
}
这是我的本地tomcat apache服务器wsdl文件:
http://localhost:8089/TestPrompts/services/Fetch?wsdl
表示它已成功用于我的模拟器和Android设备。
同样的TestPrompts项目我只导出并创建了war文件并上传到我的tomcat服务器。
这是我的tomcat服务器wsdl文件:
http://87.76.29.180:8080/TestPrompts/services/Fetch?wsdl
但这里只面临问题:
我必须把这些URL意味着在模拟器和Android设备上都没有得到任何结果。我只是得到了黑屏。
控制台窗口显示以下错误:
11-19 15:12:55.232: D/SntpClient(73): request time failed: java.net.SocketException: Address family not supported by protocol
请帮助我。我可以解决我的错误。
答案 0 :(得分:0)
我认为您遇到了某种网络问题。请尝试通过手机或模拟器中的浏览器访问该wsdl。所以你可以查看天气连接是否存在。 。请参阅这篇文章。我在我的应用程序中完成了它。 http://www.insightforfuture.blogspot.com/search/label/Android