Android Question Calling a SAP Web Service

ObiTeoKenobi

Member
Licensed User
Longtime User
Hi all,

I'm new of the forum but 1 years old licensed user of B4A
My problem: i'm trying to call a SAP Web Service by b4a application using httputils2 library.

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

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
    Dim sidij As HttpJob
    Dim url As String

    Dim lblText As Label
    Dim scvText As ScrollView

    Dim txt As String
    
    Dim requestSoapXML As String

End Sub

Sub Activity_Create(FirstTime As Boolean)

    Activity.LoadLayout("LongText")
    scvText.Panel.LoadLayout("LongText1")

    url = "http://10.1.1.4:8000/sap/bc/srt/wsdl/flv_10002P111AD1/sdef_url/ZWEB_MC_TEST?sap-client=100"
    requestSoapXML = "<?xml version=""1.0""?> <n0:ZwebTest xmlns:n0=""urn:sap-com:document:sap:soap:functions:mc-style""/>"

    Log("Imposto il messaggio di richiesta:")
    Log(requestSoapXML )

    sidij.Initialize("Job", Me)
    sidij.Username = "user"
    sidij.Password = "pass"
    sidij.poststring(url, requestSoapXML)
    sidij.GetRequest.SetContentType("text/xml; charset=""UTF-8""")

    ToastMessageShow("un momento ...", True)
End Sub

Sub JobDone (Job As HttpJob)
  Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
  If Job.Success = True Then
        Log("Risultato su job.getstring:")
        Log(Job.GetString)
        txt = ""
        txt = txt & Job.GetString
        lblText.Text=txt
  Else
          Log("Error: " & Job.ErrorMessage)
          ToastMessageShow("Error: " & Job.ErrorMessage, True)
  End If
  Job.Release
End Sub

All the code is executed correctly but in job.getstring i've the WSDL xlm file as result..

The result of my webservice is getting a string as return (ex: "hello world")
The request SOAP XML is generated by SAP.

This is the expected result:
B4X:
<?xml version="1.0" encoding="UTF-8"?>
<n0:ZwebTestResponse xmlns:n0="urn:sap-com:document:sap:soap:functions:mc-style">
<OMsg>Forse funziona!</OMsg>
</n0:ZwebTestResponse>

Any suggestion?
 

eps

Expert
Licensed User
Longtime User
From my simple understanding of what you're trying to achieve it doesn't look as if you're actually making a request of any kind. Surely for this part

B4X:
<?xml version=""1.0""?> <n0:ZwebTest xmlns:n0=""urn:sap-com:document:sap:soap:functions:mc-style"

It actually needs to do something, none of that looks like a request or get or something similar..? Maybe it's mc-style, but that doesn't sound like a request of any sort.
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Ah, okay...

So you get Job.Success = True

I usually use
B4X:
TextReader1.Initialize(Job.GetInputStream)

        Dim line As String

        line = TextReader1.ReadLine

        TextReader1.Close

        Log("done parsing page.")
 
Upvote 0

ObiTeoKenobi

Member
Licensed User
Longtime User
A string.
When i test the service directly in sap i get this as request:
B4X:
<?xml version="1.0"?>
<n0:ZwebTest xmlns:n0="urn:sap-com:document:sap:soap:functions:mc-style"/>
and this as response:
B4X:
<?xml version="1.0" encoding="UTF-8"?>
<n0:ZwebTestResponse xmlns:n0="urn:sap-com:document:sap:soap:functions:mc-style">
<OMsg>Forse funziosa!</OMsg>
</n0:ZwebTestResponse>
 
Upvote 0

eps

Expert
Licensed User
Longtime User

Try this as the code to retrieve the data and see what you get back.
 
Upvote 0

eps

Expert
Licensed User
Longtime User
It feels like the request is incorrect.

Maybe try this?

requestSoapXML = "<n0:ZwebTest xmlns:n0=""urn:sap-com:document:sap:soap:functions:mc-style""/>"
 
Upvote 0

ObiTeoKenobi

Member
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…