Android Question New Project Problems

Tjunas

Member
Licensed User
Longtime User
HI All,

I am new to Basic4Android and I am trying to get my first project of the ground.

My First Activity is a Login page.

I am trying to call a XML Webservice to complete the login process but I am getting errors.

Below is the current code

B4X:
Sub
btnLogin_Click
RequestSoapXML = _
"<?xml version='1.0' encoding='utf-8'?>" & _
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"
& _
"<soap:Body>" & _
"<Agmen_Login xmlns='http://tempuri.org//'>" & _
"<User>Eugene</User>" & _
"</soap:Body>"
& _
"</soap:Envelope>"
job2
.Initialize(Me,Me)
job2
.PostString(url,RequestSoapXML)
job2.GetRequest.SetContentType("text/xml; charset=utf-8")
job2.GetRequest.SetHeader("SOAPAction", """http://www.Myserver.co.za/deliverymanager/services/ccd.asmx""")
End Sub
[CODE]


And this is the error Im getting


startService: class anywheresoftware.b4a.samples.httputils2.httputils2service

** Service (httputils2service) Create **

** Service (httputils2service) Start **

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="[URL]http://schemas.xmlsoap.org/soap/envelope/[/URL]" xmlns:xsi="[URL]http://www.w3.org/2001/XMLSchema-instance[/URL]" xmlns:xsd="[URL]http://www.ccdcouriers.co.za/deliverymanager/services/ccd.asmx[/URL].
  at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
  at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
  at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
  at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean&amp; abortProcessing)</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
main_jobdone (B4A line: 78)

Log(Job.GetString)
java.io.FileNotFoundException: /data/data/hippeus.ccd/cache/1: open failed: ENOENT (No such file or directory)

at libcore.io.IoBridge.open(IoBridge.java:416)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:197)
at anywheresoftware.b4a.samples.httputils2.httpjob._getstring2(httpjob.java:155)
at anywheresoftware.b4a.samples.httputils2.httpjob._getstring(httpjob.java:144)
at hippeus.ccd.main._jobdone(main.java:448)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.keywords.Common$5.run(Common.java:958)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:400)
... 18 more
** Activity (main) Create, isFirst = true **

** Activity (main) Resume **

startService: class anywheresoftware.b4a.samples.httputils2.httputils2service

** Service (httputils2service) Create **

** Service (httputils2service) Start **

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="[URL]http://schemas.xmlsoap.org/soap/envelope/[/URL]" xmlns:xsi="[URL]http://www.w3.org/2001/XMLSchema-instance[/URL]" xmlns:xsd="[URL]http://www.myserver.co.za/deliverymanager/services/ccd.asmx[/URL].
  at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
  at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
  at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
  at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean&amp; abortProcessing)</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
 
Last edited:

Tjunas

Member
Licensed User
Longtime User
Hi Erel,

I have managed to get a bit further, was able to consume the following service and get a response

http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit

But now when I call my service I get an error I have checked the response in xml from my service and I dont see a problem.

My Service XML Reponse

-<soap:Envelope>
-<soap:Body>
-<HippeusLoginResponse>
<HippeusLoginResult>Login Successful</HippeusLoginResult>
</HippeusLoginResponse>
</soap:Body>
</soap:Envelope>

Error That I Am Getting on B4A

** Activity (main) Create, isFirst = true **


** Activity (main) Resume **


startService: class anywheresoftware.b4a.samples.httputils2.httputils2service


** Service (httputils2service) Create **


** Service (httputils2service) Start **


<html>



<head>

<title>Request format is unrecognized for URL unexpectedly ending in '/HippeusLogin'.</title>

<style>

body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}

p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}

b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}

H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }

H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }

pre {font-family:"Lucida Console";font-size: .9em}

.marker {font-weight: bold; color: black;text-decoration: none;}

.version {color: gray;}

.error {margin-bottom: 10px;}

.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }

</style>

</head>



<body bgcolor="white">



<span><H1>Server Error in '/DeliveryManager' Application.<hr width=100% size=1 color=silver></H1>





<h2> <i>Request format is unrecognized for URL unexpectedly ending in '/HippeusLogin'.</i> </h2></span>



<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">



<b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.



<br><br>



<b> Exception Details: </b>System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/HippeusLogin'.<br><br>



<b>Source Error:</b> <br><br>



<table width=100% bgcolor="#ffffcc">

<tr>

<td>

<code>



An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>



</td>

</tr>

</table>



<br>
 
Upvote 0

Tjunas

Member
Licensed User
Longtime User
Ok So for the next poor soul that wants to consume a SOAP XML service built in .Net This is the steps.

1.Enable HTTPPost and HTTPGet in the WebConfig file

HTML:
<system.web>
    <webServices>
      <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
      </protocols>
    </webServices>

2. The URL for for httputils2 should be formated as follows

"http://www.YourService.co.za/services/ServiceName.asmx/MethodName"

3. Below is the Code that works

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

    Dim job2 As HttpJob
    Dim url As String
    Dim su As StringUtils
    url = "http://www.YourServer.co.za/services/YourService.asmx/YourMethod"
   
End Sub


Sub btnLogin_Click

     
    job2.Initialize("Job2", Me)
    job2.PostString(url, "User=1566")
   
End Sub


Sub JobDone (job As HttpJob)

'Msgbox("JobName = " & job.JobName & ", Success = " & job.Success,"")
If job.Success = True Then
Msgbox(job.GetString,"")
'lblConsultar.Text = job.GetString
ToastMessageShow("Succes= " & job2.Success, True)
Else
'Log("Error: " & job.ErrorMessage)
ToastMessageShow("Error: " & job.ErrorMessage, True)
End If
job.Release
End Sub


This should make it easier for the .Net guys just landing here!!!
 
Upvote 0
Top