B4J Question Internal Server Error

Discussion in 'B4J Questions' started by aaronk, Jun 17, 2015.

  1. aaronk

    aaronk Well-Known Member Licensed User


    I originally had a issue trying to send a SOAP message/request but have now solved that issue. (http://www.b4x.com/android/forum/threads/help-with-soap-in-b4j.55088/)

    Now when I send the request I am getting a error and the reply I am getting is as below:

    <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Receiver</soap:Value></soap:Code><soap:Reason><soap:Text xml:lang="en">Server was unable to process request. ---&gt; Data at the root level is invalid. Line 1, position 1.</soap:Text></soap:Reason><soap:Detail /></soap:Fault></soap:Body></soap:...
    Internal Server Error

    Can't seem to work out where Line 1, Position 1 is?

    The code I am using to send the request is as follows:

    'Non-UI application (console / server application)
    #Region  Project Attributes
    #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>" & _

    "JOB1", Me)
    "https://xxx.xxx.xxx.xxx/Accounts.asmx", requestSoapXML)

    End Sub

    Public Sub JobDone (Job As HttpJob)
    If Job.Success = True Then
    End If
    End Sub
    I do have the code working in VB.net but want to port it over to B4J since I have most of my other code working already in B4J, but if I can't solve the issue then I am going to have to port my B4J code to VB.net and give up with B4J and continue with VB.net.

    I can't post my VB.net code in the forum but willing to send a PM to anyone that wants to help (serious people only please)

    Anyone know where the error is happening ?
  2. Erel

    Erel Administrator Staff Member Licensed User

    Why don't you use the new smart strings literal?
    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/'>
         <CredentialsHeader xmlns='https://xxx.xxx.xxx.xxx/test/API'>
         <ListAccounts xmlns='https://xxx.xxx.xxx.xxx/test/API' />
    Maybe you need to set the content type as done here: http://www.b4x.com/android/forum/threads/soap-textbox-info.19961/#post-155159 ?
    The SOAPAction header is also sometimes required.
  3. aaronk

    aaronk Well-Known Member Licensed User

    I guess I could do that.

    Yeah I have tied adding that but made no difference.

    I tried that as well and still get the same error.

    Are you interested in helping me converting the VB.net project (that works) to B4J if I PM you the VB.net project?
  4. Erel

    Erel Administrator Staff Member Licensed User

    I cannot convert it for you. Sorry.

    If I were to debug this issue, I would have used WireShark or a similar tool to monitor the http requests and see the exact request sent from the other client. This way you will be able to send the same request from your B4J program.
  5. aaronk

    aaronk Well-Known Member Licensed User

    Yeah I tired using WireShark but couldn't read what was being sent since it's a https request and the data was encrypted. (unless I was capturing the WireShark data wrong)
  6. Erel

    Erel Administrator Staff Member Licensed User

    Can't you temporary switch to http?
  7. aaronk

    aaronk Well-Known Member Licensed User

    I did try http rather than https but the request didn't work so I am guessing it needs to be https.

    I will have a play and see if I can get it to work with http so I can see what gets sent.
  8. aaronk

    aaronk Well-Known Member Licensed User

    Ended up getting it to work. Had to use Soap1.2 and now the commands are working.
    Jmu5667 and Erel like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice