Java 连接到使用SOAPpy的pythonwebservice的Android客户端
我是SOAP编程新手,正在寻找我的android应用程序能够与用SOAPpy编写的python Web服务通信的方法。我在互联网上发现,使用套接字通信可能是一种选择,但另一种选择是,我可以使用HTTP/HTTPS这样做吗?WifiPositioningSoapAPI包含的函数允许我操作存储数据的XML文件Java 连接到使用SOAPpy的pythonwebservice的Android客户端,java,android,soap,ksoap2,soapui,Java,Android,Soap,Ksoap2,Soapui,我是SOAP编程新手,正在寻找我的android应用程序能够与用SOAPpy编写的python Web服务通信的方法。我在互联网上发现,使用套接字通信可能是一种选择,但另一种选择是,我可以使用HTTP/HTTPS这样做吗?WifiPositioningSoapAPI包含的函数允许我操作存储数据的XML文件 class StartSOAPServer: def __init__(self): api = WifiPositionSoapAPI() handler = SOA
class StartSOAPServer:
def __init__(self):
api = WifiPositionSoapAPI()
handler = SOAPpy.SOAPServer(("", Config.SOAP_PORT))
handler.registerObject(api, Config.NAMESPACE)
print "SOAP server running at IP Address %s port %s." % (socket.gethostbyname(socket.gethostname() ), Config.SOAP_PORT)
handler.serve_forever()
这就是我所做的,getPassword位于python服务器上与之交互的一个.py文件夹中,该文件夹包含许多.py文件
public class WifiPositioningServices {
private final String NAMESPACE = "urn:WifiPositioningSystem";
//private final String METHOD_NAME = "GetPassword";
//private final String SOAP_ACTION = "urn:WifiPositioningSystem/GetPassword";
private final String URL = "http://xxx.xxx.xxx.xxx:8080";
private SoapSerializationEnvelope envelope;
public WifiPositioningServices(){
}
public String[] getPassword(String loginID){
String[] temp = null;
SoapObject request = new SoapObject(NAMESPACE, "GetPassword");
PropertyInfo quotesProperty = new PropertyInfo();
quotesProperty.setName("LoginID");
quotesProperty.setValue(loginID);
quotesProperty.setType(String.class);
request.addProperty(quotesProperty);
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
String result = "";
HttpTransportSE httpRequest = new HttpTransportSE(URL);
try
{
httpRequest.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
result = response.toString();
temp = result.split(";");
}
catch(Exception e)
{
e.printStackTrace();
}
return temp;
}
}