简体   繁体   中英

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

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?

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 (fe 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 fe

    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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM