简体   繁体   English

错误:java.lang.IllegalArgumentException:请求不能为null

[英]Error: java.lang.IllegalArgumentException: Request must not be null

I am using B4A for calling ASMX service also used httputils2 library. 我正在使用B4A来调用ASMX服务,也使用了httputils2库。

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. java.lang.IllegalArgumentException:请求不能为null。

How can I fix it? 我该如何解决?

You will have to : 你不得不 :

  1. load in your browser the asmx file when it is compiled 编译时在浏览器中加载asmx文件
  2. click on the method 点击方法
  3. copy the post soap 复制邮政肥皂
  4. copy the headers (content-type and SOAPaction) 复制标头(内容类型和SOAPaction)
  5. generate in B4A a multiline string literal with the soap (fe stringliteral = $"..."$) 在B4A中使用肥皂生成多行字符串文字(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. 在此字符串文字中,将字符串查询替换为值“ mysql = insert into users(facebook_id)values('ersdxc')”,您将必须使用stringutils和asmx一侧的urldecode进行urlencode。
  7. post the string literal with the headers fe 发布带有标题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. 另请注意,不推荐使用HttpUtils2,您将必须使用OkHttp和OkHttpUtils2库。 There is no difference in the code when using these two libraries. 使用这两个库时,代码没有区别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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