Hi, I am trying to invoke a web service operation, but I have no luck so far.
I have tested the SOAP-based web service using SOAPUI and this is the SOAP request XML that the web service is expecting
I have tested it in SOAPUI, it works perfectly, here is the HTTP log:
And this is my B4A codes:
But I always get a Client.NoSOAPAction Error as below:
Did I miss something?
Appreciate any help.
:sign0085:
I have tested the SOAP-based web service using SOAPUI and this is the SOAP request XML that the web service is expecting
<soapenv:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ejb='http://ejb.dm.service.abc.nz'>
<soapenv:Header/>
<soapenv:Body>
<ejb:doInitialLogin soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<arg_0_15 xsi:type="xsd:string">mydomain</arg_0_15>
<arg_1_15 xsi:type="xsd:string">testuser1</arg_1_15>
<arg_2_15 xsi:type="xsd:string">testpassword</arg_2_15>
<arg_3_15 xsi:type="xsd:string">LIB</arg_3_15>
</ejb:doInitialLogin>
</soapenv:Body>
</soapenv:Envelope>
I have tested it in SOAPUI, it works perfectly, here is the HTTP log:
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> "POST /services/MyService HTTP/1.1[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> "Accept-Encoding: gzip,deflate[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> "Content-Type: text/xml;charset=UTF-8[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> "SOAPAction: ""[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> "Host: soa61.mydomain.com:9080[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> "Content-Length: 756[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> "[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> "<soapenv:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ejb='http://ejb.dm.service.abc.nz'>[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> " <soapenv:Header/>[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> " <soapenv:Body>[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> " <ejb:doInitialLogin soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> "[0x9]<!-- domain -->[\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> " <arg_0_15 xsi:type="xsd:string">mydomain</arg_0_15>[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> "[0x9]<!-- user name -->[\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> " <arg_1_15 xsi:type="xsd:string">testuser1</arg_1_15>[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> "[0x9]<!-- password -->[\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> " <arg_2_15 xsi:type="xsd:string">password</arg_2_15>[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> "[0x9]<!-- Library Name -->[\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> " <arg_3_15 xsi:type="xsd:string">LIB1</arg_3_15>[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> " </ejb:doInitialLogin>[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> " </soapenv:Body>[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:>> "</soapenv:Envelope>"
Thu Jan 12 16:16:38 NZDT 2012EBUG:<< "HTTP/1.1 200 OK[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:<< "HTTP/1.1 200 OK[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:<< "Content-Type: text/xml; charset=utf-8[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:<< "Content-Language: en-NZ[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:<< "Content-Length: 987[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:<< "Date: Thu, 12 Jan 2012 03:16:37 GMT[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:<< "Server: WebSphere Application Server/6.1[\r][\n]"
Thu Jan 12 16:16:38 NZDT 2012EBUG:<< "[\r][\n]"
And this is my B4A codes:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim webClient As HttpClient
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 btnLogin As Button
Dim pnlDM As Panel
Dim webRequest As HttpRequest
Dim lblLoginStatus As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("MainScreen")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnLogin_Click
Dim endPoint As String
Dim requestSoapXML As String
Dim domain, userName, password, library As String
domain = "mydomain"
userName = "testuser1"
password = "password"
library = "LIB"
endPoint = "http://soa61.mydomain.com:9080/services/MyService"
requestSoapXML = _
"<soapenv:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ejb='http://ejb.dm.service.abc.nz'>" & _
"<soapenv:Header/>" & _
"<soapenv:Body>" & _
"<ejb:doInitialLogin soapenv:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>" & _
"<arg_0_15 xsi:Type='xsd:String'>" & domain & "</arg_0_15>" & _
"<arg_1_15 xsi:Type='xsd:String'>" & userName & "</arg_1_15>" & _
"<arg_2_15 xsi:Type='xsd:String'>" & password & "</arg_2_15>" & _
"<arg_3_15 xsi:Type='xsd:String'>" & library & "</arg_3_15>" & _
"</ejb:doInitialLogin>" & _
"</soapenv:Body>" & _
"</soapenv:Envelope>"
Log(requestSoapXML )
webRequest.InitializePost2(endPoint, requestSoapXML .GetBytes("UTF8"))
webRequest.SetHeader("Content-Type", "application/soap+xml; charset=utf-8")
webRequest.Timeout = 10000
webClient.Initialize("webClient")
If webClient.Execute(webRequest, 1) = False Then Return
End Sub
Sub webClient_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim resultSoapXML As String
resultSoapXML = Response.GetString("UTF8")
lblLoginStatus.Text = resultSoapXML
Log("Success : " & resultSoapXML)
End Sub
Sub webClient_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Dim resultSoapXML As String
resultSoapXML = Response.GetString("UTF8")
lblLoginStatus.Text = resultSoapXML
Log("Error : " & resultSoapXML)
Log("Reason: " & Reason)
Log("StatusCode: " & StatusCode)
End Sub
But I always get a Client.NoSOAPAction Error as below:
Error : <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>Client.NoSOAPAction</faultcode><faultstring>WSWS3147E: Error: no SOAPAction header!</faultstring></soapenv:Fault></soapenv:Body></soapenv:Envelope>
Did I miss something?
Appreciate any help.
:sign0085:
Last edited: