Android Question WCF get method issue

vincentehsu

Member
Licensed User
Longtime User
Dear Sir:
I can pass the JSON parameter via browser and get the json result,how can i use the httpjob to get the result
B4X:
http://125.227.11.94/services/MyTranService.svc/My?string={%22TXNCode%22:%22TXN_REGISTER_R001%22,%22DeviceID%22:%229990B9F3-4E64-4C71-9000-95F638FE8FA8%22,%22TerminalID%22:%228cde526a2003%22,%22MAC%22:%22%22,%22EMSK%22:%22%22,%22ECSK%22:%22%22,%22KSN4CSK%22:%22%22}

result
B4X:
{"Check_ReginstrationResult":"{\"MAC\":\"\",\"Message\":\"Login\",\"TXNCode\":\"TXN_REGISTER_R001\"}"}
 

vincentehsu

Member
Licensed User
Longtime User
Dear Erel:
What kind of parameter should i use?I've been use as belw,but I get error
B4X:
Dim lst As Map
            lst.Initialize
            lst.Put("TXNCode","TXN_TRANQRY_R001")
            lst.Put("DeviceID",Main.PhoneMac)
            'lst.Put("DeviceID","AAA")
            lst.Put("TerminalID",Main.SelectedDeviceMac)
            'lst.Put("TerminalID","ST100079")
            lst.Put("ECSK","")
            lst.Put("EMSK","")
            lst.Put("KSN4CSK","")
            lst.Put("MAC","")
            MyJosn.Initialize(lst)
            Log(MyJosn.ToString)
            job1.Initialize("Job1", Me)
            job1.download2("http://125.227.11.94/Services/MyTranService.svc/My?string=", Array As String("TXNCode",MyJosn.ToString))
            job1.GetRequest.Timeout = 6000000

Log file
B4X:
{"TXNCode":"TXN_TRANQRY_R001","DeviceID":"B8:5E:7B:07:43:92","MAC":"","EMSK":"","KSN4CSK":"","ECSK":"","TerminalID":"5C:51:4F:2B:9F:C5"}


** Service (httputils2service) Create **


** Service (httputils2service) Start **


JobName = Job1, Success = false


Error: org.apache.http.conn.HttpHostConnectException: Connection to http://125.227.11.94 refused


java.io.IOException: read failed, socket might closed or timeout, read ret: -1
 
Upvote 0

vincentehsu

Member
Licensed User
Longtime User
Dear Erel:
I've change my code to below
B4X:
job1.download2("http://125.227.11.94/Services/MyTranService.svc/My", Array As String("string",MyJosn.ToString))

I still get the error
B4X:
** Activity (main) Create, isFirst = true **


** Activity (main) Resume **


** Activity (main) Pause, UserClosed = true **


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


** Activity (agree) Resume **


** Activity (agree) Pause, UserClosed = true **
** Activity (selectdevice) Create, isFirst = true **


** Activity (selectdevice) Resume **


{"TXNCode":"TXN_TRANQRY_R001","DeviceID":"AAA","MAC":"","EMSK":"","KSN4CSK":"","ECSK":"","TerminalID":"ST100079"}


** Service (httputils2service) Create **


** Service (httputils2service) Start **


JobName = Job1, Success = false


Error: org.apache.http.conn.HttpHostConnectException: Connection to http://125.227.11.94 refused


java.io.IOException: read failed, socket might closed or timeout, read ret: -1
 
Upvote 0

vincentehsu

Member
Licensed User
Longtime User
Why I've use the same code,but i get error?
B4X:
Error: org.apache.http.conn.HttpHostConnectException: Connection to http://125.227.11.94 refused

Am I miss something? It's my sourcecode,pls help me to find what's going on?


Is the Javac.exe version or andriod.jar version issue?
I use
C:\Program Files (x86)\Java\jdk1.8.0_25\bin\javac.exe

C:\Program Files (x86)\Android\android-sdk\platforms\android-14\android.jar
 

Attachments

  • WebServicesWithB4A.zip
    407.7 KB · Views: 168
Upvote 0

vincentehsu

Member
Licensed User
Longtime User
Dear Erel:
I've solved the WCF get method problem
You are right,I should use following code
B4X:
Dim lst As Map
    lst.Initialize
    lst.Put("TXNCode","TXN_LOGIN_L001")
    lst.Put("MerchantUserID",txt_UserID.Text)
    lst.Put("UserPwd",txt_Password.Text)
    lst.Put("DevicePlatform","Andriod")
    lst.Put("TerminalSN",Main.SelectedDeviceName)
    lst.Put("TerminalID",Main.SelectedDeviceMac)
    lst.Put("DeviceID",Main.PhoneMac)
    lst.Put("Latitude",Lat)
    lst.Put("Longitude",Logt)
    lst.Put("MAC","")
    lst.Put("EMSK","")
    lst.Put("KSN4MSK","")
    lst.Put("ECSK","")
    lst.Put("KSN4CSK","")
    Dim MyJson As JSONGenerator
    MyJson.Initialize(lst)
    Log(MyJson.ToString)
    job1.Initialize("job1", Me)
    job1.Download2("http://125.227.11.94/services/MyTranService.svc/Login", Array As String("string", MyJson.ToString))

and the mobile device should turn wifi on.
 
Upvote 0
Top