So far I have created a PHP client, and a VB.NET client which both successfully call my PHP web-service. To get the latter to work I needed to use the SoapUI tool from SourceForge. It told me that my wsdl was not WS-I compliant. I did not need the Pro version to test my service interactively as it allows you to directly edit the soap request. After fixing my WSDL and getting my VB.Net client functioning android is still a problem.
I also attached the source code for ksoap2-andriod so that I could step through while debugging. It helped a little but there are bundled dependencies for which the source is not included, in particular "kxml2 v1.6". If anyone can point me to a source zip or Jar for that I'd appreciate it.
This is the error I cant get past when calling the PHP webservice from my android client.
org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <definitions name='naturallyIrrationalsoapserver' targetNamespace='http://www.naturallyIrrational.com'>@10:42 in java.io.InputStreamReader@44dce560)
Its telling me it cant parse the WSDL\XML - the poistion @10.42 is the end of the opening definitions tag.
I believe that as the WSDL in now WS-I compliant that the problem is withing this service namespace definitions as interpreted by Ksoap2. Here is my android client code used to call it.
public class SoapClientActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = (TextView) findViewById(R.id.myText);
String soapResponse="";
final String METHOD_NAME = "getArrval";
final String SOAP_ACTION = "http://www.naturallyIrrational.com/naturallyIrrationalsoapserver.wsdl";
final String NAMESPACE = "http://www.naturallyIrrational.com";
* This next line was incorrect and should point to http://www.naturallyIrrational.com/naturallyIrrationalsoapserver.php *
final String URL = "http://www.naturallyIrrational.com/naturallyIrrationalsoapserver.wsdl";
if (InternetStatus.getInstance(this).isOnline(this)) {
try{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo pi = new PropertyInfo();
pi.setName("valname");
pi.setValue("rt2");
pi.setType(String.class);
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=false;
envelope.setOutputSoapObject(request);
HttpTransportSE andHttpTransport = new HttpTransportSE(URL);
andHttpTransport.debug = true;
andHttpTransport.call(SOAP_ACTION, envelope);
* there is something wrong with returning this value, it has been received but throws an error when passed back from ksoap *
soapResponse = (String) envelope.getResponse(); //Exception is thrown here
String strrequest = andHttpTransport.requestDump;
String strresponse = andHttpTransport.responseDump;
}catch(Exception e){soapResponse = "Nope not working "+"
" + e.getMessage() + "/n/n" + e.getStackTrace() ;}
} else {soapResponse="You are not online"; }
tv.setText(soapResponse);
}
}
If I am doing something dumb and some one can point it out I'd appreciate it.
Is there a directive to not cache and reuse wsdl in Android like there is in PHP?
Maybe using net beans will help, that's next when I have time. If anyone can please help in the interim, don't hesitate to suggest something.
<?php
class naturallyIrrational {
private $arrval = array("pi" => 3.1415,"e" => 2.7183, "rt2" => 1.414, "phi" => 1.618 );
function getIrrationalvalue($valname) {
$myFile = "logFile.html";
$fh = fopen($myFile, 'a') or die("can't open file");
$datq = date('m/d/Y h:i:s a', time());
fwrite($fh, $datq);
if (isset($this->arrval[$valname])) {
$stringData = " ".$valname." = ".$this->arrval[$valname]."<br/>";
fwrite($fh, $stringData);
fclose($fh);
return $this->arrval[$valname];
} else {
throw new SoapFault("Server","Unknown Symbol '$valname'.");
}
}
}
$server = new SoapServer("naturallyIrrational.wsdl");
$server->setClass("naturallyIrrational");
$server->handle();