So far, I have created a PHP client and a VB.NET client that successfully called my PHP service. For the latter to work, I needed to use the SoapUI tool from SourceForge . He told me that my wsdl is not WS-I compliant. I do not need the Pro version for interactive testing of my service, since it allows you to directly edit the soap request. After fixing my WSDL and getting the VB.Net Android client working, itβs still a problem.
I also attached the source code for ksoap2-andriod so that I can go through debugging. This helped a little, but there are related dependencies for which the source is not included, in particular "kxml2 v1.6". If anyone can point me to the source of zip or Jar, I would appreciate it.
This is an error that I cannot get when calling a PHP web service 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 )
Telling me that he cannot parse WSDL \ XML - poistion @ 10.42 is the end of the discovery definition tag.
I believe that since WSDL is now WS-I compatible, the problem is with these service namespace definitions that are interpreted by Ksoap2. Here is my client code for Android.
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);
* something is wrong with the return of this value, it was received, but it gives an error when transferring 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 "+"\n\n" + e.getMessage() + "/n/n" + e.getStackTrace() ;} } else {soapResponse="You are not online"; } tv.setText(soapResponse); } }
If I am doing something dumb, and someone can point it out, I would appreciate it.
Is there a directive not to cache and reuse wsdl in Android, as in PHP?
Maybe using net beans will help, what's next when I have time. If someone can help with this, feel free 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();