Error: java.lang.IllegalArgumentException: Request must not be null

904 Views Asked by At

I am using B4A for calling ASMX service also used httputils2 library.

I use the following code for calling service:

Private httprequest As HttpJop
httprequest.Initialize("Job1", Me)
httprequest.PostString("http://192.168.1.104/service.asmx/query","mysql="&"insert into users (facebook_id) values ('ersdxc')")

When I run my application, I get this error:

java.lang.IllegalArgumentException: Request must not be null.

How can I fix it?

1

There are 1 best solutions below

0
Nikolaos Hatzistelios On

You will have to :

  1. load in your browser the asmx file when it is compiled
  2. click on the method
  3. copy the post soap
  4. copy the headers (content-type and SOAPaction)
  5. generate in B4A a multiline string literal with the soap (f.e. stringliteral = $"..."$)
  6. replace in this string literal the string query with the value "mysql=insert into users (facebook_id) values ('ersdxc')" which you will have to urlencode with stringutils and on the asmx side urldecode.
  7. post the string literal with the headers f.e.

    Private httprequest As HttpJop
    httprequest.Initialize("Job1", Me)
    httprequest.PostString("http://192.168.1.104/service.asmx/query", stringliteral)
    httprequest.GetRequest.SetContentType("text/xml; charset=utf-8")
    httprequest.GetRequest.SetHeader("SOAPAction", """REPLACE_WITH_YOUR_SOAP_ACTION_HERE""")

Please also note that the HttpUtils2 is deprecated and you will have to use the OkHttp and OkHttpUtils2 libraries. There is no difference in the code when using these two libraries.