相关疑难解决方法(0)

如何在Android上调用SOAP Web服务

我在查找如何使用Android调用标准SOAP/WSDL Web服务方面遇到很多麻烦.我能找到的所有文件都是非常复杂的文档和对"kSoap2"的引用,然后是一些关于使用SAX手动解析它的一些内容.好的,这很好,但是它是2008年,所以我认为应该有一些很好的库来调用标准的Web服务.

Web服务基本上是在NetBeans中创建的.我想有IDE支持生成管道类.我只需要最简单/最优雅的方式来从基于Android的手机联系基于WSDL的Web服务.

java android soap wsdl web-services

545
推荐指数
21
解决办法
41万
查看次数

Android HttpPost消息不会通过网络发送其有效负载

我正在尝试发送一个简单的字符串作为HttpPost消息的内容.

问题是,HttpPost消息的主体永远不会成为线路.(说Wireshark捕获).标题看起来很好(包括正确计算的Content-Length.

这是代码的样子:

String url = "http://1.2.3.4/resource";
HttpClient client = new DefaultHttpClient();
String cmd = "AT+AVLPOS\r\n";
StringEntity se = new StringEntity(cmd);
se.setContentType("text/plain");  

HttpPost request = new HttpPost(url);
request.setHeader("Content-Type","text/plain");
request.setEntity(se);

HttpResponse response = client.execute(request);
[...]
Run Code Online (Sandbox Code Playgroud)

字符串应该是ASCII编码的,但这是一个细节.

这是WireShark中显示的内容: - >请注意,标有+的行是发送的内容,而 - 是收到的内容.

+POST /resource HTTP/1.1
+Content-Type: text/plain
+Content-Length: 11
+Host: 1.2.3.4
+Connection: Keep-Alive
+User-Agent: Apache-HttpClient/UNAVAILABLE (java 1.4)
+Expect: 100-Continue

-HTTP/1.1 200 OK
-Content-Type: text/plain
-Transfer-Encoding: chunked

-4
-OK
Run Code Online (Sandbox Code Playgroud)

应该是显示出来的(在C#中编写了一个非常简单的控制台应用程序来执行此操作,它只是起作用):

+POST /resource HTTP/1.1
+Content-Type: text/plain
+Host: 1.2.3.4
+Content-Length: 11
+Expect: 100-continue …
Run Code Online (Sandbox Code Playgroud)

java networking android http-post

5
推荐指数
1
解决办法
4389
查看次数

如何在android中将xml数据发布到服务器

因为我是android的新手请给我链接教程在服务器上发布xml数据.我面临的问题是执行post请求

public void uploadFileToServer()
 {
      DefaultHttpClient httpClient = new DefaultHttpClient();
      HttpPost httppost = new HttpPost(url_context + "/orders/order"); 
      httppost.addHeader("Accept", "text/xml");
      httppost.addHeader("Content-Type", "application/xml");
      try
      {
          StringEntity entity = new StringEntity(xmlString, "UTF-8");
          entity.setContentType("application/xml");
          httppost.setEntity(entity);
          HttpResponse response = httpClient.execute(httppost);
          BasicResponseHandler responseHandler = new BasicResponseHandler();
             String strResponse = null;
             if (response != null) 
             {
                 try {
                     strResponse = responseHandler.handleResponse(response);
                    } catch (HttpResponseException e) 
                    {
                        e.printStackTrace();  
                    } catch (IOException e) 
                    {
                            e.printStackTrace();
                    }
             }

      }
      catch (Exception ex)
      {
                 ex.printStackTrace();
      }
 }
Run Code Online (Sandbox Code Playgroud)

xml android

2
推荐指数
1
解决办法
7600
查看次数

如何在Android应用程序中将数据发布到远程服务器

可能重复:
如何在Android中执行HTTP发布?

我想将这两个值发送到服务器,比如http://localhost/twoVal.php,它将进一步处理信息.

例如,

我有val1 = 12和val2 = 13我想将这些数据发布到上面提到的URL.(可能是某些URL不一定是localhost)怎么做?此外,数据需要作为HTTP标头(POST)的一部分发送,而不是作为查询参数发送.

android

-1
推荐指数
1
解决办法
8165
查看次数

标签 统计

android ×4

java ×2

http-post ×1

networking ×1

soap ×1

web-services ×1

wsdl ×1

xml ×1