Android Question Post with HttpUtils2

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Hi.
I have a WebService (asmx) that I would like to call with B4A App. I am missing something on the calling string. In fact while the direct call works fine, when I insert it in a PostString, I cannot obtain the answer from the service. The project is very simple and I attach it.
The direct call to the browser is:

http://www.galileo2000.it/acmmate/AcmMate.asmx/Work?Request=O=100

I have used a:

PostString("http://www.galileo2000.it/acmmate/AcmMate.asmx/Work","Request=O=100")

The project is copied from the example on UttpUtils, and is self explanatory.
Thanks in advance
 

Attachments

  • TestPost.zip
    6.9 KB · Views: 201

DonManfred

Expert
Licensed User
Longtime User
The url you want to call is http://www.acmmate.com/Galileo2000/AcmMate.asmx/Work with httpjob. If i open this url in a browser i get a resource not found error.

The httpjob itself it working (and shows the same error i get in my browser)

** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
<!DOCTYPE html>
<html>
<head>
<title>The resource cannot be found.</title>
<meta name="viewport" content="width=device-width" />
<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:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
.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; }
@media screen and (max-width: 639px) {
pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
}
@media screen and (max-width: 479px) {
pre { width: 280px; }
}
</style>
</head>
<body bgcolor="white">
<span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>
<h2> <i>The resource cannot be found.</i> </h2></span>
<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
<b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. &nbsp;Please review the following URL and make sure that it is spelled correctly.
<br><br>
<b> Requested URL: </b>/Galileo2000/AcmMate.asmx/Work<br><br>
<hr width=100% size=1 color=silver>
<b>Version Information:</b>&nbsp;Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34274
</font>
</body>
</html>
<!--
[HttpException]: The file &#39;/Galileo2000/AcmMate.asmx&#39; does not exist.
at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath)
at System.Web.UI.WebServiceParser.GetCompiledType(String inputFile, HttpContext context)
at System.Web.Services.Protocols.WebServiceHandlerFactory.GetCompiledType(String url, HttpContext context)
at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)
at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication
Message longer than Log limit (4000). Message was truncated.
JobName = Job2, Success = false
Error: Not Found
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
 
Last edited:
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Hi. Thanks, but you have to open the Url with the complete string, reported in my first message. (and it works, just try clicking it) It is an asmx service.
I reproduce it:

http://www.galileo2000.it/acmmate/AcmMate.asmx/Work?Request=O=100

the answer is (the visible part, I mean):

<?xml version="1.0" encoding="UTF-8"?>
<string xmlns="http://tempuri.org/">#!OK!#</string>

Now the question is to correctly divide that call to use the PostString..
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim job2 As HttpJob
    Dim Url As String : Url="http://www.galileo2000.it/acmmate/AcmMate.asmx/Work?"
End Sub
' Direct call in browser is : http://www.galileo2000.it/acmmate/AcmMate.asmx/Work?Request=O=100
Sub Activity_Create(FirstTime As Boolean)
   'Send a POST request
   Dim Req="Request=O=100"
   job2.Initialize("Job2", Me)
   job2.PostString(Url,Req)
End Sub
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Probably I did some confusion. Sorry... Thanks for your time.. Now it works. I don't know why I swapped the site name (actually I have a site with that name, so probably i copied the wrong string..) Sorry again.. Thanks.
 
Upvote 0
Top