我不明白为什么我在Android上的soap请求不起作用,我遵循了https://code.tutsplus.com/tutorials/consuming-web-services-with-ksoap--mobile-21242上的教程
这基本上是我的代码如下所示:
公共类SoapClient {
private static final String NAMESPACE = "https://ieslamp.technikum-wien.at/sys_bvu4_17_l/JamDec/ContentManager/soapservice.php";
//not used right now
private static final String TARGET_NAMESPACE = "http://ieslamp.technikum-wien.at/soap/getJamRoutes";
private static final String SOAP_ACTION = "https://ieslamp.technikum-wien.at/sys_bvu4_17_l/JamDec/ContentManager/soapservice.php/getJamRoutes";
//which is the URL I need? some tutorials say it's the url to the wsdl, but others say it's the location of the webservice
private static final String POST_URL = "https://ieslamp.technikum-wien.at/sys_bvu4_17_l/JamDec/ContentManager/soapservice.php?wsdl";
private static final String LOCATION_URL = "https://ieslamp.technikum-wien.at:443/sys_bvu4_17_l/JamDec/ContentManager/soapservice.php";
private Context context;
public SoapClient(Context context) {
this.context = context;
}
public String getJamsFromServer() {
String methodname = "getJamRoutes";
SoapObject request = new SoapObject(TARGET_NAMESPACE, methodname);
String routes = null;
SoapSerializationEnvelope envelope = getSoapSerializationEnvelope(request);
HttpTransportSE ht = getHttpTransportSE();
try {
ArrayList<HeaderProperty> headerPropertyArrayList = new ArrayList<>();
headerPropertyArrayList.add(new HeaderProperty("Connection", "close"));
ht.call(SOAP_ACTION, envelope, headerPropertyArrayList);
SoapPrimitive result = (SoapPrimitive)envelope.getResponse();
routes = result.toString();
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
return routes;
}
private final SoapSerializationEnvelope getSoapSerializationEnvelope(SoapObject request) {
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.implicitTypes = true;
envelope.setOutputSoapObject(request);
return envelope;
}
private final HttpTransportSE getHttpTransportSE() {
HttpTransportSE ht = new HttpTransportSE(Proxy.NO_PROXY, LOCATION_URL, 1200000);
ht.debug = true;
ht.setXmlVersionTag("<!--?xml version=\"1.0\" encoding= \"UTF-8\" ?-->");
return ht;
}
}该服务返回一个"Hello World“-字符串,我使用SOAP测试它,这个软件的请求实际上给了我一个响应,但是当我试图用我的Android应用程序做出响应时-
ht.call();在我身上抛出一个EOF异常,我不知道出了什么问题。
你能解释一下哪个名称空间和url -
HttpTransportSE ht = new HttpTransportSE(URL); 我真的需要?我是使用targetNamespace还是名称空间?我在研究的时候弄不清楚。
下面是我生成的wsdl文件:
谢谢你的帮助!
发布于 2017-06-25 23:21:04
问题自己解决了,似乎最新的jar文件不起作用。如果您要使用ksoap,我建议您使用被标记为不推荐的旧版本,但它们至少会完成这项工作。
https://stackoverflow.com/questions/44616836
复制相似问题