B4J Question Help with SOAP in B4J

aaronk

Well-Known Member
Licensed User
Hi,

I am having a issue trying to send a SOAP request.
I am using a Non-UI Application.

I can't say I have ever done SOAP messages/requests before so I am learning as I work on this.

The following is the code I am using:
(I removed the IP from the code I posted)

B4X:
'Non-UI application (console / server application)
#Region  Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
   
End Sub

Sub AppStart (Args() As String)

    Dim job1 As HttpJob
       Dim requestSoapXML As String

       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:Header>" & _
                    "    <CredentialsHeader xmlns='https://xxx.xxx.xxx.xxx/test/API'>" & _
                    "      <OrganizationID>1234</OrganizationID>" & _
                    "      <Username>Admin</Username>" & _
                    "      <Password>1234</Password>" & _
                    "    </CredentialsHeader>" & _
                    "  </soap:Header>" & _
                    "  <soap:Body>" & _
                    "    <ListAccounts xmlns='https://xxx.xxx.xxx.xxx/test/API' />" & _
                    "  </soap:Body>" & _
                    "</soap:Envelope>"
   

      job1.Initialize("JOB1", Me)
       job1.PostString("https://xxx.xxx.xxx.xxx/Accounts.asmx", requestSoapXML)

    StartMessageLoop
   
End Sub

Public Sub JobDone (Job As HttpJob)
    If Job.Success = True Then
        Log(Job.GetString)
    End If
   Job.Release
End Sub
The error I am getting is:

Program started.
java.lang.RuntimeException: java.lang.NoClassDefFoundError: javafx/application/Platform
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:114)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:82)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.main(main.java:29)
Caused by: java.lang.NoClassDefFoundError: javafx/application/Platform
at anywheresoftware.b4j.objects.FxBA.postRunnable(FxBA.java:17)
at anywheresoftware.b4a.keywords.Common.CallSubDelayed4(Common.java:484)
at anywheresoftware.b4a.keywords.Common.CallSubDelayed2(Common.java:468)
at b4j.example.httpjob._postbytes(httpjob.java:215)
at b4j.example.httpjob._poststring(httpjob.java:261)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
Program terminated (StartMessageLoop was not called).
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:606)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:227)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:156)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
... 3 more
Caused by: java.lang.ClassNotFoundException: javafx.application.Platform
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 20 more
I guess I am doing something wrong..

Anyone know what I have done wrong ?
 

aaronk

Well-Known Member
Licensed User
Thanks for the reply.
Didn't realise that I needed to use those 2 modules rather than the library that I was using.

When I use it I am getting this error:

Program started.
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
at sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:397)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)
at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:399)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:143)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:108)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
at anywheresoftware.b4a.http.HttpClientWrapper.executeWithTimeout(HttpClientWrapper.java:310)
at anywheresoftware.b4a.http.HttpClientWrapper.access$0(HttpClientWrapper.java:308)
at anywheresoftware.b4a.http.HttpClientWrapper$ExecuteHelper.run(HttpClientWrapper.java:207)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
Any ideas on what is causing this to happen ?
 

aaronk

Well-Known Member
Licensed User
This means that the SSL certificate is not recognized.
Any idea on how to make it so that it is recognized ?

Is this a SSL certificate error or just that B4J (Java) doesn't like the certificate that it received ?
 
Top